Completed
Push — remove-content-bundle ( fd7705...1b4274 )
by Kamil
18:36
created

getPricingConfigurationForChannelAndCurrencyCalculator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
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