/**
  * Module generator test
  *
  * @param $module
  * @param $machine_name
  * @param $module_path,
  * @param $description
  * @param $core
  * @param $package
  * @param $moduleFile
  * @param $feature
  * @param $composer
  * @param $dependencies
  *
  * @dataProvider commandData
  */
 public function testGenerateModule($module, $machine_name, $module_path, $description, $core, $package, $moduleFile, $feature, $composer, $dependencies)
 {
     $generator = new ModuleGenerator();
     $this->getRenderHelper()->setSkeletonDirs($this->getSkeletonDirs());
     $this->getRenderHelper()->setTranslator($this->getTranslatorHelper());
     $generator->setHelperSet($this->getHelperSet());
     $generator->generate($module, $machine_name, $module_path, $description, $core, $package, $moduleFile, $feature, $composer, $dependencies);
     $this->assertTrue(file_exists($module_path . '/' . $machine_name . '/' . $machine_name . '.info.yml'), sprintf('%s has been generated', $module_path . '/' . $machine_name . '.info.yml'));
     if ($moduleFile) {
         $this->assertTrue(file_exists($module_path . '/' . $machine_name . '/' . $machine_name . '.module'), sprintf('%s has been generated', $module_path . '/' . $machine_name . '/' . $machine_name . '.module'));
     }
     if ($composer) {
         $this->assertTrue(file_exists($module_path . '/' . $machine_name . '/composer.json'), sprintf('%s has been generated', $module_path . '/' . $machine_name . '/composer.json'));
     }
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $yes = $input->hasOption('yes') ? $input->getOption('yes') : false;
     // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
     if (!$this->confirmGeneration($io, $yes)) {
         return;
     }
     $module = $this->validator->validateModuleName($input->getOption('module'));
     $modulePath = $this->appRoot . $input->getOption('module-path');
     $modulePath = $this->validator->validateModulePath($modulePath, true);
     $machineName = $this->validator->validateMachineName($input->getOption('machine-name'));
     $description = $input->getOption('description');
     $core = $input->getOption('core');
     $package = $input->getOption('package');
     $moduleFile = $input->getOption('module-file');
     $featuresBundle = $input->getOption('features-bundle');
     $composer = $input->getOption('composer');
     // Modules Dependencies, re-factor and share with other commands
     $dependencies = $this->validator->validateModuleDependencies($input->getOption('dependencies'));
     // Check if all module dependencies are available
     if ($dependencies) {
         $checked_dependencies = $this->checkDependencies($dependencies['success']);
         if (!empty($checked_dependencies['no_modules'])) {
             $io->warning(sprintf($this->trans('commands.generate.module.warnings.module-unavailable'), implode(', ', $checked_dependencies['no_modules'])));
         }
         $dependencies = $dependencies['success'];
     }
     $this->generator->generate($module, $machineName, $modulePath, $description, $core, $package, $moduleFile, $featuresBundle, $composer, $dependencies);
 }