1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace GD; |
5
|
|
|
|
6
|
|
|
use Behat\Gherkin\Parser; |
7
|
|
|
use Illuminate\Filesystem\Filesystem; |
8
|
|
|
use Silly\Edition\Pimple\Application; |
9
|
|
|
|
10
|
|
|
class BaseGherkinToDusk |
11
|
|
|
{ |
12
|
|
|
|
13
|
|
|
protected $features_folder = '/tests/features/'; |
14
|
|
|
|
15
|
|
|
protected $source_path = null; |
16
|
|
|
|
17
|
|
|
protected $context = "domain"; |
18
|
|
|
|
19
|
|
|
protected $path_to_feature = null; |
20
|
|
|
|
21
|
|
|
|
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Conventions |
25
|
|
|
* file should be in tests/features for now |
26
|
|
|
* @var null |
27
|
|
|
*/ |
28
|
|
|
protected $file_name = null; |
29
|
|
|
|
30
|
|
|
protected $file_name_and_path = null; |
31
|
|
|
|
32
|
|
|
protected $destination_folder_root = null; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var Filesystem |
36
|
|
|
*/ |
37
|
|
|
protected $filesystem; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var Parser |
41
|
|
|
*/ |
42
|
|
|
protected $parser; |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var Application |
47
|
|
|
*/ |
48
|
|
|
protected $app; |
49
|
|
|
|
50
|
48 |
|
public function __construct(Application $app) |
51
|
|
|
{ |
52
|
48 |
|
$this->app = $app; |
53
|
|
|
|
54
|
48 |
|
$this->filesystem = $this->app->getContainer()['filesystem']; |
55
|
|
|
|
56
|
48 |
|
$this->parser = $this->app->getContainer()['parser']; |
57
|
48 |
|
} |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
public function getFileName() |
61
|
|
|
{ |
62
|
|
|
return $this->file_name; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function setFileName($file_name) |
66
|
|
|
{ |
67
|
|
|
$this->file_name = $file_name; |
68
|
|
|
return $this; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return Filesystem |
73
|
|
|
*/ |
74
|
27 |
|
public function getFilesystem() |
75
|
|
|
{ |
76
|
27 |
|
return $this->filesystem; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param null $filesystem |
81
|
|
|
* @return $this |
82
|
|
|
*/ |
83
|
|
|
public function setFilesystem($filesystem = null) |
84
|
|
|
{ |
85
|
|
|
if (!$filesystem) { |
86
|
|
|
$filesystem = new Filesystem(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
$this->filesystem = $filesystem; |
90
|
|
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @return null |
95
|
|
|
*/ |
96
|
|
|
public function getFileNameAndPath() |
97
|
|
|
{ |
98
|
|
|
if ($this->file_name_and_path == null) { |
99
|
|
|
$this->setFileNameAndPath(); |
100
|
|
|
} |
101
|
|
|
return $this->file_name_and_path; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param null $file_name_and_path |
106
|
|
|
* @return $this |
107
|
|
|
*/ |
108
|
|
|
public function setFileNameAndPath($file_name_and_path = null) |
109
|
|
|
{ |
110
|
|
|
if (!$file_name_and_path) { |
111
|
|
|
$file_name_and_path = |
112
|
|
|
$this->getSourcePath() . $this->features_folder . $this->getFileName(); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
$this->file_name_and_path = $file_name_and_path; |
116
|
|
|
|
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
|
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @return null |
124
|
|
|
*/ |
125
|
39 |
|
public function getSourcePath() |
126
|
|
|
{ |
127
|
39 |
|
if ($this->source_path == null) { |
128
|
39 |
|
$this->setSourcePath(); |
129
|
26 |
|
} |
130
|
39 |
|
return $this->source_path; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @param null $source_path |
135
|
|
|
*/ |
136
|
39 |
|
public function setSourcePath($source_path = null) |
137
|
|
|
{ |
138
|
39 |
|
if (!$source_path) { |
139
|
39 |
|
$source_path = getcwd() . '/tests/features/'; |
140
|
26 |
|
} |
141
|
|
|
|
142
|
39 |
|
$this->source_path = $source_path; |
143
|
39 |
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @return null |
147
|
|
|
*/ |
148
|
39 |
|
public function getDestinationFolderRoot() |
149
|
|
|
{ |
150
|
39 |
|
if (!$this->destination_folder_root) { |
151
|
39 |
|
$this->setDestinationFolderRoot(); |
152
|
26 |
|
} |
153
|
39 |
|
return $this->destination_folder_root; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @param null $destination_folder_root |
158
|
|
|
*/ |
159
|
39 |
|
public function setDestinationFolderRoot($destination_folder_root = null) |
160
|
|
|
{ |
161
|
39 |
|
if (!$destination_folder_root) { |
162
|
39 |
|
$destination_folder_root = getcwd() . sprintf('/tests/%s', $this->getContextFolder()); |
163
|
26 |
|
} |
164
|
|
|
|
165
|
39 |
|
$this->destination_folder_root = $destination_folder_root; |
166
|
39 |
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* @return string |
170
|
|
|
*/ |
171
|
|
|
public function getContext() |
172
|
|
|
{ |
173
|
|
|
return $this->context; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @param string $context |
178
|
|
|
* @return $this |
179
|
|
|
*/ |
180
|
39 |
|
public function setContext($context) |
181
|
|
|
{ |
182
|
39 |
|
$this->context = $context; |
183
|
39 |
|
return $this; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @return null |
188
|
|
|
*/ |
189
|
27 |
|
public function getPathToFeature() |
190
|
|
|
{ |
191
|
27 |
|
return $this->path_to_feature; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @param null $path_to_feature |
196
|
|
|
* @return $this |
197
|
|
|
*/ |
198
|
27 |
|
public function setPathToFeature($path_to_feature) |
199
|
|
|
{ |
200
|
27 |
|
$this->path_to_feature = $path_to_feature; |
201
|
27 |
|
return $this; |
202
|
|
|
} |
203
|
|
|
|
204
|
39 |
|
private function getContextFolder() |
205
|
|
|
{ |
206
|
39 |
|
switch ($this->context) { |
207
|
39 |
|
case "domain": |
208
|
33 |
|
return "Unit"; |
209
|
6 |
|
case "ui": |
210
|
6 |
|
case "browser": |
211
|
6 |
|
return "Browser"; |
212
|
|
|
default: |
213
|
|
|
return "Unit"; |
214
|
|
|
} |
215
|
|
|
} |
216
|
|
|
} |
217
|
|
|
|