|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Sylius\Behat\Context\Ui\Admin; |
|
13
|
|
|
|
|
14
|
|
|
use Behat\Behat\Context\Context; |
|
15
|
|
|
use Sylius\Behat\Page\Admin\Taxon\CreateForParentPageInterface; |
|
16
|
|
|
use Sylius\Behat\Page\Admin\Taxon\CreatePageInterface; |
|
17
|
|
|
use Sylius\Behat\Page\Admin\Taxon\UpdatePageInterface; |
|
18
|
|
|
use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface; |
|
19
|
|
|
use Sylius\Behat\Service\SharedStorageInterface; |
|
20
|
|
|
use Sylius\Component\Core\Model\Taxon; |
|
21
|
|
|
use Sylius\Component\Core\Model\TaxonInterface; |
|
22
|
|
|
use Webmozart\Assert\Assert; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @author Arkadiusz Krakowiak <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
final class ManagingTaxonsContext implements Context |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* @var SharedStorageInterface |
|
31
|
|
|
*/ |
|
32
|
|
|
private $sharedStorage; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var CreatePageInterface |
|
36
|
|
|
*/ |
|
37
|
|
|
private $createPage; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var CreateForParentPageInterface |
|
41
|
|
|
*/ |
|
42
|
|
|
private $createForParentPage; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var UpdatePageInterface |
|
46
|
|
|
*/ |
|
47
|
|
|
private $updatePage; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var CurrentPageResolverInterface |
|
51
|
|
|
*/ |
|
52
|
|
|
private $currentPageResolver; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param SharedStorageInterface $sharedStorage |
|
56
|
|
|
* @param CreatePageInterface $createPage |
|
57
|
|
|
* @param CreateForParentPageInterface $createForParentPage |
|
58
|
|
|
* @param UpdatePageInterface $updatePage |
|
59
|
|
|
* @param CurrentPageResolverInterface $currentPageResolver |
|
60
|
|
|
*/ |
|
61
|
|
|
public function __construct( |
|
62
|
|
|
SharedStorageInterface $sharedStorage, |
|
63
|
|
|
CreatePageInterface $createPage, |
|
64
|
|
|
CreateForParentPageInterface $createForParentPage, |
|
65
|
|
|
UpdatePageInterface $updatePage, |
|
66
|
|
|
CurrentPageResolverInterface $currentPageResolver |
|
67
|
|
|
) { |
|
68
|
|
|
$this->sharedStorage = $sharedStorage; |
|
69
|
|
|
$this->createPage = $createPage; |
|
70
|
|
|
$this->createForParentPage = $createForParentPage; |
|
71
|
|
|
$this->updatePage = $updatePage; |
|
72
|
|
|
$this->currentPageResolver = $currentPageResolver; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @Given I want to create a new taxon |
|
77
|
|
|
* @Given I want to see all taxons in store |
|
78
|
|
|
*/ |
|
79
|
|
|
public function iWantToCreateANewTaxon() |
|
80
|
|
|
{ |
|
81
|
|
|
$this->createPage->open(); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @Given I want to create a new taxon for :taxon |
|
86
|
|
|
*/ |
|
87
|
|
|
public function iWantToCreateANewTaxonForParent(TaxonInterface $taxon) |
|
88
|
|
|
{ |
|
89
|
|
|
$this->createForParentPage->open(['id' => $taxon->getId()]); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @Given /^I want to modify the ("[^"]+" taxon)$/ |
|
94
|
|
|
*/ |
|
95
|
|
|
public function iWantToModifyATaxon(TaxonInterface $taxon) |
|
96
|
|
|
{ |
|
97
|
|
|
$this->sharedStorage->set('taxon', $taxon); |
|
98
|
|
|
|
|
99
|
|
|
$this->updatePage->open(['id' => $taxon->getId()]); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @When I specify its code as :code |
|
104
|
|
|
*/ |
|
105
|
|
|
public function iSpecifyItsCodeAs($code) |
|
106
|
|
|
{ |
|
107
|
|
|
$this->createPage->specifyCode($code); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @When I name it :name in :language |
|
112
|
|
|
*/ |
|
113
|
|
|
public function iNameItIn($name, $language) |
|
114
|
|
|
{ |
|
115
|
|
|
$this->createPage->nameIt($name, $language); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @When I rename it to :name in :language |
|
120
|
|
|
*/ |
|
121
|
|
|
public function iRenameItIn($name, $language) |
|
122
|
|
|
{ |
|
123
|
|
|
$this->updatePage->nameIt($name, $language); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* @When I set its slug to :slug |
|
128
|
|
|
* @When I do not specify its slug |
|
129
|
|
|
*/ |
|
130
|
|
|
public function iSetItsSlugTo($slug = null) |
|
131
|
|
|
{ |
|
132
|
|
|
/** @var CreatePageInterface|UpdatePageInterface $currentPage */ |
|
133
|
|
|
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([ |
|
134
|
|
|
$this->createPage, |
|
135
|
|
|
$this->createForParentPage, |
|
136
|
|
|
$this->updatePage, |
|
137
|
|
|
]); |
|
138
|
|
|
|
|
139
|
|
|
$currentPage->specifySlug($slug); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* @Then the slug field should not be editable |
|
144
|
|
|
*/ |
|
145
|
|
|
public function theSlugFieldShouldNotBeEditable() |
|
146
|
|
|
{ |
|
147
|
|
|
Assert::true( |
|
148
|
|
|
$this->updatePage->isSlugReadOnly(), |
|
149
|
|
|
'Slug should be immutable, but it does not.' |
|
150
|
|
|
); |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* @When I enable slug modification |
|
155
|
|
|
*/ |
|
156
|
|
|
public function iEnableSlugModification() |
|
157
|
|
|
{ |
|
158
|
|
|
$this->updatePage->enableSlugModification(); |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* @When I change its description to :description in :language |
|
163
|
|
|
*/ |
|
164
|
|
|
public function iChangeItsDescriptionToIn($description, $language) |
|
165
|
|
|
{ |
|
166
|
|
|
$this->updatePage->describeItAs($description, $language); |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* @When I describe it as :description in :language |
|
171
|
|
|
*/ |
|
172
|
|
|
public function iDescribeItAs($description, $language) |
|
173
|
|
|
{ |
|
174
|
|
|
$this->createPage->describeItAs($description, $language); |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* @When /^I move up ("[^"]+" taxon)$/ |
|
179
|
|
|
*/ |
|
180
|
|
|
public function iWantToMoveUpTaxon(TaxonInterface $taxon) |
|
181
|
|
|
{ |
|
182
|
|
|
$this->createPage->moveUp($taxon); |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* @Given /^I choose ("[^"]+" as a parent taxon)$/ |
|
187
|
|
|
*/ |
|
188
|
|
|
public function iChooseAsAParentTaxon(TaxonInterface $taxon) |
|
189
|
|
|
{ |
|
190
|
|
|
$this->createPage->chooseParent($taxon); |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* @Given /^I change its (parent taxon to "[^"]+")$/ |
|
195
|
|
|
*/ |
|
196
|
|
|
public function iChangeItsParentTaxonTo(TaxonInterface $taxon) |
|
197
|
|
|
{ |
|
198
|
|
|
$this->updatePage->chooseParent($taxon); |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* @When I do not specify its code |
|
203
|
|
|
*/ |
|
204
|
|
|
public function iDoNotSpecifyItsCode() |
|
205
|
|
|
{ |
|
206
|
|
|
// Intentionally left blank to fulfill context expectation |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* @When I do not specify its name |
|
211
|
|
|
*/ |
|
212
|
|
|
public function iDoNotSpecifyItsName() |
|
213
|
|
|
{ |
|
214
|
|
|
// Intentionally left blank to fulfill context expectation |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
/** |
|
218
|
|
|
* @When I delete taxon named :name |
|
219
|
|
|
*/ |
|
220
|
|
|
public function iDeleteTaxonNamed($name) |
|
221
|
|
|
{ |
|
222
|
|
|
$this->createPage->open(); |
|
223
|
|
|
$this->createPage->deleteTaxonOnPageByName($name); |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
/** |
|
227
|
|
|
* @When I add it |
|
228
|
|
|
* @When I try to add it |
|
229
|
|
|
*/ |
|
230
|
|
|
public function iAddIt() |
|
231
|
|
|
{ |
|
232
|
|
|
$this->createPage->create(); |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
|
|
/** |
|
236
|
|
|
* @When I save my changes |
|
237
|
|
|
* @When I try to save my changes |
|
238
|
|
|
*/ |
|
239
|
|
|
public function iSaveMyChanges() |
|
240
|
|
|
{ |
|
241
|
|
|
$this->updatePage->saveChanges(); |
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
|
|
/** |
|
245
|
|
|
* @Then /^the ("[^"]+" taxon) should appear in the registry$/ |
|
246
|
|
|
*/ |
|
247
|
|
|
public function theTaxonShouldAppearInTheRegistry(TaxonInterface $taxon) |
|
248
|
|
|
{ |
|
249
|
|
|
$this->updatePage->open(['id' => $taxon->getId()]); |
|
250
|
|
|
Assert::true( |
|
251
|
|
|
$this->updatePage->hasResourceValues(['code' => $taxon->getCode()]), |
|
252
|
|
|
sprintf('Taxon %s should be in the registry.', $taxon->getName()) |
|
253
|
|
|
); |
|
254
|
|
|
} |
|
255
|
|
|
|
|
256
|
|
|
/** |
|
257
|
|
|
* @Then this taxon :element should be :value |
|
258
|
|
|
*/ |
|
259
|
|
|
public function thisTaxonElementShouldBe($element, $value) |
|
260
|
|
|
{ |
|
261
|
|
|
Assert::true( |
|
262
|
|
|
$this->updatePage->hasResourceValues([$element => $value]), |
|
263
|
|
|
sprintf('Taxon with %s should have %s value.', $element, $value) |
|
264
|
|
|
); |
|
265
|
|
|
} |
|
266
|
|
|
|
|
267
|
|
|
/** |
|
268
|
|
|
* @Then the code field should be disabled |
|
269
|
|
|
*/ |
|
270
|
|
|
public function theCodeFieldShouldBeDisabled() |
|
271
|
|
|
{ |
|
272
|
|
|
Assert::true( |
|
273
|
|
|
$this->updatePage->isCodeDisabled(), |
|
274
|
|
|
'Code field should be disabled but it is not.' |
|
275
|
|
|
); |
|
276
|
|
|
} |
|
277
|
|
|
|
|
278
|
|
|
/** |
|
279
|
|
|
* @Then /^the slug of the ("[^"]+" taxon) should(?:| still) be "([^"]+)"$/ |
|
280
|
|
|
*/ |
|
281
|
|
|
public function productSlugShouldBe(TaxonInterface $taxon, $slug) |
|
282
|
|
|
{ |
|
283
|
|
|
$this->updatePage->open(['id' => $taxon->getId()]); |
|
284
|
|
|
|
|
285
|
|
|
Assert::true( |
|
286
|
|
|
$this->updatePage->hasResourceValues(['slug' => $slug]), |
|
287
|
|
|
sprintf('Taxon\'s slug should be %s.', $slug) |
|
288
|
|
|
); |
|
289
|
|
|
} |
|
290
|
|
|
|
|
291
|
|
|
/** |
|
292
|
|
|
* @Then /^this taxon should (belongs to "[^"]+")$/ |
|
293
|
|
|
*/ |
|
294
|
|
|
public function thisTaxonShouldBelongsTo(TaxonInterface $taxon) |
|
295
|
|
|
{ |
|
296
|
|
|
Assert::eq( |
|
297
|
|
|
$this->updatePage->getParent(), |
|
298
|
|
|
$taxon->getName() |
|
299
|
|
|
); |
|
300
|
|
|
} |
|
301
|
|
|
|
|
302
|
|
|
/** |
|
303
|
|
|
* @Given it should not belong to any other taxon |
|
304
|
|
|
*/ |
|
305
|
|
|
public function itShouldNotBelongToAnyOtherTaxon() |
|
306
|
|
|
{ |
|
307
|
|
|
$parent = $this->updatePage->getParent(); |
|
308
|
|
|
|
|
309
|
|
|
Assert::isEmpty( |
|
310
|
|
|
$parent, |
|
311
|
|
|
sprintf('Current taxon should not belong to any other, but it does belong to "%s"', $parent) |
|
312
|
|
|
); |
|
313
|
|
|
} |
|
314
|
|
|
|
|
315
|
|
|
/** |
|
316
|
|
|
* @Then I should be notified that taxon with this code already exists |
|
317
|
|
|
*/ |
|
318
|
|
|
public function iShouldBeNotifiedThatTaxonWithThisCodeAlreadyExists() |
|
319
|
|
|
{ |
|
320
|
|
|
/** @var CreatePageInterface|UpdatePageInterface $currentPage */ |
|
321
|
|
|
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]); |
|
322
|
|
|
|
|
323
|
|
|
Assert::same($currentPage->getValidationMessage('code'), 'Taxon with given code already exists.'); |
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
|
|
/** |
|
327
|
|
|
* @Then I should be notified that taxon slug must be unique |
|
328
|
|
|
*/ |
|
329
|
|
|
public function iShouldBeNotifiedThatTaxonSlugMustBeUnique() |
|
330
|
|
|
{ |
|
331
|
|
|
/** @var CreatePageInterface|UpdatePageInterface $currentPage */ |
|
332
|
|
|
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]); |
|
333
|
|
|
|
|
334
|
|
|
Assert::same($currentPage->getValidationMessage('slug'), 'Taxon slug must be unique.'); |
|
335
|
|
|
} |
|
336
|
|
|
|
|
337
|
|
|
/** |
|
338
|
|
|
* @Then I should be notified that :element is required |
|
339
|
|
|
*/ |
|
340
|
|
|
public function iShouldBeNotifiedThatIsRequired($element) |
|
341
|
|
|
{ |
|
342
|
|
|
/** @var CreatePageInterface|UpdatePageInterface $currentPage */ |
|
343
|
|
|
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]); |
|
344
|
|
|
|
|
345
|
|
|
Assert::same($currentPage->getValidationMessage($element), sprintf('Please enter taxon %s.', $element)); |
|
346
|
|
|
} |
|
347
|
|
|
|
|
348
|
|
|
/** |
|
349
|
|
|
* @Then /^there should still be only one taxon with code "([^"]+)"$/ |
|
350
|
|
|
*/ |
|
351
|
|
|
public function thereShouldStillBeOnlyOneTaxonWithCode($code) |
|
352
|
|
|
{ |
|
353
|
|
|
Assert::true( |
|
354
|
|
|
$this->updatePage->hasResourceValues(['code' => $code]), |
|
355
|
|
|
sprintf('Taxon with code %s cannot be found.', $code) |
|
356
|
|
|
); |
|
357
|
|
|
} |
|
358
|
|
|
|
|
359
|
|
|
/** |
|
360
|
|
|
* @Then /^Taxon named "([^"]+)" should not be added$/ |
|
361
|
|
|
* @Then the taxon named :name should no longer exist in the registry |
|
362
|
|
|
*/ |
|
363
|
|
|
public function taxonNamedShouldNotBeAdded($name) |
|
364
|
|
|
{ |
|
365
|
|
|
Assert::eq( |
|
366
|
|
|
0, |
|
367
|
|
|
$this->createPage->countTaxonsByName($name), |
|
368
|
|
|
sprintf('Taxon %s should not exist.', $name) |
|
369
|
|
|
); |
|
370
|
|
|
} |
|
371
|
|
|
|
|
372
|
|
|
/** |
|
373
|
|
|
* @Then /^I should see (\d+) taxons on the list$/ |
|
374
|
|
|
*/ |
|
375
|
|
|
public function iShouldSeeTaxonsInTheList($number) |
|
376
|
|
|
{ |
|
377
|
|
|
$taxonsOnPage = $this->createPage->countTaxons(); |
|
378
|
|
|
|
|
379
|
|
|
Assert::same( |
|
380
|
|
|
(int) $number, |
|
381
|
|
|
$taxonsOnPage, |
|
382
|
|
|
sprintf('On list should be %d taxons but get %d.', $number, $taxonsOnPage) |
|
383
|
|
|
); |
|
384
|
|
|
} |
|
385
|
|
|
|
|
386
|
|
|
/** |
|
387
|
|
|
* @Then I should see the taxon named :name in the list |
|
388
|
|
|
*/ |
|
389
|
|
|
public function iShouldSeeTheTaxonNamedInTheList($name) |
|
390
|
|
|
{ |
|
391
|
|
|
Assert::eq( |
|
392
|
|
|
1, |
|
393
|
|
|
$this->createPage->countTaxonsByName($name), |
|
394
|
|
|
sprintf('Taxon %s does not exist or multiple taxons with this name exist.', $name) |
|
395
|
|
|
); |
|
396
|
|
|
} |
|
397
|
|
|
|
|
398
|
|
|
/** |
|
399
|
|
|
* @When I attach the :path image with a code :code |
|
400
|
|
|
*/ |
|
401
|
|
|
public function iAttachImageWithACode($path, $code) |
|
402
|
|
|
{ |
|
403
|
|
|
/** @var CreatePageInterface|UpdatePageInterface $currentPage */ |
|
404
|
|
|
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]); |
|
405
|
|
|
|
|
406
|
|
|
$currentPage->attachImage($path, $code); |
|
407
|
|
|
} |
|
408
|
|
|
|
|
409
|
|
|
/** |
|
410
|
|
|
* @When I attach the :path image without a code |
|
411
|
|
|
*/ |
|
412
|
|
|
public function iAttachImageWithoutACode($path) |
|
413
|
|
|
{ |
|
414
|
|
|
$this->updatePage->attachImage($path); |
|
415
|
|
|
} |
|
416
|
|
|
|
|
417
|
|
|
/** |
|
418
|
|
|
* @Then /^this taxon should have(?:| also) an image with a code "([^"]*)"$/ |
|
419
|
|
|
*/ |
|
420
|
|
|
public function thisTaxonShouldHaveAnImageWithCode($code) |
|
421
|
|
|
{ |
|
422
|
|
|
Assert::true( |
|
423
|
|
|
$this->updatePage->isImageWithCodeDisplayed($code), |
|
424
|
|
|
sprintf('Image with a code %s should have been displayed.', $code) |
|
425
|
|
|
); |
|
426
|
|
|
} |
|
427
|
|
|
|
|
428
|
|
|
/** |
|
429
|
|
|
* @Then /^this taxon should not have(?:| also) an image with a code "([^"]*)"$/ |
|
430
|
|
|
*/ |
|
431
|
|
|
public function thisTaxonShouldNotHaveAnImageWithCode($code) |
|
432
|
|
|
{ |
|
433
|
|
|
Assert::false( |
|
434
|
|
|
$this->updatePage->isImageWithCodeDisplayed($code), |
|
435
|
|
|
sprintf('Image with a code %s should not have been displayed.', $code) |
|
436
|
|
|
); |
|
437
|
|
|
} |
|
438
|
|
|
|
|
439
|
|
|
/** |
|
440
|
|
|
* @When /^I remove(?:| also) an image with a code "([^"]*)"$/ |
|
441
|
|
|
*/ |
|
442
|
|
|
public function iRemoveAnImageWithACode($code) |
|
443
|
|
|
{ |
|
444
|
|
|
$this->updatePage->removeImageWithCode($code); |
|
445
|
|
|
} |
|
446
|
|
|
|
|
447
|
|
|
/** |
|
448
|
|
|
* @When I remove the first image |
|
449
|
|
|
*/ |
|
450
|
|
|
public function iRemoveTheFirstImage() |
|
451
|
|
|
{ |
|
452
|
|
|
$this->updatePage->removeFirstImage(); |
|
453
|
|
|
} |
|
454
|
|
|
|
|
455
|
|
|
/** |
|
456
|
|
|
* @Then /^(this taxon) should not have any images$/ |
|
457
|
|
|
*/ |
|
458
|
|
|
public function thisTaxonShouldNotHaveImages(TaxonInterface $taxon) |
|
459
|
|
|
{ |
|
460
|
|
|
$this->iWantToModifyATaxon($taxon); |
|
461
|
|
|
|
|
462
|
|
|
Assert::eq( |
|
463
|
|
|
0, |
|
464
|
|
|
$this->updatePage->countImages(), |
|
465
|
|
|
'This taxon has %2$s, but it should not have.' |
|
466
|
|
|
); |
|
467
|
|
|
} |
|
468
|
|
|
|
|
469
|
|
|
/** |
|
470
|
|
|
* @When I change the image with the :code code to :path |
|
471
|
|
|
*/ |
|
472
|
|
|
public function iChangeItsImageToPathForTheCode($path, $code) |
|
473
|
|
|
{ |
|
474
|
|
|
$this->updatePage->changeImageWithCode($code, $path); |
|
475
|
|
|
} |
|
476
|
|
|
|
|
477
|
|
|
/** |
|
478
|
|
|
* @Then I should be notified that the image with this code already exists |
|
479
|
|
|
*/ |
|
480
|
|
|
public function iShouldBeNotifiedThatTheImageWithThisCodeAlreadyExists() |
|
481
|
|
|
{ |
|
482
|
|
|
Assert::same($this->updatePage->getValidationMessageForImage(), 'Image code must be unique within this taxon.'); |
|
483
|
|
|
} |
|
484
|
|
|
|
|
485
|
|
|
/** |
|
486
|
|
|
* @Then I should be notified that an image code is required |
|
487
|
|
|
*/ |
|
488
|
|
|
public function iShouldBeNotifiedThatAnImageCodeIsRequired() |
|
489
|
|
|
{ |
|
490
|
|
|
Assert::same( |
|
491
|
|
|
$this->updatePage->getValidationMessageForImage(), |
|
492
|
|
|
'Please enter an image code.' |
|
493
|
|
|
); |
|
494
|
|
|
} |
|
495
|
|
|
|
|
496
|
|
|
/** |
|
497
|
|
|
* @Then there should still be only one image in the :taxon taxon |
|
498
|
|
|
*/ |
|
499
|
|
|
public function thereShouldStillBeOnlyOneImageInThisTaxon(TaxonInterface $taxon) |
|
500
|
|
|
{ |
|
501
|
|
|
$this->iWantToModifyATaxon($taxon); |
|
502
|
|
|
|
|
503
|
|
|
Assert::eq( |
|
504
|
|
|
1, |
|
505
|
|
|
$this->updatePage->countImages(), |
|
506
|
|
|
'This taxon has %2$s images, but it should have only one.' |
|
507
|
|
|
); |
|
508
|
|
|
} |
|
509
|
|
|
|
|
510
|
|
|
/** |
|
511
|
|
|
* @Then the image code field should be disabled |
|
512
|
|
|
*/ |
|
513
|
|
|
public function theImageCodeFieldShouldBeDisabled() |
|
514
|
|
|
{ |
|
515
|
|
|
Assert::true( |
|
516
|
|
|
$this->updatePage->isImageCodeDisabled(), |
|
517
|
|
|
'Image code field should be disabled but it is not.' |
|
518
|
|
|
); |
|
519
|
|
|
} |
|
520
|
|
|
|
|
521
|
|
|
/** |
|
522
|
|
|
* @Then I should be notified that the :imageNumber image should have an unique code |
|
523
|
|
|
*/ |
|
524
|
|
|
public function iShouldBeNotifiedThatTheFirstImageShouldHaveAnUniqueCode($imageNumber) |
|
525
|
|
|
{ |
|
526
|
|
|
preg_match_all('!\d+!', $imageNumber, $matches); |
|
527
|
|
|
|
|
528
|
|
|
Assert::same( |
|
529
|
|
|
$this->updatePage->getValidationMessageForImageAtPlace(((int) $matches[0][0]) - 1), |
|
530
|
|
|
'Image code must be unique within this taxon.' |
|
531
|
|
|
); |
|
532
|
|
|
} |
|
533
|
|
|
|
|
534
|
|
|
/** |
|
535
|
|
|
* @Then the first taxon on the list should be :taxon |
|
536
|
|
|
*/ |
|
537
|
|
|
public function theFirstTaxonOnTheListShouldBe(TaxonInterface $taxon) |
|
538
|
|
|
{ |
|
539
|
|
|
Assert::same( |
|
540
|
|
|
$this->createPage->getFirstLeafName(), |
|
541
|
|
|
$taxon->getName(), |
|
542
|
|
|
sprintf( |
|
543
|
|
|
'Expected %s as a first taxon, but got %s.', |
|
544
|
|
|
$taxon->getName(), |
|
545
|
|
|
$this->createPage->getFirstLeafName() |
|
546
|
|
|
) |
|
547
|
|
|
); |
|
548
|
|
|
} |
|
549
|
|
|
|
|
550
|
|
|
/** |
|
551
|
|
|
* @Then they should have order like :firstTaxonName, :secondTaxonName, :thirdTaxonName and :fourthTaxonName |
|
552
|
|
|
*/ |
|
553
|
|
|
public function theyShouldHaveOrderLikeAnd(...$taxonsNames) |
|
554
|
|
|
{ |
|
555
|
|
|
$leaves = $this->createPage->getLeaves(); |
|
556
|
|
|
|
|
557
|
|
|
foreach ($leaves as $key => $leaf) { |
|
558
|
|
|
Assert::contains($taxonsNames[$key], $leaf->getText()); |
|
559
|
|
|
} |
|
560
|
|
|
} |
|
561
|
|
|
} |
|
562
|
|
|
|