5 * Contains \Drupal\Console\Command\Generate\JsTestCommand.
8 namespace Drupal\Console\Command\Generate;
10 use Drupal\Console\Command\Shared\ConfirmationTrait;
11 use Drupal\Console\Command\Shared\ModuleTrait;
12 use Drupal\Console\Core\Command\Command;
13 use Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait;
14 use Drupal\Console\Extension\Manager;
15 use Drupal\Console\Generator\JsTestGenerator;
16 use Drupal\Console\Utils\Validator;
17 use Symfony\Component\Console\Input\InputInterface;
18 use Symfony\Component\Console\Input\InputOption;
19 use Symfony\Component\Console\Output\OutputInterface;
21 class JsTestCommand extends Command
24 use ConfirmationTrait;
25 use ContainerAwareCommandTrait;
30 protected $extensionManager;
33 * @var JsTestGenerator
43 * JsTestCommand constructor.
45 * @param Manager $extensionManager
46 * @param JsTestGenerator $generator
47 * @param Validator $validator
49 public function __construct(
50 Manager $extensionManager,
51 JsTestGenerator $generator,
54 $this->extensionManager = $extensionManager;
55 $this->generator = $generator;
56 $this->validator = $validator;
57 parent::__construct();
63 protected function configure()
66 ->setName('generate:jstest')
67 ->setDescription($this->trans('commands.generate.jstest.description'))
68 ->setHelp($this->trans('commands.generate.jstest.help'))
72 InputOption::VALUE_REQUIRED,
73 $this->trans('commands.common.options.module')
78 InputOption::VALUE_OPTIONAL,
79 $this->trans('commands.generate.jstest.options.class')
81 ->setAliases(['gjt']);
87 protected function execute(InputInterface $input, OutputInterface $output)
89 // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmOperation
90 if (!$this->confirmOperation()) {
94 $module = $input->getOption('module');
95 $class = $this->validator->validateClassName($input->getOption('class'));
97 $this->generator->generate([
108 protected function interact(InputInterface $input, OutputInterface $output)
111 $this->getModuleOption();
114 $class = $input->getOption('class');
116 $class = $this->getIo()->ask(
117 $this->trans('commands.generate.jstest.questions.class'),
120 return $this->validator->validateClassName($class);
123 $input->setOption('class', $class);