CustomAssert::fieldIsVisible()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 2
1
<?php
2
3
namespace UnicadeAssert;
4
5
use Behat\Mink\WebAssert;
6
7
class CustomAssert extends WebAssert
8
{
9
    /**
10
     * Checks that specific element exists and is visible on the current page.
11
     *
12
     * @param string  $selectorType element selector type (css, xpath)
13
     * @param string  $selector     element selector
14
     * @param Element $container    document to check against
15
     *
16
     * @return \Behat\Mink\Element\NodeElement
17
     *
18
     * @throws ElementNotVisible
19
     */
20
    public function elementIsVisible($selectorType, $selector, Element $container = null)
21
    {
22
        $node = $this->elementExists($selectorType, $selector, $container);
23
24
        if (true !== $node->isVisible()) {
25
            throw new \LogicException('Element is not visible - selector: '.$selector);
26
        }
27
28
        return $node;
29
    }
30
    /**
31
     * Checks that specific field exists on the current page.
32
     *
33
     * @param string $field field id|name|label|value
34
     * @param Element $container    document to check against
35
     *
36
     * @return \Behat\Mink\Element\NodeElement
37
     *
38
     * @throws ElementNotVisible
39
     */
40
    public function fieldIsVisible($field, Element $container = null)
0 ignored issues
show
Unused Code introduced by
The parameter $container is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
41
    {
42
        $node = $this->fieldExists($field, $container = null);
43
44
        if (true !== $node->isVisible()) {
45
            throw new \Exception('Field is not visible - field: '.$field);
46
        }
47
48
        return $node;
49
    }
50
}
51