CreatePage   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 4
dl 0
loc 66
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setBody() 0 4 1
A setLink() 0 4 1
A setName() 0 4 1
A setTitle() 0 4 1
A chooseTaxon() 0 6 2
A attachImage() 0 4 1
A getDefinedElements() 0 10 1
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