vendor/symfony/maker-bundle/src/Maker/MakeUnitTest.php line 24

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 PHPUnit\Framework\TestCase;
  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\Bundle\MakerBundle\Util\UseStatementGenerator;
  17. use Symfony\Component\Console\Command\Command;
  18. use Symfony\Component\Console\Input\InputArgument;
  19. use Symfony\Component\Console\Input\InputInterface;
  20. trigger_deprecation('symfony/maker-bundle', '1.29', 'The "%s" class is deprecated, use "%s" instead.', MakeUnitTest::class, MakeTest::class);
  21. /**
  22. * @deprecated since MakerBundle 1.29, use Symfony\Bundle\MakerBundle\Maker\MakeTest instead.
  23. *
  24. * @author Javier Eguiluz <javier.eguiluz@gmail.com>
  25. * @author Ryan Weaver <weaverryan@gmail.com>
  26. */
  27. final class MakeUnitTest extends AbstractMaker
  28. {
  29. public static function getCommandName(): string
  30. {
  31. return 'make:unit-test';
  32. }
  33. public static function getCommandDescription(): string
  34. {
  35. return 'Creates a new unit test class';
  36. }
  37. public function configureCommand(Command $command, InputConfiguration $inputConfig): void
  38. {
  39. $command
  40. ->addArgument('name', InputArgument::OPTIONAL, 'The name of the unit test class (e.g. <fg=yellow>UtilTest</>)')
  41. ->setHelp(file_get_contents(__DIR__.'/../Resources/help/MakeUnitTest.txt'))
  42. ;
  43. }
  44. public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator): void
  45. {
  46. $testClassNameDetails = $generator->createClassNameDetails(
  47. $input->getArgument('name'),
  48. 'Tests\\',
  49. 'Test'
  50. );
  51. $generator->generateClass(
  52. $testClassNameDetails->getFullName(),
  53. 'test/Unit.tpl.php',
  54. ['use_statements' => new UseStatementGenerator([TestCase::class])]
  55. );
  56. $generator->writeChanges();
  57. $this->writeSuccessMessage($io);
  58. $io->text([
  59. 'Next: Open your new test class and start customizing it.',
  60. 'Find the documentation at <fg=yellow>https://symfony.com/doc/current/testing.html#unit-tests</>',
  61. ]);
  62. }
  63. public function configureDependencies(DependencyBuilder $dependencies): void
  64. {
  65. }
  66. }