Completed
Push — checkout-consistent-prices ( af49ca )
by Kamil
13:24
created

AttributesElement   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 19
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hasAttributeInLocale() 0 8 1
A getDefinedElements() 0 7 1
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
declare(strict_types=1);
13
14
namespace Sylius\Behat\Element\Product\ShowPage;
15
16
use FriendsOfBehat\PageObjectExtension\Element\Element;
17
18
final class AttributesElement extends Element implements AttributesElementInterface
19
{
20
    public function hasAttributeInLocale(string $attribute, string $locale, string $value): bool
21
    {
22
        $values = $this->getDocument()->find('css', sprintf('#attributes .tab.segment[data-tab="%s"]', $locale));
23
24
        $attributeValue = $values->find('css', sprintf('tr:contains("%s") td:nth-child(2)', $attribute))->getText();
25
26
        return $attributeValue === $value;
27
    }
28
29
    protected function getDefinedElements(): array
30
    {
31
        return array_merge(parent::getDefinedElements(), [
32
            'attribute_value_in_locale' => '.attributes:contains("%locale%") ~ table tr:contains("%attribute%") td:nth-child(2)',
33
            'attributes_in_locale' => '#attributes :contains("%locale%")',
34
        ]);
35
    }
36
}
37