Code Duplication    Length = 62-62 lines in 2 locations

src/Console/Command/GenerateCest.php 1 location

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

src/Console/Command/GenerateTest.php 1 location

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