Completed
Push — master ( 06b292...adafac )
by Nicolai
02:22
created

CestGenerator::getBaseSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 15
nc 1
nop 0
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
4
namespace SmartWeb\ModuleTesting\Generator;
5
6
use Illuminate\Contracts\Filesystem\Filesystem;
7
use SmartWeb\ModuleTesting\BaseIntegrationCest;
8
use SmartWeb\ModuleTesting\Codeception\SetupInterface;
9
use function class_basename;
10
11
12
/**
13
 * Class CestGenerator
14
 *
15
 * @package SmartWeb\Testing\Generator
16
 */
17
class CestGenerator extends BaseTestGenerator
18
{
19
    
20
    /**
21
     * @var Filesystem
22
     */
23
    protected $disk;
24
    
25
    /**
26
     * @var SetupInterface
27
     */
28
    protected $setup;
29
    
30
    /**
31
     * @var string
32
     */
33
    protected $suite;
34
    
35
    /**
36
     * @var string
37
     */
38
    protected $name;
39
    
40
    /**
41
     * @var array
42
     */
43
    protected $settings;
44
    
45
    /**
46
     * @var string
47
     */
48
    protected $templatePath;
49
    
50
    /**
51
     * CestGenerator constructor.
52
     *
53
     * @param SetupInterface $setup
54
     * @param string         $suite
55
     * @param string         $name
56
     * @param array          $settings
57
     *
58
     * @throws \Exception
59
     */
60
    public function __construct(SetupInterface $setup, string $suite, string $name, array $settings = [])
61
    {
62
        parent::__construct(CodeceptionTestType::cest(), $setup, $suite, $name, $settings);
63
    }
64
    
65
    /**
66
     * @return array
67
     * @throws \Codeception\Exception\ConfigurationException
68
     * @throws \Exception
69
     */
70
    protected function getBaseSettings() : array
71
    {
72
        $suiteSettings = $this->getSuiteSettings($this->suite);
73
        $moduleSettings = $this->getSettingsForModule();
74
        
75
        $baseSettings = [
76
            'namespace'      => $suiteSettings['namespace'],
77
            'baseClass'      => BaseIntegrationCest::class,
78
            'baseClassShort' => 'BaseIntegrationCest',
79
            'name'           => class_basename($this->name),
80
            'group'          => 'exampleGroup',
81
        ];
82
        
83
        $actor = ($suiteSettings['actor'] ?? $moduleSettings['actor']) ?? 'Tester';
84
        
85
        $baseSettings['actor'] = $actor;
86
        $baseSettings['actorName'] = 'tester';
87
        $baseSettings['actorClass'] = $suiteSettings['namespace'] . '\\' . $actor;
88
        $baseSettings['actorClassShort'] = class_basename($actor);
89
        
90
        return $baseSettings;
91
    }
92
}