|
14 | 14 | use Symfony\Component\Console\Application; |
15 | 15 | use Symfony\Component\Console\Output\Output; |
16 | 16 | use Symfony\Component\Console\Tester\ApplicationTester; |
| 17 | +use Symfony\Component\Console\Input\InputArgument; |
| 18 | +use Symfony\Component\Console\Input\InputOption; |
| 19 | +use Symfony\Component\Console\Input\ArrayInput; |
| 20 | +use Symfony\Component\Console\Output\NullOutput; |
17 | 21 |
|
18 | 22 | class ApplicationTest extends \PHPUnit_Framework_TestCase |
19 | 23 | { |
@@ -346,4 +350,33 @@ public function testRun() |
346 | 350 | $tester->run(array('command' => 'foo:bar', '-n' => true), array('decorated' => false)); |
347 | 351 | $this->assertEquals("called\n", $this->normalize($tester->getDisplay()), '->run() does not called interact() if -n is passed'); |
348 | 352 | } |
| 353 | + |
| 354 | + /** |
| 355 | + * @expectedException \LogicException |
| 356 | + * @dataProvider getAddingAlreadySetDefinitionElementData |
| 357 | + */ |
| 358 | + public function testAddingAlreadySetDefinitionElementData($def) |
| 359 | + { |
| 360 | + $application = new Application(); |
| 361 | + $application->setAutoExit(false); |
| 362 | + $application->setCatchExceptions(false); |
| 363 | + $application |
| 364 | + ->register('foo') |
| 365 | + ->setDefinition(array($def)) |
| 366 | + ->setCode(function (InputInterface $input, OutputInterface $output) {}) |
| 367 | + ; |
| 368 | + |
| 369 | + $input = new ArrayInput(array('command' => 'foo')); |
| 370 | + $output = new NullOutput(); |
| 371 | + $application->run($input, $output); |
| 372 | + } |
| 373 | + |
| 374 | + public function getAddingAlreadySetDefinitionElementData() |
| 375 | + { |
| 376 | + return array( |
| 377 | + array(new InputArgument('command', InputArgument::REQUIRED)), |
| 378 | + array(new InputOption('quiet', '', InputOption::VALUE_NONE)), |
| 379 | + array(new InputOption('query', 'q', InputOption::VALUE_NONE)), |
| 380 | + ); |
| 381 | + } |
349 | 382 | } |
0 commit comments