Completed
Push — master ( a9aa0c...602f1d )
by Kamil
26:22 queued 09:35
created

ShowPage::showVariantEditPage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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\Page\Admin\Product;
15
16
use FriendsOfBehat\PageObjectExtension\Page\SymfonyPage;
17
use Sylius\Component\Core\Model\ProductVariantInterface;
18
19
class ShowPage extends SymfonyPage implements ShowPageInterface
20
{
21
    public function isSimpleProductPage(): bool
22
    {
23
        return !$this->hasElement('variants');
24
    }
25
26
    public function isShowInShopButtonDisabled(): bool
27
    {
28
        return $this->getElement('show_product_single_button')->hasClass('disabled');
29
    }
30
31
    public function getName(): string
32
    {
33
        return $this->getElement('product_name')->getText();
34
    }
35
36
    public function getRouteName(): string
37
    {
38
        return 'sylius_admin_product_show';
39
    }
40
41
    public function showProductInChannel(string $channel): void
42
    {
43
        $this->getElement('show_product_dropdown')->clickLink($channel);
44
    }
45
46
    public function showProductInSingleChannel(): void
47
    {
48
        $this->getElement('show_product_single_button')->click();
49
    }
50
51
    public function showProductEditPage(): void
52
    {
53
        $this->getElement('edit_product_button')->click();
54
    }
55
56
    public function showVariantEditPage(ProductVariantInterface $variant): void
57
    {
58
        $this->getElement('edit_variant_button', ['%variantCode%' => $variant->getCode()])->click();
59
    }
60
61
    protected function getDefinedElements(): array
62
    {
63
        return array_merge(parent::getDefinedElements(), [
64
            'edit_product_button' => '#edit-product',
65
            'edit_variant_button' => '#variants .variants-accordion__title:contains("%variantCode%") .edit-variant',
66
            'product_name' => '#header h1 .content > span',
67
            'show_product_dropdown' => '.scrolling.menu',
68
            'show_product_single_button' => '.ui.labeled.icon.button',
69
            'variants' => '#variants',
70
        ]);
71
    }
72
}
73