1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace SmartWeb\ModuleTesting\Generator\Test; |
5
|
|
|
|
6
|
|
|
use SmartWeb\ModuleTesting\Codeception\SetupInterface; |
7
|
|
|
use function class_basename; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class CestGenerator |
11
|
|
|
* |
12
|
|
|
* @package SmartWeb\ModuleTesting\Generator\Test |
13
|
|
|
*/ |
14
|
|
|
class CestGenerator extends BaseTestGenerator |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* CestGenerator constructor. |
19
|
|
|
* |
20
|
|
|
* @param SetupInterface $setup |
21
|
|
|
* @param string $suite |
22
|
|
|
* @param string $name |
23
|
|
|
* @param array $settings |
24
|
|
|
* |
25
|
|
|
* @throws \Exception |
26
|
|
|
*/ |
27
|
|
|
public function __construct(SetupInterface $setup, string $suite, string $name, array $settings = []) |
28
|
|
|
{ |
29
|
|
|
parent::__construct(CodeceptionTestType::cest(), $setup, $suite, $name, $settings); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @return array |
34
|
|
|
* @throws \Codeception\Exception\ConfigurationException |
35
|
|
|
* @throws \Exception |
36
|
|
|
*/ |
37
|
|
|
protected function getBaseSettings() : array |
38
|
|
|
{ |
39
|
|
|
$suiteSettings = $this->getSuiteSettings($this->suite); |
40
|
|
|
$moduleSettings = $this->getSettingsForModule(); |
41
|
|
|
|
42
|
|
|
$baseSettings = [ |
43
|
|
|
'namespace' => $suiteSettings['namespace'], |
44
|
|
|
'baseClass' => $this->getBaseClass(), |
45
|
|
|
'baseClassShort' => class_basename($this->getBaseClass()), |
46
|
|
|
'name' => class_basename($this->name), |
47
|
|
|
'group' => 'exampleGroup', |
48
|
|
|
]; |
49
|
|
|
|
50
|
|
|
$actor = ($suiteSettings['actor'] ?? $moduleSettings['actor']) ?? 'Tester'; |
51
|
|
|
|
52
|
|
|
$baseSettings['actor'] = $actor; |
53
|
|
|
$baseSettings['actorName'] = 'tester'; |
54
|
|
|
$baseSettings['actorClass'] = $suiteSettings['namespace'] . '\\' . $actor; |
55
|
|
|
$baseSettings['actorClassShort'] = class_basename($actor); |
56
|
|
|
|
57
|
|
|
return $baseSettings; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|