Created
January 16, 2014 14:19
Revisions
-
jakzal created this gist
Jan 16, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ <?php namespace Zalas\Bundle\PackagistBundle\Command; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class FindPackageListsCommand extends ContainerAwareCommand { protected function configure() { $this->setName('packagist:crawl:package-lists'); $this->addOption('batch-size', 'bs', InputOption::VALUE_REQUIRED, 'The batch size', 100); } protected function execute(InputInterface $input, OutputInterface $output) { $finder = $this->getContainer()->get('zalas_packagist.package_list_page_finder'); $finder->setBatchSize($input->getOption('batch-size')); $finder->run('https://packagist.org'); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,57 @@ <?php namespace spec\Zalas\Bundle\PackagistBundle\Command; use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Zalas\Packagist\Worker\PackageListFinder; class FindPackageListsCommandSpec extends ObjectBehavior { function let(InputInterface $input, PackageListFinder $packageListPageFinder) { $input->bind(Argument::cetera())->willReturn(); $input->isInteractive()->willReturn(false); $input->validate()->willReturn(); $input->getOption('batch-size')->willReturn(1); $packageListPageFinder->setBatchSize(Argument::cetera())->willReturn(); } function it_is_a_container_aware_command() { $this->shouldHaveType('Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand'); } function it_has_a_name() { $this->getName()->shouldReturn('packagist:crawl:package-lists'); } function it_runs_the_package_list_page_finder(ContainerInterface $container, InputInterface $input, OutputInterface $output, PackageListFinder $packageListPageFinder) { $container->get('zalas_packagist.package_list_page_finder')->willReturn($packageListPageFinder); $packageListPageFinder->run('https://packagist.org')->shouldBeCalled(); $this->setContainer($container); $this->run($input, $output); } function it_sets_the_batch_size_if_given(ContainerInterface $container, InputInterface $input, OutputInterface $output, PackageListFinder $packageListPageFinder) { $batchSize = 100; $container->get('zalas_packagist.package_list_page_finder')->willReturn($packageListPageFinder); $input->getOption('batch-size')->willReturn($batchSize); $packageListPageFinder->setBatchSize($batchSize)->shouldBeCalled(); $packageListPageFinder->run('https://packagist.org')->willReturn(); $this->setContainer($container); $this->run($input, $output); } }