vendor/symfony/maker-bundle/src/Maker/MakeFunctionalTest.php line 26

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony MakerBundle package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Bundle\MakerBundle\Maker;
  11. use Symfony\Bundle\FrameworkBundle\Test\WebTestAssertionsTrait;
  12. use Symfony\Bundle\MakerBundle\ConsoleStyle;
  13. use Symfony\Bundle\MakerBundle\DependencyBuilder;
  14. use Symfony\Bundle\MakerBundle\Generator;
  15. use Symfony\Bundle\MakerBundle\InputConfiguration;
  16. use Symfony\Component\BrowserKit\History;
  17. use Symfony\Component\Console\Command\Command;
  18. use Symfony\Component\Console\Input\InputArgument;
  19. use Symfony\Component\Console\Input\InputInterface;
  20. use Symfony\Component\CssSelector\CssSelectorConverter;
  21. use Symfony\Component\Panther\PantherTestCaseTrait;
  22. trigger_deprecation('symfony/maker-bundle''1.29''The "%s" class is deprecated, use "%s" instead.'MakeFunctionalTest::class, MakeTest::class);
  23. /**
  24.  * @deprecated since MakerBundle 1.29, use Symfony\Bundle\MakerBundle\Maker\MakeTest instead.
  25.  *
  26.  * @author Javier Eguiluz <javier.eguiluz@gmail.com>
  27.  * @author Ryan Weaver <weaverryan@gmail.com>
  28.  */
  29. class MakeFunctionalTest extends AbstractMaker
  30. {
  31.     public static function getCommandName(): string
  32.     {
  33.         return 'make:functional-test';
  34.     }
  35.     public static function getCommandDescription(): string
  36.     {
  37.         return 'Creates a new functional test class';
  38.     }
  39.     public function configureCommand(Command $commandInputConfiguration $inputConf)
  40.     {
  41.         $command
  42.             ->addArgument('name'InputArgument::OPTIONAL'The name of the functional test class (e.g. <fg=yellow>DefaultControllerTest</>)')
  43.             ->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeFunctionalTest.txt'))
  44.         ;
  45.     }
  46.     public function generate(InputInterface $inputConsoleStyle $ioGenerator $generator)
  47.     {
  48.         $testClassNameDetails $generator->createClassNameDetails(
  49.             $input->getArgument('name'),
  50.             'Tests\\',
  51.             'Test'
  52.         );
  53.         $generator->generateClass(
  54.             $testClassNameDetails->getFullName(),
  55.             'test/Functional.tpl.php',
  56.             [
  57.                 'web_assertions_are_available' => trait_exists(WebTestAssertionsTrait::class),
  58.                 'panther_is_available' => trait_exists(PantherTestCaseTrait::class),
  59.             ]
  60.         );
  61.         $generator->writeChanges();
  62.         $this->writeSuccessMessage($io);
  63.         $io->text([
  64.             'Next: Open your new test class and start customizing it.',
  65.             'Find the documentation at <fg=yellow>https://symfony.com/doc/current/testing.html#functional-tests</>',
  66.         ]);
  67.     }
  68.     public function configureDependencies(DependencyBuilder $dependencies)
  69.     {
  70.         $dependencies->addClassDependency(
  71.             History::class,
  72.             'browser-kit',
  73.             true,
  74.             true
  75.         );
  76.         $dependencies->addClassDependency(
  77.             CssSelectorConverter::class,
  78.             'css-selector',
  79.             true,
  80.             true
  81.         );
  82.     }
  83. }