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
|
|
|
} |