1 | <?php |
||
21 | trait AssertTrait |
||
22 | { |
||
23 | /** |
||
24 | * assert contains tag |
||
25 | * |
||
26 | * @param array $expected expected |
||
27 | * @param string $result HTML |
||
28 | * @return void |
||
29 | */ |
||
30 | public function assertContainsTag($expected, $result) |
||
50 | |||
51 | /** |
||
52 | * tests if XPath exists in HTML Source |
||
53 | * |
||
54 | * @param string $html HTML |
||
55 | * @param string $path XPath |
||
56 | * @param int $count how many times should XPath exist in HTML |
||
57 | * @return mixed |
||
58 | */ |
||
59 | public function assertXPath($html, $path, $count = 1) |
||
70 | |||
71 | /** |
||
72 | * assert not xpath |
||
73 | * |
||
74 | * @param string $html path |
||
75 | * @param string $path path |
||
76 | * @return bool |
||
77 | */ |
||
78 | public function assertNotXPath($html, $path) |
||
82 | |||
83 | /** |
||
84 | * get dom xpath |
||
85 | * |
||
86 | * @param string $html HTML |
||
87 | * @return \DOMXPath |
||
88 | */ |
||
89 | protected function _getDOMXPath($html) |
||
99 | |||
100 | /** |
||
101 | * Assert Flash message was set |
||
102 | * |
||
103 | * @param string $message message |
||
104 | * @param string $element element |
||
105 | * @param bool $debug debugging |
||
106 | * @return void |
||
107 | */ |
||
108 | protected function assertFlash(string $message, string $element = null, $debug = false): void |
||
130 | } |
||
131 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.