当前位置: 首页>>代码示例>>PHP>>正文


PHP Tester\CommandTester类代码示例

本文整理汇总了PHP中Symfony\Component\Console\Tester\CommandTester的典型用法代码示例。如果您正苦于以下问题:PHP CommandTester类的具体用法?PHP CommandTester怎么用?PHP CommandTester使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CommandTester类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testShouldReturnErrorIfThereIsFilesWithWrongStyle

 public function testShouldReturnErrorIfThereIsFilesWithWrongStyle()
 {
     $kernel = $this->getMock(\stdClass::class);
     /* @var \Behat\Gherkin\Parser|\PHPUnit_Framework_MockObject_MockObject $parser */
     $parser = $this->getMockBuilder(Parser::class)->disableOriginalConstructor()->getMock();
     /* @var \Behat\Gherkin\Node\FeatureNode|\PHPUnit_Framework_MockObject_MockObject $feature */
     $feature = $this->getMockBuilder(FeatureNode::class)->disableOriginalConstructor()->getMock();
     $feature->expects(self::once())->method('hasTags')->willReturn(true);
     $feature->expects(self::once())->method('getKeyword')->willReturn('Feature');
     $feature->expects(self::once())->method('getTags')->willReturn(['users', 'another-feature', 'another-tag']);
     $feature->expects(self::once())->method('getTitle')->willReturn('User registration');
     $feature->expects(self::once())->method('hasDescription')->willReturn(true);
     $feature->expects(self::once())->method('getDescription')->willReturn("In order to order products\n" . "As a visitor\n" . "I need to be able to create an account in the store");
     $feature->expects(self::once())->method('hasBackground')->willReturn(true);
     $feature->expects(self::once())->method('getBackground')->willReturn($this->getBackground());
     $feature->expects(self::once())->method('hasScenarios')->willReturn(false);
     $parser->expects(self::once())->method('parse')->willReturn($feature);
     $application = new Application($kernel);
     $application->add(new CheckGherkinCodeStyle(null, $parser));
     $command = $application->find('gherkin:check');
     $commandTester = new CommandTester($command);
     $commandTester->execute(['directory' => __DIR__ . '/../assets/left-aligned.feature']);
     self::assertRegExp('/Wrong style/', $commandTester->getDisplay());
     self::assertNotRegExp('/I need to be able to create an account in the store/', $commandTester->getDisplay());
 }
开发者ID:malukenho,项目名称:kawaii-gherkin,代码行数:25,代码来源:CheckGherkinCodeStyleTest.php

示例2: shouldExecuteConsumeCommand

 /**
  * @test
  */
 public function shouldExecuteConsumeCommand()
 {
     $application = new Application('prod');
     // Add command
     $command = new TestableConsumerCommand('fake:consumer', $this->getMockForAbstractClass('Boot\\RabbitMQ\\Consumer\\AbstractConsumer', [$this->queueTemplate], 'MockConsumer'), $this->createLogger());
     $application->add($command);
     // Create command tester
     $commandTester = new CommandTester($command);
     // Execute consumer
     $commandTester->execute(['command' => $command->getName()]);
     // Should have declared the queue once
     $this->assertEquals(1, $this->basicQueueDeclareInvocations->getInvocationCount());
     $args = $this->basicQueueDeclareInvocations->getInvocations()[0]->parameters;
     // Make sure that the queue name is correct
     $this->assertEquals('some_test_queue', $args[0]);
     // Make sure that the queue is durable
     $this->assertTrue($args[2], 'The queue is not durable!');
     // Make sure that the queue is not automatically deleted
     $this->assertFalse($args[4], 'The queue is automatically deleted!');
     // Should have declared the quality of service once
     $this->assertEquals(1, $this->basicQosInvocations->getInvocationCount());
     // Should have declared the quality of service once
     $this->assertEquals(1, $this->basicConsumeInvocations->getInvocationCount());
     // The wait method should have been invoked once
     $this->assertEquals(1, $this->waitInvocations->getInvocationCount());
     // Should have status code 0
     $this->assertEquals(0, $commandTester->getStatusCode());
 }
开发者ID:leadtech,项目名称:boot-rabbit-mq,代码行数:31,代码来源:FaultTolerantBehaviourConsumerTest.php

示例3: testExecute

 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());
 }
开发者ID:TransformCore,项目名称:HayPersistenceApi,代码行数:7,代码来源:FileUploadCommandTest.php

示例4: testExecution

 /**
  * @dataProvider getFormat
  * @runInSeparateProcess
  */
 public function testExecution($format)
 {
     $tmpDir = sys_get_temp_dir() . '/sf_hello';
     $filesystem = new Filesystem();
     $filesystem->remove($tmpDir);
     $filesystem->mkdirs($tmpDir);
     chdir($tmpDir);
     $tester = new CommandTester(new InitCommand());
     $tester->execute(array('--name' => 'Hello' . $format, '--app-path' => 'hello' . $format, '--web-path' => 'web', '--src-path' => 'src', '--format' => $format));
     // autoload
     $content = file_get_contents($file = $tmpDir . '/src/autoload.php');
     $content = str_replace("__DIR__.'/vendor", "'" . __DIR__ . "/../../../../src/vendor", $content);
     file_put_contents($file, $content);
     // Kernel
     $class = 'Hello' . $format . 'Kernel';
     $file = $tmpDir . '/hello' . $format . '/' . $class . '.php';
     $this->assertTrue(file_exists($file));
     $content = file_get_contents($file);
     $content = str_replace("__DIR__.'/../src/vendor/Symfony/src/Symfony/Bundle'", "'" . __DIR__ . "/../../../../src/vendor/Symfony/src/Symfony/Bundle'", $content);
     file_put_contents($file, $content);
     require_once $file;
     $kernel = new $class('dev', true);
     $response = $kernel->handle(Request::create('/'));
     $this->assertRegExp('/successfully/', $response->getContent());
     $filesystem->remove($tmpDir);
 }
开发者ID:kawahara,项目名称:symfony-bootstrapper,代码行数:30,代码来源:InitCommandTest.php

示例5: testExecute

 public function testExecute()
 {
     $application = $this->getApplication();
     $application->add(new ListCommand());
     $command = $this->getApplication()->find('dev:module:create');
     $root = getcwd();
     // delete old module
     if (is_dir($root . '/N98Magerun_UnitTest')) {
         $filesystem = new Filesystem();
         $filesystem->recursiveRemoveDirectory($root . '/N98Magerun_UnitTest');
         clearstatcache();
     }
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), '--add-all' => true, '--add-setup' => true, '--add-readme' => true, '--add-composer' => true, '--modman' => true, '--description' => 'Unit Test Description', '--author-name' => 'Unit Test', '--author-email' => 'n98-magerun@example.com', 'vendorNamespace' => 'N98Magerun', 'moduleName' => 'UnitTest'));
     $this->assertFileExists($root . '/N98Magerun_UnitTest/composer.json');
     $this->assertFileExists($root . '/N98Magerun_UnitTest/readme.md');
     $moduleBaseFolder = $root . '/N98Magerun_UnitTest/src/app/code/local/N98Magerun/UnitTest/';
     $this->assertFileExists($moduleBaseFolder . 'etc/config.xml');
     $this->assertFileExists($moduleBaseFolder . 'Block');
     $this->assertFileExists($moduleBaseFolder . 'Model');
     $this->assertFileExists($moduleBaseFolder . 'Helper');
     $this->assertFileExists($moduleBaseFolder . 'data/n98magerun_unittest_setup');
     $this->assertFileExists($moduleBaseFolder . 'sql/n98magerun_unittest_setup');
     // delete old module
     if (is_dir($root . '/N98Magerun_UnitTest')) {
         $filesystem = new Filesystem();
         $filesystem->recursiveRemoveDirectory($root . '/N98Magerun_UnitTest');
         clearstatcache();
     }
 }
开发者ID:lslab,项目名称:n98-magerun,代码行数:30,代码来源:CreateCommandTest.php

示例6: getCommandTester

 /**
  * @param string $commandName
  * @param array $options
  * @return CommandTester
  */
 protected function getCommandTester($commandName, array $options = [])
 {
     $command = $this->getApplication()->find($commandName);
     $commandTester = new CommandTester($command);
     $commandTester->execute(['command' => $commandName], $options);
     return $commandTester;
 }
开发者ID:hrphp,项目名称:hrphp-cli,代码行数:12,代码来源:PingCommandTest.php

示例7: iShouldGetTheFollowingProductsAfterApplyTheFollowingUpdaterToIt

 /**
  * @Then /^I should get the following products after apply the following updater to it:$/
  *
  * @param TableNode $updates
  *
  * @throws \Exception
  */
 public function iShouldGetTheFollowingProductsAfterApplyTheFollowingUpdaterToIt(TableNode $updates)
 {
     $application = $this->getApplicationsForUpdaterProduct();
     $updateCommand = $application->find('pim:product:update');
     $updateCommand->setContainer($this->getMainContext()->getContainer());
     $updateCommandTester = new CommandTester($updateCommand);
     $getCommand = $application->find('pim:product:get');
     $getCommand->setContainer($this->getMainContext()->getContainer());
     $getCommandTester = new CommandTester($getCommand);
     foreach ($updates->getHash() as $update) {
         $username = isset($update['username']) ? $update['username'] : null;
         $updateCommandTester->execute(['command' => $updateCommand->getName(), 'identifier' => $update['product'], 'json_updates' => $update['actions'], 'username' => $username]);
         $expected = json_decode($update['result'], true);
         if (isset($expected['product'])) {
             $getCommandTester->execute(['command' => $getCommand->getName(), 'identifier' => $expected['product']]);
             unset($expected['product']);
         } else {
             $getCommandTester->execute(['command' => $getCommand->getName(), 'identifier' => $update['product']]);
         }
         $actual = json_decode($getCommandTester->getDisplay(), true);
         if (null === $actual) {
             throw new \Exception(sprintf('An error occured during the execution of the update command : %s', $getCommandTester->getDisplay()));
         }
         if (null === $expected) {
             throw new \Exception(sprintf('Looks like the expected result is not valid json : %s', $update['result']));
         }
         $diff = $this->arrayIntersect($actual, $expected);
         assertEquals($expected, $diff);
     }
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:37,代码来源:CommandContext.php

示例8: testExecute

 public function testExecute()
 {
     $expected = '/^Hashing pid data/';
     $commandTester = new CommandTester($this->instance->find('haytool:pid-obfuscation'));
     $commandTester->execute(array());
     $this->assertRegExp($expected, $commandTester->getDisplay());
 }
开发者ID:TransformCore,项目名称:HayPersistenceApi,代码行数:7,代码来源:PIDDataObfuscationCommandTest.php

示例9: runCommand

 /**
  * Runa a command in and returns the commandTester object. This method can
  * run either a blend command or a sub-application command
  * @param string $projectFolder
  * @param string $commandName
  * @param string $params
  * @param string $app In case of null it will be set to blend. In case of
  * className as string, the application's class name will be used
  * @return CommandTester
  */
 public static function runCommand($projectFolder, $commandName, array $params = [], $app = null, $runOptions = [])
 {
     $loader = new ClassLoader();
     $curDir = getcwd();
     chdir($projectFolder);
     if ($app === null) {
         $app = new SetupApplication($projectFolder);
     } else {
         if (is_string($app)) {
             $classes = explode('\\', $app);
             $loader->addPsr4("{$classes[0]}\\", $projectFolder . '/src/');
             $loader->register(true);
             $c = new Container();
             $c->defineSingletonWithInterface('app', $app, ['scriptPath' => $projectFolder . '/bin']);
             $app = $c->get('app');
         }
     }
     $commandTester = new CommandTester($app->find($commandName));
     $commandTester->execute($params, $runOptions);
     chdir($curDir);
     $c = null;
     if ($loader) {
         $loader->unregister();
     }
     return $commandTester;
 }
开发者ID:blendsdk,项目名称:blendengine,代码行数:36,代码来源:ProjectUtil.php

示例10: testExecute

 public function testExecute()
 {
     $this->moduleList->expects($this->once())->method('getNames')->willReturn([]);
     $commandTester = new CommandTester($this->command);
     $commandTester->execute([]);
     $this->assertContains('List of active modules', $commandTester->getDisplay());
 }
开发者ID:jeremyBass,项目名称:wsumage_command,代码行数:7,代码来源:CheckActiveModulesCommandTest.php

示例11: test_options

 /**
  * Test setting the flag option on the test command..
  *
  * @return void
  * @author Dan Cox
  */
 public function test_options()
 {
     $command = $this->DI->get('console')->find('test:command');
     $CT = new CommandTester($command);
     $CT->execute(['command' => $command->getName(), 'test' => 'foo', '--flag' => true]);
     $this->assertContains('flag set', $CT->getDisplay());
 }
开发者ID:antoligy,项目名称:Framework,代码行数:13,代码来源:CommandTest.php

示例12: testSites

 /**
  * @dataProvider provideSites
  * @param string $root Root directory of site
  * @param string|null $config Path to configuration file
  */
 public function testSites($root, $config = null)
 {
     $application = new Application();
     $application->add(new BuildCommand());
     /** @var \CastlePointAnime\Brancher\Command\BuildCommand $command */
     $command = $application->find('build');
     $commandTester = new CommandTester($command);
     $outputDir = self::$outputDir;
     $commandTester->execute(array_filter(['--config' => $config, '--exclude' => '_site', 'root' => $root, 'output' => $outputDir]));
     // Test to make sure existing files match
     $finder = new Finder();
     $finder->files()->in("{$root}/_site");
     /** @var \Symfony\Component\Finder\SplFileInfo $fileInfo */
     foreach ($finder as $fileInfo) {
         $this->assertFileEquals($fileInfo->getPathname(), "{$outputDir}/{$fileInfo->getRelativePathname()}", $fileInfo->getPathname());
     }
     // Test to make sure excluded files do not exist
     $excludeDirs = $command->getContainer()->getParameter('castlepointanime.brancher.build.excludes');
     if (count($excludeDirs)) {
         $finder = new Finder();
         $finder->files()->in($root)->exclude('_site')->exclude('_templates');
         array_map([$finder, 'path'], $excludeDirs);
         /** @var \Symfony\Component\Finder\SplFileInfo $fileInfo */
         foreach ($finder as $fileInfo) {
             $this->assertFileNotExists("{$outputDir}/{$fileInfo->getRelativePathname()}");
         }
     }
 }
开发者ID:castlepointanime,项目名称:brancher,代码行数:33,代码来源:BuildCommandTest.php

示例13: getCommandTester

 /**
  * @param string $commandName
  * @return CommandTester
  */
 protected function getCommandTester($commandName)
 {
     $command = $this->getApplication()->find($commandName);
     $commandTester = new CommandTester($command);
     $commandTester->execute(array_merge(array('command' => $commandName)));
     return $commandTester;
 }
开发者ID:billjordan,项目名称:hrphp-cli,代码行数:11,代码来源:PingCommandTest.php

示例14: testExecute

 public function testExecute()
 {
     $application = $this->getApplication();
     $application->add(new DumpCommand());
     $setCommand = $this->getApplication()->find('config:set');
     $deleteCommand = $this->getApplication()->find('config:delete');
     /**
      * Add a new entry
      */
     $commandTester = new CommandTester($setCommand);
     $commandTester->execute(array('command' => $setCommand->getName(), 'path' => 'imi_conrun/foo/bar', 'value' => '1234'));
     $this->assertContains('imi_conrun/foo/bar => 1234', $commandTester->getDisplay());
     $commandTester = new CommandTester($deleteCommand);
     $commandTester->execute(array('command' => $deleteCommand->getName(), 'path' => 'imi_conrun/foo/bar'));
     $this->assertContains('| imi_conrun/foo/bar | default | 0  |', $commandTester->getDisplay());
     /**
      * Delete all
      */
     foreach (\Mage::app()->getStores() as $store) {
         // add multiple entries
         $commandTester = new CommandTester($setCommand);
         $commandTester->execute(array('command' => $setCommand->getName(), 'path' => 'imi_conrun/foo/bar', '--scope' => 'stores', '--scope-id' => $store->getId(), 'value' => 'store-' . $store->getId()));
     }
     $commandTester = new CommandTester($deleteCommand);
     $commandTester->execute(array('command' => $deleteCommand->getName(), 'path' => 'imi_conrun/foo/bar', '--all' => true));
     foreach (\Mage::app()->getStores() as $store) {
         $this->assertContains('| imi_conrun/foo/bar | stores   | ' . $store->getId() . '  |', $commandTester->getDisplay());
     }
 }
开发者ID:iMi-digital,项目名称:imi-conrun,代码行数:29,代码来源:DeleteCommandTest.php

示例15: testExecute

 public function testExecute()
 {
     /**
      * Check autoloading
      */
     /* @var $application Application */
     $application = (require __DIR__ . '/../../../src/bootstrap.php');
     $application->setMagentoRootFolder($this->getTestMagentoRoot());
     $this->assertInstanceOf('\\N98\\Magento\\Application', $application);
     $loader = $application->getAutoloader();
     $this->assertInstanceOf('\\Composer\\Autoload\\ClassLoader', $loader);
     /**
      * Check version
      */
     $this->assertEquals(Application::APP_VERSION, trim(file_get_contents(__DIR__ . '/../../../version.txt')));
     /* @var $loader \Composer\Autoload\ClassLoader */
     $prefixes = $loader->getPrefixes();
     $this->assertArrayHasKey('N98', $prefixes);
     $distConfigArray = Yaml::parse(file_get_contents(__DIR__ . '/../../../config.yaml'));
     $configArray = array('autoloaders' => array('N98MagerunTest' => __DIR__ . '/_ApplicationTestSrc'), 'commands' => array('customCommands' => array(0 => 'N98MagerunTest\\TestDummyCommand'), 'aliases' => array(array('ssl' => 'sys:store:list'))), 'init' => array('options' => array('config_model' => 'N98MagerunTest\\AlternativeConfigModel')));
     $application->setAutoExit(false);
     $application->init(ArrayFunctions::mergeArrays($distConfigArray, $configArray));
     $application->run(new StringInput('list'), new NullOutput());
     // Check if autoloaders, commands and aliases are registered
     $prefixes = $loader->getPrefixes();
     $this->assertArrayHasKey('N98MagerunTest', $prefixes);
     $testDummyCommand = $application->find('n98mageruntest:test:dummy');
     $this->assertInstanceOf('\\N98MagerunTest\\TestDummyCommand', $testDummyCommand);
     $commandTester = new CommandTester($testDummyCommand);
     $commandTester->execute(array('command' => $testDummyCommand->getName()));
     $this->assertContains('dummy', $commandTester->getDisplay());
     $this->assertTrue($application->getDefinition()->hasOption('root-dir'));
     // check alias
     $this->assertInstanceOf('\\N98\\Magento\\Command\\System\\Store\\ListCommand', $application->find('ssl'));
 }
开发者ID:brentwpeterson,项目名称:n98-magerun2,代码行数:35,代码来源:ApplicationTest.php


注:本文中的Symfony\Component\Console\Tester\CommandTester类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。