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\Page\Admin\ProductVariant; |
13
|
|
|
|
14
|
|
|
use Sylius\Behat\Behaviour\ChecksCodeImmutability; |
15
|
|
|
use Sylius\Behat\Page\Admin\Crud\UpdatePage as BaseUpdatePage; |
16
|
|
|
use Sylius\Component\Core\Model\ChannelInterface; |
17
|
|
|
use Sylius\Component\Currency\Model\CurrencyInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @author Łukasz Chruściel <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class UpdatePage extends BaseUpdatePage implements UpdatePageInterface |
23
|
|
|
{ |
24
|
|
|
use ChecksCodeImmutability; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* {@inheritdoc} |
28
|
|
|
*/ |
29
|
|
|
protected function getCodeElement() |
30
|
|
|
{ |
31
|
|
|
return $this->getElement('code'); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
|
|
public function specifyPrice($price) |
38
|
|
|
{ |
39
|
|
|
$this->getDocument()->fillField('Price', $price); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function disableTracking() |
43
|
|
|
{ |
44
|
|
|
$this->getElement('tracked')->uncheck(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function enableTracking() |
48
|
|
|
{ |
49
|
|
|
$this->getElement('tracked')->check(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* {@inheritdoc} |
54
|
|
|
*/ |
55
|
|
|
public function isTracked() |
56
|
|
|
{ |
57
|
|
|
return $this->getElement('tracked')->isChecked(); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* {@inheritdoc} |
62
|
|
|
*/ |
63
|
|
|
public function getPricingConfigurationForChannelAndCurrencyCalculator(ChannelInterface $channel, CurrencyInterface $currency) |
64
|
|
|
{ |
65
|
|
|
$priceElement = $this->getElement('pricing_configuration')->find('css', sprintf('label:contains("%s %s")', $channel->getCode(), $currency->getCode()))->getParent(); |
66
|
|
|
|
67
|
|
|
return $priceElement->find('css', 'input')->getValue(); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* {@inheritdoc} |
72
|
|
|
*/ |
73
|
|
|
protected function getDefinedElements() |
74
|
|
|
{ |
75
|
|
|
return array_merge(parent::getDefinedElements(), [ |
76
|
|
|
'code' => '#sylius_product_variant_code', |
77
|
|
|
'price' => '#sylius_product_variant_price', |
78
|
|
|
'pricing_configuration' => '#sylius_calculator_container', |
79
|
|
|
'tracked' => '#sylius_product_variant_tracked', |
80
|
|
|
]); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|