|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Lug package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Eric GELOEN <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please read the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Lug\Bundle\LocaleBundle\Behat\Context; |
|
13
|
|
|
|
|
14
|
|
|
use Behat\Behat\Hook\Scope\BeforeScenarioScope; |
|
15
|
|
|
use Behat\Gherkin\Node\TableNode; |
|
16
|
|
|
use Lug\Bundle\GridBundle\Behat\Context\GridWebContext; |
|
17
|
|
|
use Lug\Bundle\ResourceBundle\Behat\Context\ResourceWebContext; |
|
18
|
|
|
use Lug\Component\Behat\Context\RoutingContext; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @author GeLo <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
class LocaleWebContext extends AbstractLocaleContext |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var GridWebContext |
|
27
|
|
|
*/ |
|
28
|
|
|
private $gridContext; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var RoutingContext |
|
32
|
|
|
*/ |
|
33
|
|
|
private $routingContext; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @BeforeScenario |
|
37
|
|
|
*/ |
|
38
|
|
|
public function init(BeforeScenarioScope $scope) |
|
39
|
|
|
{ |
|
40
|
|
|
$environment = $scope->getEnvironment(); |
|
41
|
|
|
|
|
42
|
|
|
$this->gridContext = $environment->getContext(GridWebContext::class); |
|
43
|
|
|
$this->resourceContext = $environment->getContext(ResourceWebContext::class); |
|
44
|
|
|
$this->routingContext = $environment->getContext(RoutingContext::class); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @Given I am on the locale listing page |
|
49
|
|
|
*/ |
|
50
|
|
|
public function visitIndex() |
|
51
|
|
|
{ |
|
52
|
|
|
$this->visit('index'); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @Given I am on the locale creation page |
|
57
|
|
|
*/ |
|
58
|
|
|
public function visitCreate() |
|
59
|
|
|
{ |
|
60
|
|
|
$this->visit('create'); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @param string $code |
|
65
|
|
|
* |
|
66
|
|
|
* @Given I am on the locale ":code" page |
|
67
|
|
|
*/ |
|
68
|
|
|
public function visitShow($code) |
|
69
|
|
|
{ |
|
70
|
|
|
$this->visit('show', $code); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @param string $code |
|
75
|
|
|
* |
|
76
|
|
|
* @Given I am on the locale ":code" edition page |
|
77
|
|
|
*/ |
|
78
|
|
|
public function visitUpdate($code) |
|
79
|
|
|
{ |
|
80
|
|
|
$this->visit('update', $code); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @Given I toggle the locale grid batches |
|
85
|
|
|
*/ |
|
86
|
|
|
public function toggleGridBatch() |
|
87
|
|
|
{ |
|
88
|
|
|
$this->gridContext->toggleBatch(); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @param string $code |
|
93
|
|
|
* |
|
94
|
|
|
* @Given I select the locale grid batch ":code" |
|
95
|
|
|
*/ |
|
96
|
|
|
public function selectGridBatch($code) |
|
97
|
|
|
{ |
|
98
|
|
|
$this->gridContext->selectBatch($code); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @Given I select the "all" locale grid batch |
|
103
|
|
|
*/ |
|
104
|
|
|
public function selectGridBatchAll() |
|
105
|
|
|
{ |
|
106
|
|
|
$this->gridContext->selectBatchAll(); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @param string $code |
|
111
|
|
|
* @param string $sorting |
|
112
|
|
|
* |
|
113
|
|
|
* @Given I follow the locale grid sorting link ":code" ":sorting" |
|
114
|
|
|
*/ |
|
115
|
|
|
public function followGridSortingLink($code, $sorting) |
|
116
|
|
|
{ |
|
117
|
|
|
$this->gridContext->followSortingLink($code, $sorting); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* @param string $code |
|
122
|
|
|
* |
|
123
|
|
|
* @Given I follow the locale grid show link ":code" |
|
124
|
|
|
*/ |
|
125
|
|
|
public function followGridShowLink($code) |
|
126
|
|
|
{ |
|
127
|
|
|
$this->gridContext->followColumnActionLink($code, 'Show'); |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @param string $code |
|
132
|
|
|
* |
|
133
|
|
|
* @Given I follow the locale grid edition link ":code" |
|
134
|
|
|
*/ |
|
135
|
|
|
public function followGridEditionLink($code) |
|
136
|
|
|
{ |
|
137
|
|
|
$this->gridContext->followColumnActionLink($code, 'Update'); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* @param string $code |
|
142
|
|
|
* |
|
143
|
|
|
* @Given I follow the locale grid deletion link ":code" |
|
144
|
|
|
*/ |
|
145
|
|
|
public function followGridDeletionLink($code) |
|
146
|
|
|
{ |
|
147
|
|
|
$this->gridContext->followColumnActionLink($code, 'Delete'); |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* @Given I wait the locale grid filters |
|
152
|
|
|
*/ |
|
153
|
|
|
public function waitGridFilters() |
|
154
|
|
|
{ |
|
155
|
|
|
$this->gridContext->waitFilters(); |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* @Given I wait the locale grid filters refresh |
|
160
|
|
|
*/ |
|
161
|
|
|
public function waitGridFiltersRefresh() |
|
162
|
|
|
{ |
|
163
|
|
|
$this->gridContext->waitFiltersRefresh(); |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* @param TableNode $table |
|
168
|
|
|
* |
|
169
|
|
|
* @Then the locale grid should be: |
|
170
|
|
|
*/ |
|
171
|
|
|
public function assertGrid(TableNode $table) |
|
172
|
|
|
{ |
|
173
|
|
|
$this->gridContext->assertGrid($table->getRows()); |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* @param string $column |
|
178
|
|
|
* @param string $order |
|
179
|
|
|
* |
|
180
|
|
|
* @Then the locale grid column ":column" should be sorted ":order" |
|
181
|
|
|
*/ |
|
182
|
|
|
public function assertGridSorting($column, $order) |
|
183
|
|
|
{ |
|
184
|
|
|
$this->gridContext->assertSorting($column, $order); |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* @param string $column |
|
189
|
|
|
* @param string $cells |
|
190
|
|
|
* |
|
191
|
|
|
* @Given the locale grid for the column ":column" should be ":cells" |
|
192
|
|
|
*/ |
|
193
|
|
|
public function assertGridCells($column, $cells) |
|
194
|
|
|
{ |
|
195
|
|
|
$this->gridContext->assertColumnCells( |
|
196
|
|
|
$column, |
|
|
|
|
|
|
197
|
|
|
array_map('trim', !empty($cells) ? explode(';', $cells) : []) |
|
198
|
|
|
); |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* @Then all locale grid batches should be checked |
|
203
|
|
|
*/ |
|
204
|
|
|
public function assertGridBatchesChecked() |
|
205
|
|
|
{ |
|
206
|
|
|
$this->gridContext->assertBatchesState(true); |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* @Then all locale grid batches should not be checked |
|
211
|
|
|
*/ |
|
212
|
|
|
public function assertGridBatchesUnchecked() |
|
213
|
|
|
{ |
|
214
|
|
|
$this->gridContext->assertBatchesState(false); |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
/** |
|
218
|
|
|
* @Then I should be on the locale listing page |
|
219
|
|
|
*/ |
|
220
|
|
|
public function assertIndexAddress() |
|
221
|
|
|
{ |
|
222
|
|
|
$this->assertAddress('index'); |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
/** |
|
226
|
|
|
* @Then I should be on the locale batching page |
|
227
|
|
|
*/ |
|
228
|
|
|
public function assertBatchAddress() |
|
229
|
|
|
{ |
|
230
|
|
|
$this->assertAddress('batch'); |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
/** |
|
234
|
|
|
* @Then I should be on the locale creation page |
|
235
|
|
|
*/ |
|
236
|
|
|
public function assertCreateAddress() |
|
237
|
|
|
{ |
|
238
|
|
|
$this->assertAddress('create'); |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
/** |
|
242
|
|
|
* @param string $code |
|
243
|
|
|
* |
|
244
|
|
|
* @Then I should be on the locale ":code" page |
|
245
|
|
|
*/ |
|
246
|
|
|
public function assertShowAddress($code) |
|
247
|
|
|
{ |
|
248
|
|
|
$this->assertAddress('show', $code); |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
/** |
|
252
|
|
|
* @param string $code |
|
253
|
|
|
* |
|
254
|
|
|
* @Then I should be on the locale ":code" edition page |
|
255
|
|
|
*/ |
|
256
|
|
|
public function assertUpdateAddress($code) |
|
257
|
|
|
{ |
|
258
|
|
|
$this->assertAddress('update', $code); |
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
|
|
/** |
|
262
|
|
|
* @param string $action |
|
263
|
|
|
* @param string|null $code |
|
264
|
|
|
*/ |
|
265
|
|
View Code Duplication |
private function visit($action, $code = null) |
|
|
|
|
|
|
266
|
|
|
{ |
|
267
|
|
|
$parameters = []; |
|
268
|
|
|
|
|
269
|
|
|
if ($code !== null) { |
|
270
|
|
|
$parameters['code'] = $code; |
|
271
|
|
|
} |
|
272
|
|
|
|
|
273
|
|
|
$this->resourceContext->visit('locale', $action, $parameters); |
|
|
|
|
|
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
/** |
|
277
|
|
|
* @param string $action |
|
278
|
|
|
* @param string|null $code |
|
279
|
|
|
*/ |
|
280
|
|
View Code Duplication |
private function assertAddress($action, $code = null) |
|
|
|
|
|
|
281
|
|
|
{ |
|
282
|
|
|
$parameters = []; |
|
283
|
|
|
|
|
284
|
|
|
if ($code !== null) { |
|
285
|
|
|
$parameters['code'] = $code; |
|
286
|
|
|
} |
|
287
|
|
|
|
|
288
|
|
|
$this->resourceContext->assertAddress('locale', $action, $parameters); |
|
|
|
|
|
|
289
|
|
|
} |
|
290
|
|
|
} |
|
291
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: