NotExists::assert()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 9
nc 4
nop 0
1
<?php
2
3
namespace Magium\Assertions\Element;
4
5
6
use Magium\AbstractTestCase;
7
8
class NotExists extends AbstractSelectorAssertion
9
{
10
11
    const ASSERTION = 'Element\NotExists';
12
13
    public function assert()
14
    {
15
        $exceptionThrown = false;
16
        try {
17
            $this->getTestCase()->assertWebDriverElement($this->webDriver->{$this->by}($this->selector));
18
        } catch (\Exception $e) {
19
            $exceptionThrown = true;
20
            AbstractTestCase::assertTrue(true); // protection against " test did not perform any assertions"
21
        }
22
        if (!$exceptionThrown) {
23
            $this->getTestCase()->fail(sprintf('Element "%s" was found using selector "%s"', $this->selector, $this->by));
24
        }
25
    }
26
27
}
28