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

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\FrameworkBundle\Test\WebTestCase;
  13. use Symfony\Bundle\MakerBundle\ConsoleStyle;
  14. use Symfony\Bundle\MakerBundle\DependencyBuilder;
  15. use Symfony\Bundle\MakerBundle\Generator;
  16. use Symfony\Bundle\MakerBundle\InputConfiguration;
  17. use Symfony\Bundle\MakerBundle\Util\UseStatementGenerator;
  18. use Symfony\Component\BrowserKit\History;
  19. use Symfony\Component\Console\Command\Command;
  20. use Symfony\Component\Console\Input\InputArgument;
  21. use Symfony\Component\Console\Input\InputInterface;
  22. use Symfony\Component\CssSelector\CssSelectorConverter;
  23. use Symfony\Component\Panther\PantherTestCase;
  24. use Symfony\Component\Panther\PantherTestCaseTrait;
  25. trigger_deprecation('symfony/maker-bundle''1.29''The "%s" class is deprecated, use "%s" instead.'MakeFunctionalTest::class, MakeTest::class);
  26. /**
  27.  * @deprecated since MakerBundle 1.29, use Symfony\Bundle\MakerBundle\Maker\MakeTest instead.
  28.  *
  29.  * @author Javier Eguiluz <javier.eguiluz@gmail.com>
  30.  * @author Ryan Weaver <weaverryan@gmail.com>
  31.  */
  32. class MakeFunctionalTest extends AbstractMaker
  33. {
  34.     public static function getCommandName(): string
  35.     {
  36.         return 'make:functional-test';
  37.     }
  38.     public static function getCommandDescription(): string
  39.     {
  40.         return 'Creates a new functional test class';
  41.     }
  42.     public function configureCommand(Command $commandInputConfiguration $inputConfig): void
  43.     {
  44.         $command
  45.             ->addArgument('name'InputArgument::OPTIONAL'The name of the functional test class (e.g. <fg=yellow>DefaultControllerTest</>)')
  46.             ->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeFunctionalTest.txt'))
  47.         ;
  48.     }
  49.     public function generate(InputInterface $inputConsoleStyle $ioGenerator $generator): void
  50.     {
  51.         $testClassNameDetails $generator->createClassNameDetails(
  52.             $input->getArgument('name'),
  53.             'Tests\\',
  54.             'Test'
  55.         );
  56.         $pantherAvailable trait_exists(PantherTestCaseTrait::class);
  57.         $useStatements = new UseStatementGenerator([
  58.             $pantherAvailable PantherTestCase::class : WebTestCase::class,
  59.         ]);
  60.         $generator->generateClass(
  61.             $testClassNameDetails->getFullName(),
  62.             'test/Functional.tpl.php',
  63.             [
  64.                 'use_statements' => $useStatements,
  65.                 'web_assertions_are_available' => trait_exists(WebTestAssertionsTrait::class),
  66.                 'panther_is_available' => $pantherAvailable,
  67.             ]
  68.         );
  69.         $generator->writeChanges();
  70.         $this->writeSuccessMessage($io);
  71.         $io->text([
  72.             'Next: Open your new test class and start customizing it.',
  73.             'Find the documentation at <fg=yellow>https://symfony.com/doc/current/testing.html#functional-tests</>',
  74.         ]);
  75.     }
  76.     public function configureDependencies(DependencyBuilder $dependencies): void
  77.     {
  78.         $dependencies->addClassDependency(
  79.             History::class,
  80.             'browser-kit',
  81.             true,
  82.             true
  83.         );
  84.         $dependencies->addClassDependency(
  85.             CssSelectorConverter::class,
  86.             'css-selector',
  87.             true,
  88.             true
  89.         );
  90.     }
  91. }