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


PHP CommandTester::getDisplay方法代码示例

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


在下文中一共展示了CommandTester::getDisplay方法的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: testExecute

 public function testExecute()
 {
     // Lets create a workflow manager
     $workflowManager = new WorkflowManager();
     // Lets create a mock DI container
     $mockContainer = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')->disableOriginalConstructor()->setMethods(array('get'))->getMock();
     $mockContainer->expects($this->any())->method('get')->with($this->equalTo('tyhand_workflow.manager'))->will($this->returnValue($workflowManager));
     // Lets start the application
     $application = new Application();
     $commandObject = new WorkflowManagerDebugCommand();
     $commandObject->setContainer($mockContainer);
     $application->add($commandObject);
     $command = $application->find('tyhand_workflow:manager:debug');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName()));
     $this->assertRegExp('/.../', $commandTester->getDisplay());
     // Lets add some mock definitions to the workflow manager
     $mockDefinition = $this->getMockBuilder('TyHand\\WorkflowBundle\\Workflow\\AbstractWorkflowDefinition')->setMethods(array('getName', 'getContextClass', 'build'))->getMock();
     $mockDefinition->expects($this->any())->method('getName')->will($this->returnValue('fake'));
     $mockDefinition->expects($this->any())->method('getContextClass')->will($this->returnValue('TyHand\\WorkflowBundle\\Tests\\DummyContext'));
     $mockDefinition->expects($this->any())->method('build')->will($this->returnValue(false));
     $workflowManager->addWorkflowDefinition($mockDefinition);
     $mockDefinition2 = $this->getMockBuilder('TyHand\\WorkflowBundle\\Workflow\\AbstractWorkflowDefinition')->setMethods(array('getName', 'getContextClass', 'build'))->getMock();
     $mockDefinition2->expects($this->any())->method('getName')->will($this->returnValue('abstract'));
     $mockDefinition2->expects($this->any())->method('getContextClass')->will($this->returnValue('TyHand\\WorkflowBundle\\Tests\\DummyContext'));
     $mockDefinition2->expects($this->any())->method('build')->will($this->returnValue(false));
     $workflowManager->addWorkflowDefinition($mockDefinition2);
     // Test the command again
     $commandTester->execute(array('command' => $command->getName()));
     $this->assertRegExp('/fake/', $commandTester->getDisplay());
     $this->assertRegExp('/abstract/', $commandTester->getDisplay());
     $this->assertRegExp('/TyHand\\\\WorkflowBundle\\\\Tests\\\\DummyContext/', $commandTester->getDisplay());
     $this->assertRegExp('/Mock_AbstractWorkflowDefinition/', $commandTester->getDisplay());
 }
开发者ID:tyhand,项目名称:workflow-bundle,代码行数:34,代码来源:WorkflowManagerDebugCommandTest.php

示例3: testCommand

 public function testCommand()
 {
     $this->converter->expects($this->once())->method('convert')->with('Document\\MyClass', array('en'), array(), 'none')->will($this->returnValue(false));
     $this->mockSession->expects($this->once())->method('save');
     $this->commandTester->execute(array('classname' => 'Document\\MyClass', '--locales' => array('en'), '--force' => true));
     $this->assertEquals('.' . PHP_EOL . 'done' . PHP_EOL, $this->commandTester->getDisplay());
 }
开发者ID:doctrine,项目名称:phpcr-odm,代码行数:7,代码来源:DocumentConvertTranslationCommandTest.php

示例4: testExecute

 /**
  * @dataProvider dataProviderTestExecute
  * @param string $moduleName
  * @param int $all
  * @param array $contains
  * @param array $notContains
  */
 public function testExecute($moduleName, $all, array $contains, array $notContains)
 {
     $application = $this->getApplication();
     $application->add(new FromCommand());
     $command = $this->getApplication()->find('dev:module:dependencies:from');
     $commandTester = new CommandTester($command);
     $input = array('command' => $command->getName(), 'moduleName' => $moduleName);
     switch ($all) {
         case 2:
             $input['-a'] = true;
             break;
         case 1:
             $input['--all'] = true;
             break;
         default:
             break;
     }
     $commandTester->execute($input);
     foreach ($contains as $expectation) {
         $this->assertContains($expectation, $commandTester->getDisplay());
     }
     foreach ($notContains as $expectation) {
         $this->assertNotContains($expectation, $commandTester->getDisplay());
     }
 }
开发者ID:netz98,项目名称:n98-magerun,代码行数:32,代码来源:FromCommandTest.php

示例5: testWillShowQuery

 public function testWillShowQuery()
 {
     $this->_em->persist(new DateTimeModel());
     $this->_em->flush();
     $this->assertSame(0, $this->tester->execute(array('command' => $this->command->getName(), 'dql' => 'SELECT e FROM ' . DateTimeModel::CLASSNAME . ' e', '--show-sql' => 'true')));
     $this->assertStringMatchesFormat('string%sSELECT %a', $this->tester->getDisplay());
 }
开发者ID:selimcr,项目名称:servigases,代码行数:7,代码来源:RunDqlCommandTest.php

示例6: testMultipleSitemapsExecute

 public function testMultipleSitemapsExecute()
 {
     $templating = m::mock('Symfony\\Component\\Templating\\EngineInterface');
     $templating->shouldReceive('render')->times(3);
     $router = m::mock('Symfony\\Component\\Routing\\RouterInterface');
     $router->shouldReceive('getContext')->once()->andReturn(new RequestContext());
     $manager = new SitemapManager(array(), 5, $templating);
     $manager->addGenerator(new TestGenerator(10));
     $application = new Application();
     $application->add(new DumpCommand($manager, $router, sys_get_temp_dir()));
     $command = $application->find('dpn:xml-sitemap:dump');
     $commandTester = new CommandTester($command);
     $this->assertFileNotExists($this->getSitemapIndexFile());
     $this->assertFileNotExists($this->getSitemapFile());
     $this->assertFileNotExists($this->getSitemap1File());
     $this->assertFileNotExists($this->getSitemap2File());
     $commandTester->execute(array('command' => $command->getName(), 'host' => 'http://localhost', '--target' => sys_get_temp_dir()));
     $this->assertFileExists($this->getSitemapIndexFile());
     $this->assertFileNotExists($this->getSitemapFile());
     $this->assertFileExists($this->getSitemap1File());
     $this->assertFileExists($this->getSitemap2File());
     $this->assertContains(sprintf('[file+] %s', $this->getSitemapIndexFile()), $commandTester->getDisplay());
     $this->assertContains(sprintf('[file+] %s', $this->getSitemap1File()), $commandTester->getDisplay());
     $this->assertContains(sprintf('[file+] %s', $this->getSitemap2File()), $commandTester->getDisplay());
 }
开发者ID:bitundpixel,项目名称:DpnXmlSitemapBundle,代码行数:25,代码来源:DumpCommandTest.php

示例7: runCommand

 /**
  * Runs the command and returns it's output.
  *
  * @param array $input   Command input.
  * @param array $options Command tester options.
  *
  * @return string
  */
 protected function runCommand(array $input = array(), array $options = array())
 {
     $input['command'] = $this->command->getName();
     $options['interactive'] = true;
     $this->commandTester->execute($input, $options);
     return $this->commandTester->getDisplay();
 }
开发者ID:console-helpers,项目名称:svn-buddy,代码行数:15,代码来源:AbstractCommandTestCase.php

示例8: testExecute

    /**
     * @covers ::execute
     */
    public function testExecute()
    {
        $client = new ClientMock();
        $client->queueResponse('packagist/list.json')->queueResponse('packagist/list.json')->queueResponse('packagist/list.empty.json');
        $command = new SearchCommand($client);
        $console = new Application();
        $console->add($command);
        $tester = new CommandTester($console->get('search'));
        $tester->execute([]);
        $expected = <<<RESPONSE
Available Init Templates:
  clippings/package-template
  harp-orm/harp-template
  openbuildings/jam-template

RESPONSE;
        $this->assertEquals($expected, $tester->getDisplay());
        $tester->execute(['filter' => 'clip']);
        $expected = <<<RESPONSE
Available Init Templates:
  clippings/package-template

RESPONSE;
        $this->assertEquals($expected, $tester->getDisplay());
        $expected = <<<RESPONSE
No templates found

RESPONSE;
        $tester->execute([]);
        $this->assertEquals($expected, $tester->getDisplay());
    }
开发者ID:clippings,项目名称:composer-init,代码行数:34,代码来源:SearchCommandTest.php

示例9: testShowSpecificFuzzySingle

 public function testShowSpecificFuzzySingle()
 {
     $this->tester->execute(array('command' => $this->command->getName(), 'entityName' => 'AttractionInfo'));
     $display = $this->tester->getDisplay();
     $this->assertContains('Doctrine\\Tests\\Models\\Cache\\AttractionInfo', $display);
     $this->assertContains('Root entity name', $display);
 }
开发者ID:selimcr,项目名称:servigases,代码行数:7,代码来源:MappingDescribeCommandTest.php

示例10: exceptionWhileParsingLongUrlOutputsError

 /**
  * @test
  */
 public function exceptionWhileParsingLongUrlOutputsError()
 {
     $this->urlShortener->urlToShortCode(Argument::cetera())->willThrow(new InvalidUrlException())->shouldBeCalledTimes(1);
     $this->commandTester->execute(['command' => 'shortcode:generate', 'longUrl' => 'http://domain.com/invalid']);
     $output = $this->commandTester->getDisplay();
     $this->assertTrue(strpos($output, 'Provided URL "http://domain.com/invalid" is invalid. Try with a different one.') === 0);
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:10,代码来源:GenerateShortcodeCommandTest.php

示例11: testListUsersNoResults

 /**
  * @covers \Ilios\CliBundle\Command\ListRootUsersCommand::execute
  */
 public function testListUsersNoResults()
 {
     $this->userManager->shouldReceive('findDTOsBy')->with(['root' => true])->andReturn([]);
     $this->commandTester->execute(['command' => ListRootUsersCommand::COMMAND_NAME]);
     $output = $this->commandTester->getDisplay();
     $this->assertEquals('No users with root-level privileges found.', trim($output));
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:10,代码来源:ListRootUsersCommandTest.php

示例12: testNonInteractiveCommand

 public function testNonInteractiveCommand()
 {
     $command = $this->console->find('new');
     $tester = new CommandTester($command);
     $tester->execute(array('command' => $command->getName(), 'title' => 'The Origin of Species', '--dir' => $this->tmpDir));
     $this->assertRegExp('/.* OK .* You can start writing your book in the following directory/', $tester->getDisplay(), 'The book skeleton has been generated');
     $this->assertRegExp('/.*\\/the-origin-of-species/', $tester->getDisplay(), 'The name of the new book directory is correct');
     $bookDir = $this->tmpDir . '/the-origin-of-species';
     $files = array('config.yml', 'Contents/chapter1.md', 'Contents/chapter2.md', 'Contents/images', 'Output');
     foreach ($files as $file) {
         $this->assertFileExists($bookDir . '/' . $file, sprintf('%s has been generated', $file));
     }
     $bookConfig = Yaml::parse($bookDir . '/config.yml');
     // --- test basic config ----------------------------------------------
     $this->assertEquals($bookConfig['book']['title'], 'The Origin of Species', 'The title of the new book is "The Origin of Species"');
     $this->assertEquals($bookConfig['book']['author'], 'Change this: Author Name', 'The author of the new book is unset');
     $this->assertEquals($bookConfig['book']['language'], 'en', 'The language of the new book is English');
     $this->assertEquals($bookConfig['book']['publication_date'], null, 'The publication date of the new book is unset');
     // --- test contents config -------------------------------------------
     $contents = array(array('element' => 'cover'), array('element' => 'toc'), array('element' => 'chapter', 'number' => 1, 'content' => 'chapter1.md'), array('element' => 'chapter', 'number' => 2, 'content' => 'chapter2.md'));
     $this->assertEquals($bookConfig['book']['contents'], $contents, 'The default contents of the new book are correct');
     // --- test editions config -------------------------------------------
     $this->assertEquals(count($bookConfig['book']['editions']), 5, 'The new book has 5 editions configured');
     $this->assertArrayHasKey('ebook', $bookConfig['book']['editions'], 'The new book has an "ebook" (.epub) edition');
     $this->assertArrayHasKey('kindle', $bookConfig['book']['editions'], 'The new book has a "kindle" (.mobi) edition');
     $this->assertArrayHasKey('print', $bookConfig['book']['editions'], 'The new book has a "print" (.pdf) edition');
     $this->assertArrayHasKey('web', $bookConfig['book']['editions'], 'The new book has a "web" (.html) edition');
     $this->assertArrayHasKey('website', $bookConfig['book']['editions'], 'The new book has a "website"(.html) edition');
     // --- test second book generation ------------------------------------
     $tester->execute(array('command' => $command->getName(), 'title' => 'The Origin of Species', '--dir' => $this->tmpDir));
     $tester->execute(array('command' => $command->getName(), 'title' => 'The Origin of Species', '--dir' => $this->tmpDir));
     $this->assertRegExp('/.* OK .* You can start writing your book in the following directory/', $tester->getDisplay(), 'The second book skeleton has been generated');
     $this->assertRegExp('/.*\\/the-origin-of-species-\\d{1}\\s+/', $tester->getDisplay(), 'The name of the second book directory is correct');
 }
开发者ID:oiat,项目名称:e-book-creator,代码行数:34,代码来源:BookNewCommandTest.php

示例13: testItemCountDoesntMatter

 public function testItemCountDoesntMatter()
 {
     $returnCode = $this->runCommand('file2.yml', 'file3.yml');
     $output = $this->tester->getDisplay();
     $this->assertEmpty($output, 'There is no output');
     $this->assertEquals(0, $returnCode, 'Success exit code');
 }
开发者ID:mattketmo,项目名称:yamldiff,代码行数:7,代码来源:YamlDiffCommandTest.php

示例14: 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

示例15: seeOutput

 /**
  * Asserts that the output contains the give regex
  *
  * @param $regex
  */
 public function seeOutput($regex)
 {
     if (empty($this->commandTester)) {
         throw new \RuntimeException('You need to call runTheCommand() before checking the output');
     }
     $this->assertRegExp('/' . preg_quote($regex, '/') . '/', $this->commandTester->getDisplay());
 }
开发者ID:cubicmushroom,项目名称:project-toolbelt,代码行数:12,代码来源:ConsoleCommand.php


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