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


PHP CommandTester::getInput方法代码示例

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


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

示例1: testAskingForAFreeResponseForAMissingMandatoryOptionsWithoutAvailableValues

 public function testAskingForAFreeResponseForAMissingMandatoryOptionsWithoutAvailableValues()
 {
     $command = new SampleCommand(null);
     $this->application->add($command);
     $this->runtimeInputIs($command, "free response");
     $commandTester = new CommandTester($command);
     $commandTester->execute(['command' => $command->getName()]);
     $this->assertEquals('free response', $commandTester->getInput()->getOption('option'));
 }
开发者ID:silvadanilo,项目名称:lazy-option-command,代码行数:9,代码来源:CommandTest.php

示例2: testPrefix

 /**
  * Test specifying a prefix for different connections.
  */
 public function testPrefix()
 {
     if (Database::getConnection()->driver() == 'sqlite') {
         $this->markTestSkipped('SQLITE modifies the prefixes so we cannot effectively test it');
     }
     Database::addConnectionInfo('magic_db', 'default', Database::getConnectionInfo('default')['default']);
     $command = new DbCommandBaseTester();
     $command_tester = new CommandTester($command);
     $command_tester->execute(['--database' => 'magic_db', '--prefix' => 'extra']);
     $this->assertEquals('extra', $command->getDatabaseConnection($command_tester->getInput())->tablePrefix());
     $connection_info = Database::getConnectionInfo('default')['default'];
     $command_tester->execute(['-db-url' => $connection_info['driver'] . '://' . $connection_info['username'] . ':' . $connection_info['password'] . '@' . $connection_info['host'] . '/' . $connection_info['database'], '--prefix' => 'extra2']);
     $this->assertEquals('extra2', $command->getDatabaseConnection($command_tester->getInput())->tablePrefix());
     // This breaks simpletest cleanup.
     //    $command_tester->execute([
     //      '--prefix' => 'notsimpletest',
     //    ]);
     //    $this->assertEquals('notsimpletest', $command->getDatabaseConnection($command_tester->getInput())->tablePrefix());
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:22,代码来源:DbCommandBaseTest.php

示例3: testTheWrapperTypeCanBeChanged

 public function testTheWrapperTypeCanBeChanged()
 {
     $application = new Application();
     $command = $application->find('compare');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), '--type' => 'directory', 'previous' => __DIR__, 'latest' => __DIR__), ['verbosity' => OutputInterface::VERBOSITY_DEBUG]);
     $argument = $command->getDefinition()->getOption('type');
     $this->assertNotEquals($argument->getDefault(), $commandTester->getInput()->getOption('type'));
     $this->assertNotContains('Unknown wrapper', $commandTester->getDisplay());
     $this->assertContains('Total time', $commandTester->getDisplay());
 }
开发者ID:sourcerer-mike,项目名称:phpsemver,代码行数:11,代码来源:CompareCommandTest.php

示例4: testSuccessIfAdminAlreadyPresentAndUserUsesForce

 public function testSuccessIfAdminAlreadyPresentAndUserUsesForce()
 {
     $options = ['--username' => 'myUsername', '--name' => 'myName', '--email' => 'foo@bar.baz', '--password' => 'superSecret', '--force' => true];
     $expected = ['username' => 'myUsername', 'name' => 'myName', 'email' => 'foo@bar.baz', 'password' => 'superSecret', 'force' => true];
     $installTool = $this->getInstallToolMock(true, true);
     $command = new DatabaseAddAdminCommand($this->getFrameworkMock(), $installTool, 'en');
     $command->setHelperSet($this->getHelperSet());
     $tester = new CommandTester($command);
     $code = $tester->execute($options);
     $this->assertEquals(0, $code);
     $this->assertEquals($expected, $tester->getInput()->getOptions());
     $this->assertContains('Success: Admin user added', $tester->getDisplay());
 }
开发者ID:fuzzyma,项目名称:contao-database-commands-bundle,代码行数:13,代码来源:DatabaseAddAdminCommandTest.php

示例5: testmanageArguments

 public function testmanageArguments()
 {
     $application = $this->getApplication();
     $application->add(new DummyCommand());
     $command = $application->find('eav:attribute:create-dummy-values');
     $dialog = $this->getMock('Symfony\\Component\\Console\\Helper\\QuestionHelper', array('ask'));
     // ASK - attribute-id
     $dialog->expects($this->any())->method('ask')->with($this->isInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Question\\Question'))->will($this->returnValue(92));
     // ASK - values-type
     $dialog->expects($this->any())->method('ask')->with($this->isInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Question\\Question'))->will($this->returnValue('int'));
     // ASK - values-number
     $dialog->expects($this->any())->method('ask')->with($this->isInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Question\\Question'))->will($this->returnValue(1));
     // We override the standard helper with our mock
     $command->getHelperSet()->set($dialog, 'dialog');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName()));
     $arguments = $commandTester->getInput()->getArguments();
     $this->assertArrayHasKey('attribute-id', $arguments);
     $this->assertArrayHasKey('values-type', $arguments);
     $this->assertArrayHasKey('values-number', $arguments);
 }
开发者ID:netz98,项目名称:n98-magerun,代码行数:21,代码来源:DummyCommandTest.php

示例6: testmanageArguments

 public function testmanageArguments()
 {
     $application = $this->getApplication();
     $application->add(new DummyCommand());
     $command = $application->find('category:create:dummy');
     $dialog = $this->getMock('Symfony\\Component\\Console\\Helper\\QuestionHelper', array('ask'));
     // ASK - store-id
     $dialog->expects($this->any())->method('ask')->with($this->isInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Question\\Question'))->will($this->returnValue(1));
     // ASK - children-categories-number
     $dialog->expects($this->any())->method('ask')->with($this->isInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Question\\Question'))->will($this->returnValue(0));
     // ASK - category-name-prefix
     $dialog->expects($this->any())->method('ask')->with($this->isInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Question\\Question'))->will($this->returnValue('My Awesome Category '));
     // ASK - category-number
     $dialog->expects($this->any())->method('ask')->with($this->isInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Question\\Question'))->will($this->returnValue(0));
     // We override the standard helper with our mock
     $command->getHelperSet()->set($dialog, 'dialog');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName()));
     $arguments = $commandTester->getInput()->getArguments();
     $this->assertArrayHasKey('store-id', $arguments);
     $this->assertArrayHasKey('children-categories-number', $arguments);
     $this->assertArrayHasKey('category-name-prefix', $arguments);
     $this->assertArrayHasKey('category-number', $arguments);
 }
开发者ID:netz98,项目名称:n98-magerun,代码行数:24,代码来源:DummyCommandTest.php

示例7: testSetArgumentsAndOptionsCorrectly

 public function testSetArgumentsAndOptionsCorrectly()
 {
     $application = new Application();
     $createApache = new CreateApacheCommand($this->container);
     $application->add($createApache);
     $command = $application->find('apache:create');
     $commandTester = new CommandTester($command);
     $arguments = ['server-name' => 'marvin.dev', 'document-root' => '/home/marvin/app'];
     $options = ['ip' => '192.50.50.40', 'port' => '80', 'server-admin' => 'marvin@webmaster', 'alias' => 'marvin.local', 'log-dir' => '/home/marvin/app/logs'];
     $parameters = $arguments;
     $parameters['command'] = $command->getName();
     $parameters['--ip'] = $options['ip'];
     $parameters['--port'] = $options['port'];
     $parameters['--server-admin'] = $options['server-admin'];
     $parameters['--alias'] = $options['alias'];
     $parameters['--log-dir'] = $options['log-dir'];
     $commandTester->execute($parameters);
     $inpArguments = $commandTester->getInput()->getArguments();
     $inpOptions = $commandTester->getInput()->getOptions();
     // Assert Arguments
     $this->assertEquals($arguments['server-name'], $inpArguments['server-name']);
     $this->assertEquals($arguments['document-root'], $inpArguments['document-root']);
     // Assert Options
     $this->assertEquals($options['ip'], $inpOptions['ip']);
     $this->assertEquals($options['port'], $inpOptions['port']);
     $this->assertEquals($options['server-admin'], $inpOptions['server-admin']);
     $this->assertEquals($options['alias'], $inpOptions['alias']);
     $this->assertEquals($options['log-dir'], $inpOptions['log-dir']);
 }
开发者ID:nocttuam,项目名称:marvin,代码行数:29,代码来源:CreateApacheCommandTest.php


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