find() public method

public find ( $name )
 public function testExecute()
 {
     $expected = '/^.+ [a-z0-9]+@local.+api-key: [a-f0-9]+ secret: [a-f0-9]+$/';
     $commandTester = new CommandTester($this->instance->find('hayapi:create-user'));
     $commandTester->execute(array('username' => $this->userIdentifier, 'email' => $this->userIdentifier, 'password' => $this->userIdentifier), array('interactive'));
     $this->assertRegExp($expected, $commandTester->getDisplay());
 }
 public function testCompile()
 {
     $command = $this->application->find('help');
     $commandTester = new CommandTester($command);
     $commandTester->execute([], ['interactive' => false]);
     $this->assertTrue(true);
 }
 public function testExecute()
 {
     $expected = '/^Hashing pid data/';
     $commandTester = new CommandTester($this->instance->find('haytool:pid-obfuscation'));
     $commandTester->execute(array());
     $this->assertRegExp($expected, $commandTester->getDisplay());
 }
 public function testExecute()
 {
     $expected = 'Connection opened to foo:22/path/';
     $commandTester = new CommandTester($this->instance->find('haytool:file-upload'));
     $commandTester->execute(array());
     $this->assertStringStartsWith($expected, $commandTester->getDisplay());
 }
 /**
  * @dataProvider loadCommandProvider
  *
  * @param array  $inputs
  * @param string $expected
  */
 public function testFixturesRegistering(array $inputs, $expected)
 {
     $command = $this->application->find('hautelook_alice:fixtures:load');
     $commandTester = new CommandTester($command);
     $commandTester->execute($inputs, ['interactive' => false]);
     $this->assertEquals(trim($expected, ' '), trim($commandTester->getDisplay(), ' '));
 }
Example #6
0
 /**
  * @Given I run Sylius Install Load Sample Data command
  */
 public function iRunSyliusInstallSampleDataCommand()
 {
     $this->application = new Application($this->kernel);
     $this->application->add(new InstallSampleDataCommand());
     $this->command = $this->application->find('sylius:install:sample-data');
     $this->tester = new CommandTester($this->command);
 }
 public function testExecuteWithNoResults()
 {
     $expected = 'No analytics results found for the period, have you completed the rollup?';
     $commandTester = new CommandTester($this->instance->find('analytics:daily-rollup'));
     $commandTester->execute(array());
     $display = $commandTester->getDisplay();
     $this->assertContains($expected, $display);
 }
 public function testExecuteWithNoResults()
 {
     $expected = 'No records present for output';
     $commandTester = new CommandTester($this->instance->find('analytics:daily-export'));
     $commandTester->execute(array());
     $display = $commandTester->getDisplay();
     $this->assertContains($expected, $display);
 }
Example #9
0
 public function testSkipAllJob()
 {
     $this->mockCronHelper();
     $command = $this->application->find('oro:cron');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), '--skipCheckDaemon' => true));
     $result = $this->runCommand(CronCommand::COMMAND_NAME, []);
     $this->assertNotEmpty($result);
     $this->checkMessage('AllJobSkip', $result);
 }
 /**
  * Indicates if a command exists
  *
  * @param string $command A command name (i.e.: cache:clear)
  * @return bool
  */
 public function commandExists($command)
 {
     try {
         $this->_app->find($command);
         $exists = true;
     } catch (InvalidArgumentException $e) {
         $exists = false;
     }
     return $exists;
 }
 public function testExecuteWeekly()
 {
     $expected = '/^(\\w+\\s){5}\\d{4}-\\d{2}-\\d{2}T(00:){2}00\\+0{4}\\s\\w+\\s\\d{4}-\\d{2}-\\d{2}T23:59:59\\+0{4}/';
     $commandTester = new CommandTester($this->instance->find('analytics:prepare'));
     $commandTester->execute(array('--period' => PrepareAnalyticsCommand::OUTPUT_WEEKLY));
     $display = $commandTester->getDisplay();
     $this->assertRegExp($expected, $display);
     $this->assertContains(PrepareAnalyticsCommand::OUTPUT_WEEKLY, $display);
     $this->assertContains('Extracted information on 0 quiz starts', $display);
 }
 public function testExecute()
 {
     $expectedUpdate = 'Updated county Bar with id 1';
     $expectedCreate = 'Created county Bar with id ' . PHP_INT_MAX;
     $path = 'phpunit.xml';
     $commandTester = new CommandTester($this->instance->find('haytool:lha-counties'));
     $commandTester->execute(array('path' => $path, 'includeFirstLine' => true));
     $this->assertStringStartsWith($expectedUpdate, $commandTester->getDisplay());
     $commandTester->execute(array('path' => $path, 'includeFirstLine' => true));
     $this->assertStringStartsWith($expectedCreate, $commandTester->getDisplay());
 }
 public function testExecute()
 {
     $expectedUpdate = 'Updated parish council Bar with id 1';
     $expectedCreate = 'Created parish council Bar with id ' . PHP_INT_MAX;
     $path = 'src/TransformCore/PHE/LocalHealthAuthorityBundle/Tests/Data/test.txt';
     $commandTester = new CommandTester($this->instance->find('haytool:lha-parish-councils'));
     $commandTester->execute(array('path' => $path, 'includeFirstLine' => true));
     $this->assertStringStartsWith($expectedUpdate, $commandTester->getDisplay());
     $commandTester->execute(array('path' => $path, 'includeFirstLine' => true));
     $this->assertStringStartsWith($expectedCreate, $commandTester->getDisplay());
 }
 public function testExecute()
 {
     $expectedUpdate = 'Updated Authority for Bar with id 1';
     $expectedCreate = 'Created Authority for Bar with id ' . PHP_INT_MAX;
     $path = 'src/TransformCore/PHE/LocalHealthAuthorityBundle/Tests/Data/import.csv';
     $commandTester = new CommandTester($this->instance->find('haytool:lha-authority'));
     $commandTester->execute(array('path' => $path));
     $this->assertStringStartsWith($expectedUpdate, $commandTester->getDisplay());
     $commandTester->execute(array('path' => $path));
     $this->assertStringStartsWith($expectedCreate, $commandTester->getDisplay());
 }
 public function testExecute()
 {
     $supervisor = $this->getMockBuilder('Supervisor\\Supervisor')->disableOriginalConstructor()->getMock();
     $supervisor->expects($this->any())->method('checkConnection')->willReturn(true);
     $supervisor->expects($this->any())->method('getName')->willReturn('niceNameFoo');
     $this->supervisorManager->expects($this->any())->method('getSupervisors')->willReturn(array($supervisor));
     $this->application->add(new SupervisorListCommand());
     $command = $this->application->find('abc:supervisor:list');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName()));
     $this->assertRegExp('/Instance: niceNameFoo/', $commandTester->getDisplay());
 }
 public function testExecute()
 {
     $application = new Application($this->kernel);
     $application->add(new QueueCreateCommand());
     $command = $application->find('jobqueue:create');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), 'queue-name' => 'my:queue1', '--timeout' => 10), array('interactive' => false));
     $application->add(new QueueDeleteCommand());
     $command = $application->find('jobqueue:delete');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), 'queue-name' => 'my:queue1'), array('interactive' => false));
     $this->assertRegExp('/Queue "my:queue1" deleted/', $commandTester->getDisplay(), 'Deleted queue');
 }
 /**
  * Test execute with all the options
  *
  * @group command
  */
 public function testExecute()
 {
     static::$application->add(new ImportTranslationsCommand());
     $command = static::$application->find("lexik:translations:import");
     $command->setContainer(static::$kernel->getContainer());
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), 'bundle' => 'LexikTranslationBundle', '--cache-clear' => true, '--force' => true, '--locales' => array('en', 'fr')));
     $resultLines = explode("\n", $commandTester->getDisplay());
     $this->assertEquals('# LexikTranslationBundle:', $resultLines[0]);
     $this->assertLanguageDumped($resultLines[1]);
     $this->assertLanguageDumped($resultLines[2]);
     $this->assertEquals('Removing translations cache files ...', $resultLines[3]);
 }
 /**
  * Test execute with all the options
  *
  * @group command
  */
 public function testExecute()
 {
     static::$application->add(new ImportTranslationsCommand());
     $command = static::$application->find("lexik:translations:import");
     $command->setContainer(static::$kernel->getContainer());
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), 'bundle' => 'LexikTranslationBundle', '--cache-clear' => true, '--force' => true, '--locales' => array('en', 'fr')));
     $resultLines = explode("\n", $commandTester->getDisplay());
     $this->assertEquals('# LexikTranslationBundle:', $resultLines[0]);
     $this->assertRegExp('/Using dir (.)+(Lexik|Lexik\\/Bundle\\/)TranslationBundle\\/Resources\\/translations to lookup translation files/', $resultLines[1]);
     $this->assertRegExp('/translations\\/LexikTranslationBundle\\.((fr)|(en))\\.yml" \\.\\.\\. 17 translations/', $resultLines[2]);
     $this->assertRegExp('/translations\\/LexikTranslationBundle\\.((fr)|(en))\\.yml" \\.\\.\\. 17 translations/', $resultLines[3]);
     $this->assertEquals('Removing translations cache files ...', $resultLines[4]);
 }
 public function setUp()
 {
     self::bootKernel();
     $this->taskRunner = self::$kernel->getContainer()->get('task.runner');
     $this->taskScheduler = self::$kernel->getContainer()->get('task.scheduler');
     $this->taskRepository = self::$kernel->getContainer()->get('task.storage.task');
     $this->taskExecutionRepository = self::$kernel->getContainer()->get('task.storage.task_execution');
     $command = $this->getCommand();
     $this->application = new Application(self::$kernel);
     $this->application->add($command);
     $this->command = $this->application->find($command->getName());
     $this->commandTester = new CommandTester($this->command);
     $this->purgeDatabase();
 }
 public function testExecute()
 {
     $application = new Application($this->httpClient->getKernel());
     $application->add(new InitKillQueueCommand());
     /** @var InitKillQueueCommand $command */
     $command = $application->find('syrup:queue:kill-init');
     $commandTester = new CommandTester($command);
     $commandTester->execute(['command' => $command->getName()]);
     $this->assertEquals(0, $commandTester->getStatusCode());
     /** @var QueueFactory $queueFactory */
     $queueFactory = $this->httpClient->getContainer()->get('syrup.queue_factory');
     $queueId = 'syrup_kill_' . str_replace('.keboola.com', '', gethostname());
     $queueService = $queueFactory->get($queueId);
     $this->assertInstanceOf('Keboola\\Syrup\\Service\\Queue\\QueueService', $queueService);
     $snsConfig = $this->httpClient->getContainer()->getParameter('sns');
     $snsClient = new SnsClient(['credentials' => ['key' => $snsConfig['key'], 'secret' => $snsConfig['secret']], 'region' => isset($snsConfig['region']) ? $snsConfig['region'] : 'us-east-1', 'version' => '2010-03-31']);
     $subscriptions = $snsClient->listSubscriptionsByTopic(['TopicArn' => $snsConfig['topic_arn']]);
     $ssArr = $subscriptions->get('Subscriptions');
     $ourSS = null;
     foreach ($ssArr as $ss) {
         if (false !== strstr($ss['Endpoint'], $queueId)) {
             $ourSS = $ss;
             break;
         }
     }
     $this->assertNotNull($ourSS);
     $this->assertEquals('sqs', $ourSS['Protocol']);
     $this->assertEquals($snsConfig['topic_arn'], $ourSS['TopicArn']);
 }
 /**
  * Prepare and set instance of execute command.
  */
 private function setExecuteCommandInstance()
 {
     $kernel = self::createClient()->getKernel();
     $application = new Application($kernel);
     $application->add(new SyncStorageCreateCommand());
     $this->executeCommand = $application->find('ongr:sync:storage:create');
 }
    /**
     * @test
     * @group functional
     */
    public function execute()
    {
        $application = new Application(static::$kernel);
        $application->add(new SyncSchemaCommand());
        $command = $application->find('eav:schema:sync');
        $commandTester = new CommandTester($command);
        // FIRST PASS
        $commandTester->execute(array('command' => $command->getName()));
        $output = <<<OUTPUT
+-----------+------------------------------------------------+
| Created:  | Padam87\\AttributeBundle\\Tests\\Model\\Subscriber |
+-----------+------------------------------------------------+
| Existing: |                                                |
+-----------+------------------------------------------------+

OUTPUT;
        $this->assertSame(str_replace(PHP_EOL, "\n", $output), $commandTester->getDisplay(true));
        // SECOND PASS
        $commandTester->execute(array('command' => $command->getName()));
        $output = <<<OUTPUT
+-----------+------------------------------------------------+
| Created:  |                                                |
+-----------+------------------------------------------------+
| Existing: | Padam87\\AttributeBundle\\Tests\\Model\\Subscriber |
+-----------+------------------------------------------------+

OUTPUT;
        $this->assertSame(str_replace(PHP_EOL, "\n", $output), $commandTester->getDisplay(true));
    }
 /**
  * test saving entity with file property from parent abstract uploadable class
  */
 public function testFileSaveUpload()
 {
     $client = $this->createClient();
     $this->importDatabaseSchema();
     $file = new File();
     $existsFile = new \Symfony\Component\HttpFoundation\File\File(__DIR__ . '/../Fixtures/files/text.txt');
     $file->setTitle('new file')->setDate(new \DateTime('2013-04-04'))->setFile($existsFile);
     $this->getEntityManager()->persist($file);
     $this->getEntityManager()->flush();
     $this->assertSame($file->getFile(), array('fileName' => '/File/file/2013/1.txt', 'originalName' => 'text.txt', 'mimeType' => 'text/plain', 'size' => 9, 'path' => '/file/File/file/2013/1.txt'));
     unset($file);
     $this->getEntityManager()->clear();
     $this->getKernel()->shutdown();
     $client = $this->createClient(array('config' => 'default_newfilepath.yml'));
     $application = new Application($client->getKernel());
     $application->add(new RepairFileDataCommand());
     $command = $application->find('iphp:filestore:repair');
     $commandTester = new CommandTester($command);
     //using web directory setted in config/default.yml
     $commandTester->execute(array('command' => $command->getName(), '--entity' => 'TestXmlConfigBundle:File', '--field' => 'file', '--force' => 1, '--webdir' => realpath($this->getContainer()->getParameter('kernel.test_env_dir') . '/web/')));
     $newFile = $this->getEntityManager()->getRepository('TestXmlConfigBundle:File')->findOneByTitle('new file');
     $this->assertSame($newFile->getFile(), array('fileName' => '/1/new-file.txt', 'originalName' => 'text.txt', 'mimeType' => 'text/plain', 'size' => 9, 'path' => '/other/uploads/1/new-file.txt'));
     unset($newFile);
     unset($commandTester);
     unset($command);
     unset($application);
     $this->getEntityManager()->clear();
     $this->getKernel()->shutdown();
 }
 protected function setCommand()
 {
     $mockedKernel = $this->getMock('Symfony\\Component\\HttpKernel\\Kernel', array(), array(), '', false);
     $application = new Application($mockedKernel);
     $application->add(new WurstCommand());
     $this->command = $application->find('wurst:print');
 }
 /**
  * @return \Symfony\Component\Console\Command\Command
  */
 private function getCommandInstance()
 {
     $kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Kernel')->disableOriginalConstructor()->getMock();
     $app = new Application($kernel);
     $app->add(new GenerateProductCommand());
     return $app->find('sonata:product:generate');
 }
    public function testExecute_noConfigUpdate()
    {
        $repositoryConfig = array('filesystem' => 'dummy_tmp_fs');
        self::$fileRepository->createRepository('dummy_repo2', $repositoryConfig, 'Bla bla');
        $originalStoredFile1 = static::$fileRepository->put('dummy_repo2', new File(__DIR__ . '/../../Fixtures/backend.png'));
        $commandName = 'modera:file-repository:generate-thumbnails';
        $command = $this->application->find('modera:file-repository:generate-thumbnails');
        $commandTester = new CommandTester($command);
        $commandTester->execute(array('command' => $commandName, 'repository' => 'dummy_repo2', '--thumbnail' => ['100x100', '50x50'], '--update-config' => false));
        $output = $commandTester->getDisplay();
        $expectedOutput = <<<'OUTPUT'
 # Processing (14) backend.png
  * 100x100
  * 50x50

OUTPUT;
        $this->assertEquals($expectedOutput, $output);
        /* @var StoredFile[] $alternatives */
        $alternatives = self::$em->getRepository(StoredFile::class)->findBy(array('alternativeOf' => 14));
        $this->assertEquals(2, count($alternatives));
        $this->assertValidAlternative('backend.png', 100, 100, $alternatives[0]);
        $this->assertValidAlternative('backend.png', 50, 50, $alternatives[1]);
        /* @var Repository $repository */
        $repository = self::$em->getRepository(Repository::class)->find($originalStoredFile1->getRepository()->getId());
        $repoConfig = $repository->getConfig();
        $this->assertArrayNotHasKey('interceptors', $repoConfig);
        $this->assertArrayNotHasKey('thumbnail_sizes', $repoConfig);
    }
 /**
  * @test
  * @covers Cocur\Bundle\BuildBundle\Command\CleanCommand::__construct()
  * @covers Cocur\Bundle\BuildBundle\Command\CleanCommand::configure()
  * @covers Cocur\Bundle\BuildBundle\Command\CleanCommand::execute()
  * @covers Cocur\Bundle\BuildBundle\Command\CleanCommand::cleanDirectory()
  */
 public function executeShouldOutputDetailedInformationInVerboseMode()
 {
     $this->buildDir->addChild(vfsStream::newFile('foo1.txt'));
     $this->buildDir->addChild($barDir = vfsStream::newDirectory('bar'));
     $barDir->addChild(vfsStream::newFile('foo2.txt'));
     $this->filesystem->shouldReceive('remove')->with(sprintf('%s/foo1.txt', $this->buildDir->url()))->once();
     $this->filesystem->shouldReceive('remove')->with(sprintf('%s/bar/foo2.txt', $this->buildDir->url()))->once();
     $this->filesystem->shouldReceive('remove')->with(sprintf('%s/bar', $this->buildDir->url()))->once();
     $command = $this->application->find('cocur:clean');
     $commandTester = new CommandTester($command);
     $commandTester->execute(['command' => $command->getName()], ['verbosity' => 2]);
     $this->assertRegExp('/Delete:(.*)foo1\\.txt/', $commandTester->getDisplay());
     $this->assertRegExp('/Delete:(.*)bar/', $commandTester->getDisplay());
     $this->assertRegExp('/Delete:(.*)bar\\/foo2\\.txt/', $commandTester->getDisplay());
     $this->assertRegExp('/Removed 3 files from/', $commandTester->getDisplay());
 }
 public static function setUpBeforeClass()
 {
     @unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Resources/config/routing.rest.yml');
     @unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Controller/CarController.php');
     @unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Controller/OrderController.php');
     $kernel = new \AppKernel('test', true);
     $app = new Application($kernel);
     $app->addCommands(array(new GenerateRestControllerCommand()));
     $kernel->boot();
     $command = $app->find('generate:rest:controller');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), '--controller' => 'TestTestBundle:Order', '--entity' => 'TestTestBundle:Order', '--mongo' => true), array('interactive' => false));
     $kernel->shutdown();
     $kernel = new \AppKernel('test', true);
     $app = new Application($kernel);
     $app->addCommands(array(new GenerateRestControllerCommand()));
     $kernel->boot();
     $command = $app->find('generate:rest:controller');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), '--controller' => 'TestTestBundle:Car', '--entity' => 'TestTestBundle:Car'), array('interactive' => false));
     $kernel->shutdown();
     @unlink(__DIR__ . '/../app/cache/test/appTestUrlGenerator.php.meta');
     @unlink(__DIR__ . '/../app/cache/test/appTestUrlGenerator.php');
     @unlink(__DIR__ . '/../app/cache/test/appTestUrlMatcher.php.meta');
     @unlink(__DIR__ . '/../app/cache/test/appTestUrlMatcher.php');
 }
 /**
  * Set up the testing
  */
 public function setUp()
 {
     $kernel = $this->createKernel();
     $kernel->boot();
     $application = new Application($kernel);
     $application->add(new ExchangeRateUpdateCommand());
     $this->command = $application->find('opithrm:currency-rates:update');
 }
 /**
  * Set up the command tester
  */
 protected function setUp()
 {
     self::bootKernel();
     $application = new Application(self::$kernel);
     $application->add(new GenerateResourceClassesCommand(new DocumentRepository(), new ResourceGenerator()));
     $command = $application->find(GenerateResourceClassesCommand::NAME);
     $this->commandTester = new CommandTester($command);
 }