* * 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:----rE9Obe6Ymakp+thY8psDMG8uM6OJEFsMkIaz/7le3OE5QhF/9kKeVI2yNHX5uEAcetkHSN4KTrJnHVnYfQR3hmCu0DCl4hJW2nlkKjLxR8ej33xRevmubPdS3uO7LPEnPxDwEzTmDAVtlhHkX0osN1uwDrICuBZQ8xKiIjwsEu2sNQeAKqShfOz9gHiv1aHVCdl+D61uAGHnXR57agzTydIYd3+JswVIYwY2esd4NbtbuiAb/edwA1AlCvU73Liw0rLlGkgJb/bjPN9TSuA11UV3r95cVU6ntPN4rIZawuFpmglDZLr8EcE3JVcWF+1voWbKGK4jzinV1OqE2kHfn6ov1n2Bf1s4iNSzIpcifkvVEZdj8jxK0Uhdzhev4n8l6UdRHw6jPcp6zBGzOG0mSlwwYhhpU4YfSvTJKHSlv8wAsXSfSypjhR5CuBFzoEMORvyo1lsph2lUyvGFd5FFUzBQibhkkfZuRXDWtXLP6tv4guBckmfwk2tHlHqfpTM8+bt6RvTejAIq5L8KhRbETUWbopgyC7kKYzTyfBxAEETov98RKxOG48o3eGtQDhlkULHqmKGiYkuxF9pHjB3PiFU+FKpXu5Ep7L+jAIskPVtSPHLf5jWTId9ps/h1+whhE9oiSIIez0wS9RA8CcLm143P46jkWh7y/kbpAx0MEeY=----ATTACHMENT:----MjA0NjYzNDM4OTkxMzYyNCA0NzEzMDkzNTEwNDI2NTYxIDc4NjEyNzAwMTczMTU2NDA=