* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Tests\Command; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Form\Command\DebugCommand; use Symfony\Component\Form\FormRegistry; use Symfony\Component\Form\ResolvedFormTypeFactory; class DebugCommandTest extends TestCase { public function testDebugDefaults() { $tester = $this->createCommandTester(); $ret = $tester->execute(array(), array('decorated' => false)); $this->assertEquals(0, $ret, 'Returns 0 in case of success'); $this->assertContains('Built-in form types', $tester->getDisplay()); } public function testDebugSingleFormType() { $tester = $this->createCommandTester(); $ret = $tester->execute(array('class' => 'FormType'), array('decorated' => false)); $this->assertEquals(0, $ret, 'Returns 0 in case of success'); $this->assertContains('Symfony\Component\Form\Extension\Core\Type\FormType (Block prefix: "form")', $tester->getDisplay()); } public function testDebugFormTypeOption() { $tester = $this->createCommandTester(); $ret = $tester->execute(array('class' => 'FormType', 'option' => 'method'), array('decorated' => false)); $this->assertEquals(0, $ret, 'Returns 0 in case of success'); $this->assertContains('Symfony\Component\Form\Extension\Core\Type\FormType (method)', $tester->getDisplay()); } /** * @expectedException \Symfony\Component\Console\Exception\InvalidArgumentException * @expectedExceptionMessage Could not find type "NonExistentType" */ public function testDebugSingleFormTypeNotFound() { $tester = $this->createCommandTester(); $tester->execute(array('class' => 'NonExistentType'), array('decorated' => false, 'interactive' => false)); } public function testDebugAmbiguousFormType() { $expectedMessage = <<expectException(InvalidArgumentException::class); $this->expectExceptionMessage($expectedMessage); } else { $this->setExpectedException(InvalidArgumentException::class, $expectedMessage); } $tester = $this->createCommandTester(array( 'Symfony\Component\Form\Tests\Fixtures\Debug\A', 'Symfony\Component\Form\Tests\Fixtures\Debug\B', )); $tester->execute(array('class' => 'AmbiguousType'), array('decorated' => false, 'interactive' => false)); } public function testDebugAmbiguousFormTypeInteractive() { $tester = $this->createCommandTester(array( 'Symfony\Component\Form\Tests\Fixtures\Debug\A', 'Symfony\Component\Form\Tests\Fixtures\Debug\B', )); $tester->setInputs(array(0)); $tester->execute(array('class' => 'AmbiguousType'), array('decorated' => false, 'interactive' => true)); $this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success'); $output = $tester->getDisplay(true); $this->assertStringMatchesFormat(<<createCommandTester()->execute(array('class' => 'test')); } private function createCommandTester(array $namespaces = null) { $formRegistry = new FormRegistry(array(), new ResolvedFormTypeFactory()); $command = null === $namespaces ? new DebugCommand($formRegistry) : new DebugCommand($formRegistry, $namespaces); $application = new Application(); $application->add($command); return new CommandTester($application->find('debug:form')); } } __halt_compiler();----SIGNATURE:----MLhzciifOLwzGHS1BeuVk7GMz8ThxNcv9TpsU1HMSZzwsIS7nWgiBaMfrD1P0RNB+1vlTTAiKY45dYLdC0yU05WWCgtyR2t3l8duIR9kIkM2YQUr88DQt5BF9yeFySixxWe1IV58lJWgRdRijhTUazrNXcdwSplbUsrVKmaCIk8e+OrJE/SFxrqBI2BAlX9MQ1HKnA6HXiiC7gqyY+gCDYKd5PWoMZkFhf0/2tLJEjlqQJmNQYn0IBpUFkS5ths1vvyP9nict6fLE5koRp4kmm6tRl1ARLzdxsvt0H7q7zjMX74e0xoaynNwpLcppxSiwSXAYgdusOO4jNKGhtgsI7JcyTZfGtVB3fJxn9oSwMeW/duODlvgScZ5RDyQZASR2RIY9fQJA2DDHVhy9f/GCxkQEwnuJ5bYqcCYTqDuJ+ndmfX4yJDuEArC4pcdE8z9Wtbyqa+K0kVFfpHyctspvn1fvHftjGYzP13H08H20kV4yTzqkqourlI6RHNBxI1x+p/+UZMTshWM8ANHUghv8RK4eDXp9+ZFp1teUUx/xdJMarwQacihj0GG8/tI4D+wqgrV8t/X/ICejkyd3v0BpP2qsFRVKQjq6K8Dor/0JdtN25yd8hFGBFWFmk6EqLWA3WRwBQqbDpoy4vrc7RVYMeo0CoShWOhLpo25JdfPCTI=----ATTACHMENT:----Mzg1Mjc4ODU5NDg5Mzc1IDY5OTI5NDk2NjY3MjQxMDQgMjczODIxNDU3NzI1NTI2