|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Openbuildings\PHPUnitSpiderling; |
|
4
|
|
|
|
|
5
|
|
|
use Openbuildings\PHPUnitSpiderling\Constraint\LocatorConstraint; |
|
6
|
|
|
use Openbuildings\PHPUnitSpiderling\Constraint\NegativeLocatorConstraint; |
|
7
|
|
|
use PHPUnit\Framework\Assert as PHPUnitAssert; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Assertions. |
|
11
|
|
|
*/ |
|
12
|
|
|
abstract class Assert |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* Assert that an html tag exists inside the current tag. |
|
16
|
|
|
* |
|
17
|
|
|
* @param string|array $selector |
|
18
|
|
|
* @param array $filters |
|
19
|
|
|
* @param string $message |
|
20
|
|
|
*/ |
|
21
|
4 |
|
public static function assertHasCss($node, $selector, array $filters = [], string $message = '') |
|
22
|
|
|
{ |
|
23
|
4 |
|
PHPUnitAssert::assertThat($node, new LocatorConstraint('css', $selector, $filters), $message); |
|
24
|
4 |
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Assert that an html tag does not exist inside the current tag. |
|
28
|
|
|
* |
|
29
|
|
|
* @param string|array $selector |
|
30
|
|
|
* @param array $filters |
|
31
|
|
|
* @param string $message |
|
32
|
|
|
*/ |
|
33
|
1 |
|
public static function assertHasNoCss($node, $selector, array $filters = [], string $message = '') |
|
34
|
|
|
{ |
|
35
|
1 |
|
PHPUnitAssert::assertThat($node, new NegativeLocatorConstraint('css', $selector, $filters), $message); |
|
36
|
1 |
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Assert that an form field exists inside the current tag. |
|
40
|
|
|
* |
|
41
|
|
|
* @param string|array $selector |
|
42
|
|
|
* @param array $filters |
|
43
|
|
|
* @param string $message |
|
44
|
|
|
*/ |
|
45
|
4 |
|
public static function assertHasField($node, $selector, array $filters = [], string $message = '') |
|
46
|
|
|
{ |
|
47
|
4 |
|
PHPUnitAssert::assertThat($node, new LocatorConstraint('field', $selector, $filters), $message); |
|
48
|
4 |
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Assert that an form field does not exist inside the current tag. |
|
52
|
|
|
* |
|
53
|
|
|
* @param string|array $selector |
|
54
|
|
|
* @param array $filters |
|
55
|
|
|
* @param string $message |
|
56
|
|
|
*/ |
|
57
|
1 |
|
public static function assertHasNoField($node, $selector, array $filters = [], string $message = '') |
|
58
|
|
|
{ |
|
59
|
1 |
|
PHPUnitAssert::assertThat($node, new NegativeLocatorConstraint('field', $selector, $filters), $message); |
|
60
|
1 |
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Assert that an html tag exists inside the current tag, matched by xpath. |
|
64
|
|
|
* |
|
65
|
|
|
* @param string|array $selector |
|
66
|
|
|
* @param array $filters |
|
67
|
|
|
* @param string $message |
|
68
|
|
|
*/ |
|
69
|
1 |
|
public static function assertHasXPath($node, $selector, array $filters = [], string $message = '') |
|
70
|
|
|
{ |
|
71
|
1 |
|
PHPUnitAssert::assertThat($node, new LocatorConstraint('xpath', $selector, $filters), $message); |
|
72
|
1 |
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Assert that an html tag does not exist inside the current tag matched by xpath. |
|
76
|
|
|
* |
|
77
|
|
|
* @param string|array $selector |
|
78
|
|
|
* @param array $filters |
|
79
|
|
|
* @param string $message |
|
80
|
|
|
*/ |
|
81
|
1 |
|
public static function assertHasNoXPath($node, $selector, array $filters = [], string $message = '') |
|
82
|
|
|
{ |
|
83
|
1 |
|
PHPUnitAssert::assertThat($node, new NegativeLocatorConstraint('xpath', $selector, $filters), $message); |
|
84
|
1 |
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Assert that an html anchor tag exists inside the current tag. |
|
88
|
|
|
* |
|
89
|
|
|
* @param string|array $selector |
|
90
|
|
|
* @param array $filters |
|
91
|
|
|
* @param string $message |
|
92
|
|
|
*/ |
|
93
|
1 |
|
public static function assertHasLink($node, $selector, array $filters = [], string $message = '') |
|
94
|
|
|
{ |
|
95
|
1 |
|
PHPUnitAssert::assertThat($node, new LocatorConstraint('link', $selector, $filters), $message); |
|
96
|
1 |
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Assert that an html anchor tag does not exist inside the current tag. |
|
100
|
|
|
* |
|
101
|
|
|
* @param string|array $selector |
|
102
|
|
|
* @param array $filters |
|
103
|
|
|
* @param string $message |
|
104
|
|
|
*/ |
|
105
|
1 |
|
public static function assertHasNoLink($node, $selector, array $filters = [], string $message = '') |
|
106
|
|
|
{ |
|
107
|
1 |
|
PHPUnitAssert::assertThat($node, new NegativeLocatorConstraint('link', $selector, $filters), $message); |
|
108
|
1 |
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Assert that an html button tag exists inside the current tag. |
|
112
|
|
|
* |
|
113
|
|
|
* @param string|array $selector |
|
114
|
|
|
* @param array $filters |
|
115
|
|
|
* @param string $message |
|
116
|
|
|
*/ |
|
117
|
1 |
|
public static function assertHasButton($node, $selector, array $filters = [], string $message = '') |
|
118
|
|
|
{ |
|
119
|
1 |
|
PHPUnitAssert::assertThat($node, new LocatorConstraint('button', $selector, $filters), $message); |
|
120
|
1 |
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* Assert that an html button tag does not exist inside the current tag. |
|
124
|
|
|
* |
|
125
|
|
|
* @param string|array $selector |
|
126
|
|
|
* @param array $filters |
|
127
|
|
|
* @param string $message |
|
128
|
|
|
*/ |
|
129
|
1 |
|
public static function assertHasNoButton($node, $selector, array $filters = [], string $message = '') |
|
130
|
|
|
{ |
|
131
|
1 |
|
PHPUnitAssert::assertThat($node, new NegativeLocatorConstraint('button', $selector, $filters), $message); |
|
132
|
1 |
|
} |
|
133
|
|
|
} |
|
134
|
|
|
|