本文整理匯總了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'));
}
示例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());
}
示例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());
}
示例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());
}
示例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);
}
示例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);
}
示例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']);
}