| @@ 19-75 (lines=57) @@ | ||
| 16 | * |
|
| 17 | * @package SmartWeb\Testing\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 | $moduleName = $this->argument('moduleName'); |
|
| 46 | $suite = $this->argument('suite'); |
|
| 47 | $name = $this->argument('name'); |
|
| 48 | ||
| 49 | $this->info("Creating '{$name}' for module '{$moduleName}' in suite '{$suite}'."); |
|
| 50 | ||
| 51 | $setup = new Setup($moduleName); |
|
| 52 | ||
| 53 | try { |
|
| 54 | $generator = new CestGenerator($setup, $suite, $name); |
|
| 55 | $generator->generate(); |
|
| 56 | $this->info("Created test!"); |
|
| 57 | } catch (Exception $e) { |
|
| 58 | $this->error("Failed to create test!"); |
|
| 59 | throw $e; |
|
| 60 | } |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * @return CommandArguments |
|
| 65 | */ |
|
| 66 | protected function provideArguments() : CommandArguments |
|
| 67 | { |
|
| 68 | return new CommandArguments([ |
|
| 69 | new CommandArgument('moduleName', InputArgumentType::required(), 'The name of the module.'), |
|
| 70 | new CommandArgument('suite', InputArgumentType::required(), 'The suite to generate test in.'), |
|
| 71 | new CommandArgument('name', InputArgumentType::required(), 'The name of the test.'), |
|
| 72 | ]); |
|
| 73 | } |
|
| 74 | ||
| 75 | } |
|
| 76 | ||
| @@ 19-75 (lines=57) @@ | ||
| 16 | * |
|
| 17 | * @package SmartWeb\Testing\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 | $moduleName = $this->argument('moduleName'); |
|
| 46 | $suite = $this->argument('suite'); |
|
| 47 | $name = $this->argument('name'); |
|
| 48 | ||
| 49 | $this->info("Creating '{$name}' for module '{$moduleName}' in suite '{$suite}'."); |
|
| 50 | ||
| 51 | $setup = new Setup($moduleName); |
|
| 52 | ||
| 53 | try { |
|
| 54 | $generator = new TestGenerator($setup, $suite, $name); |
|
| 55 | $generator->generate(); |
|
| 56 | $this->info("Created test!"); |
|
| 57 | } catch (Exception $e) { |
|
| 58 | $this->error("Failed to create test!"); |
|
| 59 | throw $e; |
|
| 60 | } |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * @return CommandArguments |
|
| 65 | */ |
|
| 66 | protected function provideArguments() : CommandArguments |
|
| 67 | { |
|
| 68 | return new CommandArguments([ |
|
| 69 | new CommandArgument('moduleName', InputArgumentType::required(), 'The name of the module.'), |
|
| 70 | new CommandArgument('suite', InputArgumentType::required(), 'The suite to generate test in.'), |
|
| 71 | new CommandArgument('name', InputArgumentType::required(), 'The name of the test.'), |
|
| 72 | ]); |
|
| 73 | } |
|
| 74 | ||
| 75 | } |
|
| 76 | ||