Completed
Pull Request — master (#45)
by Jan
02:36
created

CreatePage::getDefinedElements()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
namespace Tests\Lakion\CmsPlugin\Behat\Page\Admin\TaxonBlock;
4
5
use Behat\Mink\Driver\Selenium2Driver;
6
use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage;
7
use Sylius\Behat\Service\AutocompleteHelper;
8
9
class CreatePage extends BaseCreatePage implements CreatePageInterface
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function setBody($body)
15
    {
16
        $this->getSession()->getPage()->fillField('Body', $body);
17
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function setLink($link)
23
    {
24
        $this->getSession()->getPage()->fillField('Link', $link);
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function setName($name)
31
    {
32
        $this->getSession()->getPage()->fillField('Name', $name);
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function setTitle($title)
39
    {
40
        $this->getSession()->getPage()->fillField('Title', $title);
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function chooseTaxon($taxonName)
47
    {
48
        if ($this->getDriver() instanceof Selenium2Driver) {
49
            AutocompleteHelper::chooseValue($this->getSession(), $this->getElement('taxon'), $taxonName);
50
        }
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function attachImage($relativePath)
57
    {
58
        $this->getSession()->getPage()->attachFileToField('Image', (string) $this->getParameter('files_path') . $relativePath);
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    protected function getDefinedElements()
65
    {
66
        return array_merge(parent::getDefinedElements(), [
67
            'body' => '#lakion_cms_taxon_block_body',
68
            'link' => '#lakion_cms_taxon_block_linkUrl',
69
            'name' => '#lakion_cms_taxon_block_name',
70
            'taxon' => '#lakion_cms_taxon_block_taxon',
71
            'title' => '#lakion_cms_taxon_block_title',
72
        ]);
73
    }
74
}
75