Completed
Pull Request — master (#244)
by Łukasz
09:35
created

NewsEdit::getHeader()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace FSi\Bundle\AdminBundle\Behat\Context\Page;
11
12
use SensioLabs\Behat\PageObjectExtension\PageObject\Exception\UnexpectedPageException;
13
14
class NewsEdit extends Page
15
{
16
    protected $path = '/admin/form/news/{id}';
17
    protected $elements = array(
18
        'page header' => '#page-header',
19
    );
20
21
    public function getHeader()
22
    {
23
        if (!$this->hasElement('page header')) {
24
            throw new \Exception('Unable to find page header');
25
        }
26
27
        return $this->getElement('page header')->getText();
28
    }
29
30
    protected function verifyPage()
31
    {
32
        if (!$this->has('css', '#page-header:contains("Edit element")')) {
33
            throw new UnexpectedPageException(sprintf("%s page is missing \"New element\" header", $this->path));
34
        }
35
    }
36
}
37