Completed
Push — master ( cb017b...970228 )
by Paweł
30:33 queued 20:21
created

ManagingProductVariantsContext   B

Complexity

Total Complexity 50

Size/Duplication

Total Lines 501
Duplicated Lines 0 %

Coupling/Cohesion

Components 4
Dependencies 12

Importance

Changes 0
Metric Value
wmc 50
lcom 4
cbo 12
dl 0
loc 501
rs 8.6206
c 0
b 0
f 0

49 Methods

Rating   Name   Duplication   Size   Complexity  
A iSetItsDimensionsTo() 0 4 1
A iDoNetSetItsCurrentStockTo() 0 4 1
A iChooseCalculator() 0 4 1
A iSetItsOptionAs() 0 4 1
A __construct() 0 17 1
A iWantToCreateANewProduct() 0 4 1
A iSpecifyItsCodeAs() 0 4 1
A iNameItIn() 0 4 1
A iRenameItTo() 0 4 1
A iAddIt() 0 4 1
A iDisableItsTracking() 0 4 1
A iEnableItsTracking() 0 4 1
A iSetItsPriceTo() 0 4 2
A iSetItsOriginalPriceTo() 0 4 1
A iSetThePositionOfTo() 0 4 1
A iSaveMyNewConfiguration() 0 4 1
A theVariantWithCodeShouldBePricedAtForChannel() 0 6 1
A theVariantWithCodeShouldBeNamedIn() 0 6 1
A theVariantWithCodeShouldHaveAnOriginalPriceOfForChannel() 0 9 1
A iDeleteTheVariantOfProduct() 0 6 1
A iShouldBeNotifiedOfFailure() 0 7 1
A iWantToModifyAProduct() 0 4 1
A theCodeFieldShouldBeDisabled() 0 4 1
A iShouldBeNotifiedThatIsRequired() 0 4 1
A iShouldBeNotifiedThatCodeHasToBeUnique() 0 4 1
A iShouldBeNotifiedThatOnHandIsRequired() 0 4 1
A iShouldBeNotifiedThatIsHeightWidthDepthWeightCannotBeLowerThan() 0 7 1
A iShouldBeNotifiedThatPriceCannotBeLowerThen() 0 7 1
A iShouldBeNotifiedThatThisVariantAlreadyExists() 0 7 1
A iShouldBeNotifiedThatCodeIsRequiredForVariant() 0 7 1
A iShouldBeNotifiedThatPricesInAllChannelsMustBeDefinedForTheVariant() 0 7 1
A iShouldBeNotifiedThatVariantCodeMustBeUniqueWithinThisProductForYheVariant() 0 7 1
A iShouldBeNotifiedThatPricesInAllChannelsMustBeDefined() 0 7 1
A iSaveMyChanges() 0 4 1
A iRemoveItsNameFromTranslation() 0 4 1
A thisProductVariantShouldNotBeTracked() 0 6 1
A thisProductVariantShouldBeTracked() 0 6 1
A iWantToGenerateNewVariantsForThisProduct() 0 4 1
A iClickGenerate() 0 4 1
A iSpecifyThereAreVariantsIdentifiedByCodeWithCost() 0 5 1
A iSpecifyThereAreVariantsIdentifiedByCode() 0 4 1
A iSpecifyThereAreVariantsWithCost() 0 4 1
A iRemoveVariantFromTheList() 0 4 1
A iShouldBeNotifiedThatItHasBeenSuccessfullyGenerated() 0 4 1
A iSetItsShippingCategoryAs() 0 4 1
A iDoNotSpecifyAnyInformationAboutVariants() 0 4 1
A iChangeItsQuantityOfInventoryTo() 0 4 1
A iShouldBeNotifiedThatOnHandQuantityMustBeGreaterThanTheNumberOfOnHoldUnits() 0 7 1
A assertValidationMessage() 0 7 1

How to fix   Complexity   

Complex Class

Complex classes like ManagingProductVariantsContext often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use ManagingProductVariantsContext, and based on these observations, apply Extract Interface, too.

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\NotificationType;
16
use Sylius\Behat\Page\Admin\ProductVariant\CreatePageInterface;
17
use Sylius\Behat\Page\Admin\ProductVariant\GeneratePageInterface;
18
use Sylius\Behat\Page\Admin\ProductVariant\IndexPageInterface;
19
use Sylius\Behat\Page\Admin\ProductVariant\UpdatePageInterface;
20
use Sylius\Behat\Service\NotificationCheckerInterface;
21
use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface;
22
use Sylius\Behat\Service\SharedStorageInterface;
23
use Sylius\Component\Core\Model\ProductInterface;
24
use Sylius\Component\Core\Model\ProductVariantInterface;
25
use Webmozart\Assert\Assert;
26
27
/**
28
 * @author Łukasz Chruściel <[email protected]>
29
 * @author Gorka Laucirica <[email protected]>
30
 */
31
final class ManagingProductVariantsContext implements Context
32
{
33
    /**
34
     * @var SharedStorageInterface
35
     */
36
    private $sharedStorage;
37
38
    /**
39
     * @var CreatePageInterface
40
     */
41
    private $createPage;
42
43
    /**
44
     * @var IndexPageInterface
45
     */
46
    private $indexPage;
47
48
    /**
49
     * @var UpdatePageInterface
50
     */
51
    private $updatePage;
52
53
    /**
54
     * @var GeneratePageInterface
55
     */
56
    private $generatePage;
57
58
    /**
59
     * @var CurrentPageResolverInterface
60
     */
61
    private $currentPageResolver;
62
63
    /**
64
     * @var NotificationCheckerInterface
65
     */
66
    private $notificationChecker;
67
68
    /**
69
     * @param SharedStorageInterface $sharedStorage
70
     * @param CreatePageInterface $createPage
71
     * @param IndexPageInterface $indexPage
72
     * @param UpdatePageInterface $updatePage
73
     * @param GeneratePageInterface $generatePage
74
     * @param CurrentPageResolverInterface $currentPageResolver
75
     * @param NotificationCheckerInterface $notificationChecker
76
     */
77
    public function __construct(
78
        SharedStorageInterface $sharedStorage,
79
        CreatePageInterface $createPage,
80
        IndexPageInterface $indexPage,
81
        UpdatePageInterface $updatePage,
82
        GeneratePageInterface $generatePage,
83
        CurrentPageResolverInterface $currentPageResolver,
84
        NotificationCheckerInterface $notificationChecker
85
    ) {
86
        $this->sharedStorage = $sharedStorage;
87
        $this->createPage = $createPage;
88
        $this->indexPage = $indexPage;
89
        $this->updatePage = $updatePage;
90
        $this->generatePage = $generatePage;
91
        $this->currentPageResolver = $currentPageResolver;
92
        $this->notificationChecker = $notificationChecker;
93
    }
94
95
    /**
96
     * @Given /^I want to create a new variant of (this product)$/
97
     */
98
    public function iWantToCreateANewProduct(ProductInterface $product)
99
    {
100
        $this->createPage->open(['productId' => $product->getId()]);
101
    }
102
103
    /**
104
     * @When I specify its code as :code
105
     * @When I do not specify its code
106
     */
107
    public function iSpecifyItsCodeAs($code = null)
108
    {
109
        $this->createPage->specifyCode($code);
110
    }
111
112
    /**
113
     * @When I name it :name in :language
114
     */
115
    public function iNameItIn($name, $language)
116
    {
117
        $this->createPage->nameItIn($name, $language);
118
    }
119
120
    /**
121
     * @When I rename it to :name
122
     */
123
    public function iRenameItTo($name)
124
    {
125
        $this->updatePage->nameIt($name);
0 ignored issues
show
Bug introduced by
The method nameIt() does not seem to exist on object<Sylius\Behat\Page...nt\UpdatePageInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
126
    }
127
128
    /**
129
     * @When I add it
130
     * @When I try to add it
131
     */
132
    public function iAddIt()
133
    {
134
        $this->createPage->create();
135
    }
136
137
    /**
138
     * @When I disable its inventory tracking
139
     */
140
    public function iDisableItsTracking()
141
    {
142
        $this->updatePage->disableTracking();
143
    }
144
145
    /**
146
     * @When I enable its inventory tracking
147
     */
148
    public function iEnableItsTracking()
149
    {
150
        $this->updatePage->enableTracking();
151
    }
152
153
    /**
154
     * @When /^I set its(?:| default) price to "(?:€|£|\$)([^"]+)" for "([^"]+)" channel$/
155
     * @When I do not set its price
156
     */
157
    public function iSetItsPriceTo($price = null, $channelName = null)
158
    {
159
        $this->createPage->specifyPrice($price, (null === $channelName) ? $this->sharedStorage->get('channel') :$channelName);
160
    }
161
162
    /**
163
     * @When /^I set its original price to "(?:€|£|\$)([^"]+)" for "([^"]+)" channel$/
164
     */
165
    public function iSetItsOriginalPriceTo($originalPrice, $channelName)
166
    {
167
        $this->createPage->specifyOriginalPrice($originalPrice, $channelName);
168
    }
169
170
    /**
171
     * @When I set its height, width, depth and weight to :number
172
     */
173
    public function iSetItsDimensionsTo($value)
174
    {
175
        $this->createPage->specifyHeightWidthDepthAndWeight($value, $value, $value, $value);
176
    }
177
178
    /**
179
     * @When I do not specify its current stock
180
     */
181
    public function iDoNetSetItsCurrentStockTo()
182
    {
183
        $this->createPage->specifyCurrentStock('');
184
    }
185
186
    /**
187
     * @When I choose :calculatorName calculator
188
     */
189
    public function iChooseCalculator($calculatorName)
190
    {
191
        $this->createPage->choosePricingCalculator($calculatorName);
192
    }
193
194
    /**
195
     * @When I set its :optionName option to :optionValue
196
     */
197
    public function iSetItsOptionAs($optionName, $optionValue)
198
    {
199
        $this->createPage->selectOption($optionName, $optionValue);
200
    }
201
202
    /**
203
     * @When I set the position of :name to :position
204
     */
205
    public function iSetThePositionOfTo($name, $position)
206
    {
207
        $this->indexPage->setPosition($name, (int) $position);
208
    }
209
210
    /**
211
     * @When I save my new configuration
212
     */
213
    public function iSaveMyNewConfiguration()
214
    {
215
        $this->indexPage->savePositions();
216
    }
217
218
    /**
219
     * @Then /^the (variant with code "[^"]+") should be priced at (?:€|£|\$)([^"]+) for channel "([^"]+)"$/
220
     */
221
    public function theVariantWithCodeShouldBePricedAtForChannel(ProductVariantInterface $productVariant, $price, $channelName)
222
    {
223
        $this->updatePage->open(['id' => $productVariant->getId(), 'productId' => $productVariant->getProduct()->getId()]);
224
225
        Assert::same($this->updatePage->getPriceForChannel($channelName), $price);
226
    }
227
228
    /**
229
     * @Then /^the (variant with code "[^"]+") should be named "([^"]+)" in ("([^"]+)" locale)$/
230
     */
231
    public function theVariantWithCodeShouldBeNamedIn(ProductVariantInterface $productVariant, $name, $language)
232
    {
233
        $this->updatePage->open(['id' => $productVariant->getId(), 'productId' => $productVariant->getProduct()->getId()]);
234
235
        Assert::same($this->updatePage->getNameInLanguage($language), $name);
236
    }
237
238
    /**
239
     * @Then /^the (variant with code "[^"]+") should have an original price of (?:€|£|\$)([^"]+) for channel "([^"]+)"$/
240
     */
241
    public function theVariantWithCodeShouldHaveAnOriginalPriceOfForChannel(ProductVariantInterface $productVariant, $originalPrice, $channelName)
242
    {
243
        $this->updatePage->open(['id' => $productVariant->getId(), 'productId' => $productVariant->getProduct()->getId()]);
244
245
        Assert::same(
246
            $this->updatePage->getOriginalPriceForChannel($channelName),
247
            $originalPrice
248
        );
249
    }
250
251
    /**
252
     * @When /^I delete the ("[^"]+" variant of product "[^"]+")$/
253
     * @When /^I try to delete the ("[^"]+" variant of product "[^"]+")$/
254
     */
255
    public function iDeleteTheVariantOfProduct(ProductVariantInterface $productVariant)
256
    {
257
        $this->indexPage->open(['productId' => $productVariant->getProduct()->getId()]);
258
259
        $this->indexPage->deleteResourceOnPage(['code' => $productVariant->getCode()]);
260
    }
261
262
    /**
263
     * @Then I should be notified that this variant is in use and cannot be deleted
264
     */
265
    public function iShouldBeNotifiedOfFailure()
266
    {
267
        $this->notificationChecker->checkNotification(
268
            'Cannot delete, the product variant is in use.',
269
            NotificationType::failure()
270
        );
271
    }
272
273
    /**
274
     * @When /^I want to modify the ("[^"]+" product variant)$/
275
     */
276
    public function iWantToModifyAProduct(ProductVariantInterface $productVariant)
277
    {
278
        $this->updatePage->open(['id' => $productVariant->getId(), 'productId' => $productVariant->getProduct()->getId()]);
279
    }
280
281
    /**
282
     * @Then the code field should be disabled
283
     */
284
    public function theCodeFieldShouldBeDisabled()
285
    {
286
        Assert::true($this->updatePage->isCodeDisabled());
287
    }
288
289
    /**
290
     * @Then I should be notified that :element is required
291
     */
292
    public function iShouldBeNotifiedThatIsRequired($element)
293
    {
294
        $this->assertValidationMessage($element, sprintf('Please enter the %s.', $element));
295
    }
296
297
    /**
298
     * @Then I should be notified that code has to be unique
299
     */
300
    public function iShouldBeNotifiedThatCodeHasToBeUnique()
301
    {
302
        $this->assertValidationMessage('code', 'Product variant code must be unique.');
303
    }
304
305
    /**
306
     * @Then I should be notified that current stock is required
307
     */
308
    public function iShouldBeNotifiedThatOnHandIsRequired()
309
    {
310
        $this->assertValidationMessage('on_hand', 'Please enter on hand.');
311
    }
312
313
    /**
314
     * @Then I should be notified that height, width, depth and weight cannot be lower than 0
315
     */
316
    public function iShouldBeNotifiedThatIsHeightWidthDepthWeightCannotBeLowerThan()
317
    {
318
        $this->assertValidationMessage('height', 'Height cannot be negative.');
319
        $this->assertValidationMessage('width', 'Width cannot be negative.');
320
        $this->assertValidationMessage('depth', 'Depth cannot be negative.');
321
        $this->assertValidationMessage('weight', 'Weight cannot be negative.');
322
    }
323
324
    /**
325
     * @Then I should be notified that price cannot be lower than 0.01
326
     */
327
    public function iShouldBeNotifiedThatPriceCannotBeLowerThen()
328
    {
329
        /** @var CreatePageInterface|UpdatePageInterface $currentPage */
330
        $currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]);
331
332
        Assert::contains($currentPage->getPricesValidationMessage(), 'Price must be at least 0.01.');
0 ignored issues
show
Bug introduced by
The method getPricesValidationMessage does only exist in Sylius\Behat\Page\Admin\...ant\CreatePageInterface, but not in Sylius\Behat\Page\Admin\...ant\UpdatePageInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
333
    }
334
335
    /**
336
     * @Then I should be notified that this variant already exists
337
     */
338
    public function iShouldBeNotifiedThatThisVariantAlreadyExists()
339
    {
340
        /** @var CreatePageInterface|UpdatePageInterface $currentPage */
341
        $currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]);
342
343
        Assert::same($currentPage->getValidationMessageForForm(), 'Variant with this option set already exists.');
0 ignored issues
show
Bug introduced by
The method getValidationMessageForForm does only exist in Sylius\Behat\Page\Admin\...ant\CreatePageInterface, but not in Sylius\Behat\Page\Admin\...ant\UpdatePageInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
344
    }
345
346
    /**
347
     * @Then /^I should be notified that code is required for the (\d)(?:st|nd|rd|th) variant$/
348
     */
349
    public function iShouldBeNotifiedThatCodeIsRequiredForVariant($position)
350
    {
351
        Assert::same(
352
            $this->generatePage->getValidationMessage('code', $position - 1),
353
            'Please enter the code.'
354
        );
355
    }
356
357
    /**
358
     * @Then /^I should be notified that prices in all channels must be defined for the (\d)(?:st|nd|rd|th) variant$/
359
     */
360
    public function iShouldBeNotifiedThatPricesInAllChannelsMustBeDefinedForTheVariant($position)
361
    {
362
        Assert::same(
363
            $this->generatePage->getPricesValidationMessage($position - 1),
364
            'You must define price for every channel.'
365
        );
366
    }
367
368
    /**
369
     * @Then /^I should be notified that variant code must be unique within this product for the (\d)(?:st|nd|rd|th) variant$/
370
     */
371
    public function iShouldBeNotifiedThatVariantCodeMustBeUniqueWithinThisProductForYheVariant($position)
372
    {
373
        Assert::same(
374
            $this->generatePage->getValidationMessage('code', $position - 1),
375
            'This code must be unique within this product.'
376
        );
377
    }
378
379
    /**
380
     * @Then I should be notified that prices in all channels must be defined
381
     */
382
    public function iShouldBeNotifiedThatPricesInAllChannelsMustBeDefined()
383
    {
384
        Assert::contains(
385
            $this->createPage->getPricesValidationMessage(),
386
            'You must define price for every channel.'
387
        );
388
    }
389
390
    /**
391
     * @When I save my changes
392
     * @When I try to save my changes
393
     */
394
    public function iSaveMyChanges()
395
    {
396
        $this->updatePage->saveChanges();
397
    }
398
399
    /**
400
     * @When I remove its name
401
     */
402
    public function iRemoveItsNameFromTranslation()
403
    {
404
        $this->updatePage->nameIt('');
0 ignored issues
show
Bug introduced by
The method nameIt() does not seem to exist on object<Sylius\Behat\Page...nt\UpdatePageInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
405
    }
406
407
    /**
408
     * @Then /^inventory of (this variant) should not be tracked$/
409
     */
410
    public function thisProductVariantShouldNotBeTracked(ProductVariantInterface $productVariant)
411
    {
412
        $this->iWantToModifyAProduct($productVariant);
413
414
        Assert::false($this->updatePage->isTracked());
415
    }
416
417
    /**
418
     * @Then /^inventory of (this variant) should be tracked$/
419
     */
420
    public function thisProductVariantShouldBeTracked(ProductVariantInterface $productVariant)
421
    {
422
        $this->iWantToModifyAProduct($productVariant);
423
424
        Assert::true($this->updatePage->isTracked());
425
    }
426
427
    /**
428
     * @When /^I want to generate new variants for (this product)$/
429
     */
430
    public function iWantToGenerateNewVariantsForThisProduct(ProductInterface $product)
431
    {
432
        $this->generatePage->open(['productId' => $product->getId()]);
433
    }
434
435
    /**
436
     * @When I generate it
437
     * @When I try to generate it
438
     */
439
    public function iClickGenerate()
440
    {
441
        $this->generatePage->generate();
442
    }
443
444
    /**
445
     * @When /^I specify that the (\d)(?:st|nd|rd|th) variant is identified by "([^"]+)" code and costs "(?:€|£|\$)([^"]+)" in ("[^"]+") channel$/
446
     */
447
    public function iSpecifyThereAreVariantsIdentifiedByCodeWithCost($nthVariant, $code, $price, $channelName)
448
    {
449
        $this->generatePage->specifyCode($nthVariant - 1, $code);
450
        $this->generatePage->specifyPrice($nthVariant - 1, $price, $channelName);
451
    }
452
453
    /**
454
     * @When /^I specify that the (\d)(?:st|nd|rd|th) variant is identified by "([^"]+)" code$/
455
     */
456
    public function iSpecifyThereAreVariantsIdentifiedByCode($nthVariant, $code)
457
    {
458
        $this->generatePage->specifyCode($nthVariant - 1, $code);
459
    }
460
461
    /**
462
     * @When /^I specify that the (\d)(?:st|nd|rd|th) variant costs "(?:€|£|\$)([^"]+)" in ("[^"]+") channel$/
463
     */
464
    public function iSpecifyThereAreVariantsWithCost($nthVariant, $price, $channelName)
465
    {
466
        $this->generatePage->specifyPrice($nthVariant - 1, $price, $channelName);
467
    }
468
469
    /**
470
     * @When /^I remove (\d)(?:st|nd|rd|th) variant from the list$/
471
     */
472
    public function iRemoveVariantFromTheList($nthVariant)
473
    {
474
        $this->generatePage->removeVariant($nthVariant - 1);
475
    }
476
477
    /**
478
     * @Then I should be notified that it has been successfully generated
479
     */
480
    public function iShouldBeNotifiedThatItHasBeenSuccessfullyGenerated()
481
    {
482
        $this->notificationChecker->checkNotification('Success Product variants have been successfully generated.', NotificationType::success());
483
    }
484
485
    /**
486
     * @When I set its shipping category as :shippingCategoryName
487
     */
488
    public function iSetItsShippingCategoryAs($shippingCategoryName)
489
    {
490
        $this->createPage->selectShippingCategory($shippingCategoryName);
491
    }
492
493
    /**
494
     * @When I do not specify any information about variants
495
     */
496
    public function iDoNotSpecifyAnyInformationAboutVariants()
497
    {
498
        // Intentionally left blank to fulfill context expectation
499
    }
500
501
    /**
502
     * @When I change its quantity of inventory to :amount
503
     */
504
    public function iChangeItsQuantityOfInventoryTo($amount)
505
    {
506
        $this->updatePage->specifyCurrentStock($amount);
507
    }
508
509
    /**
510
     * @Then I should be notified that on hand quantity must be greater than the number of on hold units
511
     */
512
    public function iShouldBeNotifiedThatOnHandQuantityMustBeGreaterThanTheNumberOfOnHoldUnits()
513
    {
514
        Assert::same(
515
            $this->updatePage->getValidationMessage('on_hand'),
516
            'On hand must be greater than the number of on hold units'
517
        );
518
    }
519
520
    /**
521
     * @param string $element
522
     * @param $message
523
     */
524
    private function assertValidationMessage($element, $message)
525
    {
526
        /** @var CreatePageInterface|UpdatePageInterface $currentPage */
527
        $currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]);
528
529
        Assert::same($currentPage->getValidationMessage($element), $message);
530
    }
531
}
532