X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FGenerate%2FJsTestCommand.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FGenerate%2FJsTestCommand.php;h=edca262116a5e4eea8766b4e0fea07702f0c12ba;hp=0000000000000000000000000000000000000000;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/drupal/console/src/Command/Generate/JsTestCommand.php b/vendor/drupal/console/src/Command/Generate/JsTestCommand.php new file mode 100644 index 000000000..edca26211 --- /dev/null +++ b/vendor/drupal/console/src/Command/Generate/JsTestCommand.php @@ -0,0 +1,126 @@ +extensionManager = $extensionManager; + $this->generator = $generator; + $this->validator = $validator; + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('generate:jstest') + ->setDescription($this->trans('commands.generate.jstest.description')) + ->setHelp($this->trans('commands.generate.jstest.help')) + ->addOption( + 'module', + null, + InputOption::VALUE_REQUIRED, + $this->trans('commands.common.options.module') + ) + ->addOption( + 'class', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.jstest.options.class') + ) + ->setAliases(['gjt']); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmOperation + if (!$this->confirmOperation()) { + return 1; + } + + $module = $input->getOption('module'); + $class = $this->validator->validateClassName($input->getOption('class')); + + $this->generator->generate([ + 'module' => $module, + 'class' => $class, + ]); + + return 0; + } + + /** + * {@inheritdoc} + */ + protected function interact(InputInterface $input, OutputInterface $output) + { + // --module option + $this->getModuleOption(); + + // --class option + $class = $input->getOption('class'); + if (!$class) { + $class = $this->getIo()->ask( + $this->trans('commands.generate.jstest.questions.class'), + 'DefaultJsTest', + function ($class) { + return $this->validator->validateClassName($class); + } + ); + $input->setOption('class', $class); + } + } +}