|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace SmartWeb\ModuleTesting\Codeception; |
|
5
|
|
|
|
|
6
|
|
|
use Illuminate\Support\Arr; |
|
7
|
|
|
use Illuminate\Support\Str; |
|
8
|
|
|
use function collect; |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
class AbstractGlobalConfiguration extends AbstractConfiguration implements GlobalConfigurationInterface |
|
12
|
|
|
{ |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @var string[][] |
|
16
|
|
|
*/ |
|
17
|
|
|
protected static $supportingDirs = []; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Get an attribute from the container using "dot" notation. |
|
21
|
|
|
* |
|
22
|
|
|
* @param string $key |
|
23
|
|
|
* @param mixed $default |
|
24
|
|
|
* |
|
25
|
|
|
* @return mixed |
|
26
|
|
|
*/ |
|
27
|
|
|
public function get(string $key, $default = null) |
|
28
|
|
|
{ |
|
29
|
|
|
return Arr::get($this->attributes, $key, $default); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @return array |
|
34
|
|
|
*/ |
|
35
|
|
|
public function toArray() : array |
|
36
|
|
|
{ |
|
37
|
|
|
return $this->attributes; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @return string[] |
|
42
|
|
|
*/ |
|
43
|
|
|
final public function getPaths() |
|
44
|
|
|
{ |
|
45
|
|
|
return $this[self::PATHS]; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @return string[] |
|
50
|
|
|
*/ |
|
51
|
|
|
final public function getSupportingDirs() |
|
52
|
|
|
{ |
|
53
|
|
|
return $this->resolveSupportingDirs(); |
|
54
|
|
|
// return static::$supportingDirs[$this->getNamespace()] = static::$supportingDirs[$this->getNamespace()] |
|
|
|
|
|
|
55
|
|
|
// ?? $this->resolveSupportingDirs(); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @return string[] |
|
60
|
|
|
*/ |
|
61
|
|
|
final protected function resolveSupportingDirs() |
|
62
|
|
|
{ |
|
63
|
|
|
return ['_data', '_support', '_output', '_envs']; |
|
64
|
|
|
// $filter = $this->getTestsDir() . DIRECTORY_SEPARATOR . '_'; |
|
|
|
|
|
|
65
|
|
|
// return $this->filterPaths($filter); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @param string $filter |
|
70
|
|
|
*/ |
|
71
|
|
|
protected function filterPaths(string $filter) |
|
72
|
|
|
{ |
|
73
|
|
|
return collect($this->getPaths()) |
|
74
|
|
|
->filter( |
|
75
|
|
|
function (string $dir) use ($filter) |
|
76
|
|
|
{ |
|
77
|
|
|
return Str::startsWith($dir, $filter); |
|
78
|
|
|
} |
|
79
|
|
|
) |
|
80
|
|
|
->all(); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return string |
|
85
|
|
|
*/ |
|
86
|
|
|
final public function getTestsDir() : string |
|
87
|
|
|
{ |
|
88
|
|
|
return $this[self::TESTS_DIR]; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @return string |
|
93
|
|
|
*/ |
|
94
|
|
|
final public function getDataDir() : string |
|
95
|
|
|
{ |
|
96
|
|
|
return $this[self::DATA_DIR]; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @return string |
|
101
|
|
|
*/ |
|
102
|
|
|
final public function getOutputDir() : string |
|
103
|
|
|
{ |
|
104
|
|
|
return $this[self::DATA_DIR]; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @return string |
|
109
|
|
|
*/ |
|
110
|
|
|
final public function getSupportDir() : string |
|
111
|
|
|
{ |
|
112
|
|
|
return $this[self::DATA_DIR]; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @return string |
|
117
|
|
|
*/ |
|
118
|
|
|
final public function getEnvironmentsDir() : string |
|
119
|
|
|
{ |
|
120
|
|
|
return $this[self::DATA_DIR]; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @return string |
|
125
|
|
|
*/ |
|
126
|
|
|
public function getNamespace() : string |
|
127
|
|
|
{ |
|
128
|
|
|
return $this[self::NAMESPACE]; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
} |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.