| @@ 19-75 (lines=57) @@ | ||
| 16 | * |
|
| 17 | * @package SmartWeb\ModuleTesting\Console |
|
| 18 | */ |
|
| 19 | class GenerateCest extends BaseCommand |
|
| 20 | { |
|
| 21 | ||
| 22 | /** |
|
| 23 | * The console command name. |
|
| 24 | * |
|
| 25 | * @var string |
|
| 26 | */ |
|
| 27 | protected $name = 'make-cest'; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * The console command description. |
|
| 31 | * |
|
| 32 | * @var string |
|
| 33 | */ |
|
| 34 | protected $description = 'Generate a Codeception Cest for the given module and suite'; |
|
| 35 | ||
| 36 | /** |
|
| 37 | * Execute the console command. |
|
| 38 | * |
|
| 39 | * @return void |
|
| 40 | * |
|
| 41 | * @throws Exception |
|
| 42 | */ |
|
| 43 | public function fire() |
|
| 44 | { |
|
| 45 | /** |
|
| 46 | * @var string $moduleName |
|
| 47 | * @var string $suite |
|
| 48 | * @var string $name |
|
| 49 | */ |
|
| 50 | $moduleName = $this->argument('moduleName'); |
|
| 51 | $suite = $this->argument('suite'); |
|
| 52 | $name = $this->argument('name'); |
|
| 53 | ||
| 54 | $this->info("Creating '{$name}' for module '{$moduleName}' in suite '{$suite}'."); |
|
| 55 | ||
| 56 | $setup = new Setup($moduleName); |
|
| 57 | ||
| 58 | try { |
|
| 59 | $generator = new CestGenerator($setup, $suite, $name); |
|
| 60 | $generator->generate(); |
|
| 61 | $this->info("Created test!"); |
|
| 62 | } catch (Exception $e) { |
|
| 63 | $this->error("Failed to create test!"); |
|
| 64 | throw $e; |
|
| 65 | } |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * @return CommandArguments |
|
| 70 | */ |
|
| 71 | protected function provideArguments() : CommandArguments |
|
| 72 | { |
|
| 73 | return new CommandArguments([ |
|
| 74 | new CommandArgument('moduleName', InputArgumentType::required(), 'The name of the module.'), |
|
| 75 | new CommandArgument('suite', InputArgumentType::required(), 'The suite to generate test in.'), |
|
| 76 | new CommandArgument('name', InputArgumentType::required(), 'The name of the test.'), |
|
| 77 | ]); |
|
| 78 | } |
|
| @@ 19-75 (lines=57) @@ | ||
| 16 | * |
|
| 17 | * @package SmartWeb\ModuleTesting\Console |
|
| 18 | */ |
|
| 19 | class GenerateTest extends BaseCommand |
|
| 20 | { |
|
| 21 | ||
| 22 | /** |
|
| 23 | * The console command name. |
|
| 24 | * |
|
| 25 | * @var string |
|
| 26 | */ |
|
| 27 | protected $name = 'make-test'; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * The console command description. |
|
| 31 | * |
|
| 32 | * @var string |
|
| 33 | */ |
|
| 34 | protected $description = 'Generate a Codeception Test for the given module and suite'; |
|
| 35 | ||
| 36 | /** |
|
| 37 | * Execute the console command. |
|
| 38 | * |
|
| 39 | * @return void |
|
| 40 | * |
|
| 41 | * @throws Exception |
|
| 42 | */ |
|
| 43 | public function fire() |
|
| 44 | { |
|
| 45 | /** |
|
| 46 | * @var string $moduleName |
|
| 47 | * @var string $suite |
|
| 48 | * @var string $name |
|
| 49 | */ |
|
| 50 | $moduleName = $this->argument('moduleName'); |
|
| 51 | $suite = $this->argument('suite'); |
|
| 52 | $name = $this->argument('name'); |
|
| 53 | ||
| 54 | $this->info("Creating '{$name}' for module '{$moduleName}' in suite '{$suite}'."); |
|
| 55 | ||
| 56 | $setup = new Setup($moduleName); |
|
| 57 | ||
| 58 | try { |
|
| 59 | $generator = new TestGenerator($setup, $suite, $name); |
|
| 60 | $generator->generate(); |
|
| 61 | $this->info("Created test!"); |
|
| 62 | } catch (Exception $e) { |
|
| 63 | $this->error("Failed to create test!"); |
|
| 64 | throw $e; |
|
| 65 | } |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * @return CommandArguments |
|
| 70 | */ |
|
| 71 | protected function provideArguments() : CommandArguments |
|
| 72 | { |
|
| 73 | return new CommandArguments([ |
|
| 74 | new CommandArgument('moduleName', InputArgumentType::required(), 'The name of the module.'), |
|
| 75 | new CommandArgument('suite', InputArgumentType::required(), 'The suite to generate test in.'), |
|
| 76 | new CommandArgument('name', InputArgumentType::required(), 'The name of the test.'), |
|
| 77 | ]); |
|
| 78 | } |
|