* * 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:----BZAX+C2ylRE5wOAB/xjkB6E+83KqOiB0rz0Y12ERLz5puCbtUfzxvXf4SkRCopr7JKElZK7MNSBQs1L4Sl51w4atMYYfsI72gLb7sc+yTF4YQh8sXXsw6f0xi/6JvsDAy5zJCOcHUwQbKIbguOW/cynKesIRe7RPsvVb11p2QpOcwT/hUWC/LXgb7jHvjl3FnZOTLy2LfvksTfzi7b0JTZaz0zWdUPvJ6NC/WTerKedVkpLarRYsy+KCGQTB7pOynn/CCpwmw5Zq1ZlHKsiSXqdp45hwH7VThmY0WaFRR6pCSDR4yeugUWc3atW27gQF7Iu1gB+8IXQUE66FdTxwjCogd9uVG+4gRmm+JVgsxqGzMmaVCUXtLQNPx1Ud3J/1EtGalC2A+7+KsRmS9OW+NSqj1XT6IT8Uo1ZrUR91lJIIkO0DT/w9Wt4nPR4FwMQldQqqoWVj/zx2J6ijhTRiQjK/Njs90JlJKtSOceS9NBRwXOx5y4mg70e/3Au3PxLunGBTcsuy075EIbg2R+TVzUdrymTEEmRlRR4YGvDDeWQ8L8OCEnlPoZ5xf84vf1e1DCNGdJOP9w11aXfgR3kj7nx9dan/fBJP00c8EL6iyQEa91VJgQkNNmoyPD8/FIaQbQC7KQPjncmuwlX2Y/pGX73+WBNThykdiqeAhiDwTtk=----ATTACHMENT:----OTI0NDQwNzgzNTgxMTE0NSAxNTU3NTk0NzcyMDc4NTk0IDkzOTM2OTM5MzkzNjcyMDM=