當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CommandTester::execute方法代碼示例

本文整理匯總了PHP中Symfony\Component\Console\Tester\CommandTester::execute方法的典型用法代碼示例。如果您正苦於以下問題:PHP CommandTester::execute方法的具體用法?PHP CommandTester::execute怎麽用?PHP CommandTester::execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Console\Tester\CommandTester的用法示例。


在下文中一共展示了CommandTester::execute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testUserNotFound

 /**
  * @covers \Ilios\CliBundle\Command\AddRootUserCommand::execute
  */
 public function testUserNotFound()
 {
     $userId = 0;
     $this->userManager->shouldReceive('findOneBy')->with(['id' => $userId])->andReturn(null);
     $this->setExpectedException('Exception', "No user with id #{$userId} was found.");
     $this->commandTester->execute(['command' => AddRootUserCommand::COMMAND_NAME, 'userId' => $userId]);
 }
開發者ID:stopfstedt,項目名稱:ilios,代碼行數:10,代碼來源:AddRootUserCommandTest.php

示例2: testInteractiveOutputs

 /**
  * @dataProvider inputInteractiveCommandToOutputFilesProvider
  */
 public function testInteractiveOutputs($inputCommandFilepath, $outputFilepath)
 {
     $code = (require $inputCommandFilepath);
     $this->command->setCode($code);
     $this->tester->execute(array(), array('interactive' => true, 'decorated' => false));
     $this->assertStringEqualsFile($outputFilepath, $this->tester->getDisplay(true));
 }
開發者ID:ayoah,項目名稱:symfony,代碼行數:10,代碼來源:SymfonyStyleTest.php

示例3: testExecute

 public function testExecute()
 {
     $cmd = $this->getCommandInstance();
     $cmdTester = new CommandTester($cmd);
     try {
         $cmdTester->execute(array('command' => $cmd->getName()));
         $this->fail('The command without arguments should throw a \\RuntimeException');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\RuntimeException', $e);
     }
     try {
         $cmdTester->execute(array('command' => $cmd->getName(), 'product' => 'Test'));
         $this->fail('The command without "service_id" argument should throw a \\RuntimeException');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\RuntimeException', $e);
     }
     /*
             try {
                 $cmdTester->execute(array(
                     'command' => $cmd->getName(),
                     'product' => 'Test',
                     'service_id' => 2
                 ));
             } catch (\Exception $e) {
                 $this->fail('No exception should be thrown when all arguments are provided');
             } */
 }
開發者ID:Dicoding,項目名稱:ecommerce,代碼行數:27,代碼來源:GenerateProductCommandTest.php

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

示例5: processJob

 /**
  * Call API and process job immediately, return job info
  * @param string $url URL of API call
  * @param array $params parameters of POST call
  * @param string $method HTTP method of API call
  * @return Job
  */
 protected function processJob($url, $params = [], $method = 'POST')
 {
     $responseJson = $this->callApi($url, $method, $params);
     $this->assertArrayHasKey('id', $responseJson, sprintf("Response of API call '%s' should contain 'id' key.", $url));
     $this->commandTester->execute(['command' => 'syrup:run-job', 'jobId' => $responseJson['id']]);
     return $this->jobMapper->get($responseJson['id']);
 }
開發者ID:ErikZigo,項目名稱:syrup,代碼行數:14,代碼來源:AbstractFunctionalTest.php

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

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

示例8: testDiffWithEnv

 /**
  * @test
  * @group integration
  */
 public function testDiffWithEnv()
 {
     $exit_status = $this->_commandTester->execute(array('command' => $this->_commandName, '--magento-root' => $this->_magentoRoot, '--env' => "prod", 'config-yaml-file' => __DIR__ . "/data/base_prodenv_GBP.yaml"));
     $this->assertNotEmpty($this->_commandTester->getDisplay());
     $this->assertCount(3, explode("\n", trim($this->_commandTester->getDisplay())));
     $this->assertEquals(3, $exit_status);
 }
開發者ID:punkstar,項目名稱:mageconfigsync,代碼行數:11,代碼來源:DiffIntegrationTest.php

示例9: testExecuteNoOptions

 public function testExecuteNoOptions()
 {
     $this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(false));
     $this->tester->execute([]);
     $expected = 'Enabling maintenance mode' . PHP_EOL . 'Not enough information provided to take backup.' . PHP_EOL . 'Disabling maintenance mode' . PHP_EOL;
     $this->assertSame($expected, $this->tester->getDisplay());
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:7,代碼來源:BackupCommandTest.php

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

示例11: execute

    /**
     * @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));
    }
開發者ID:jvahldick,項目名稱:AttributeBundle,代碼行數:33,代碼來源:SyncSchemaCommandTest.php

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

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

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

    public function testContainerAccess()
    {
        $invalidator = \Mockery::mock('\FOS\HttpCacheBundle\CacheManager')
            ->shouldReceive('invalidatePath')->once()->with('/my/path')
            ->shouldReceive('invalidatePath')->once()->with('/other/path')
            ->shouldReceive('invalidatePath')->once()->with('/another')
            ->getMock()
        ;
        $container = \Mockery::mock('\Symfony\Component\DependencyInjection\ContainerInterface')
            ->shouldReceive('get')->once()->with('fos_http_cache.cache_manager')->andReturn($invalidator)
            ->getMock()
        ;

        $application = new Application();
        $command = new InvalidatePathCommand();
        $command->setContainer($container);
        $application->add($command);

        $command = $application->find('fos:httpcache:invalidate:path');
        $commandTester = new CommandTester($command);
        $commandTester->execute(array(
            'command' => $command->getName(),
            'paths' => array('/my/path', '/other/path'),
        ));

        // the only output should be generated by the listener in verbose mode
        $this->assertEquals('', $commandTester->getDisplay());

        // the cache manager is only fetched once
        $commandTester->execute(array(
            'command' => $command->getName(),
            'paths' => array('/another'),
        ));
    }
開發者ID:ataxel,項目名稱:tp,代碼行數:34,代碼來源:BaseInvalidateCommandTest.php


注:本文中的Symfony\Component\Console\Tester\CommandTester::execute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。