1 | <?php |
||
20 | trait AssertTrait |
||
21 | { |
||
22 | /** |
||
23 | * assert contains tag |
||
24 | * |
||
25 | * @param array $expected expected |
||
26 | * @param string $result HTML |
||
27 | * @return void |
||
28 | */ |
||
29 | public function assertContainsTag($expected, $result) |
||
49 | |||
50 | /** |
||
51 | * tests if XPath exists in HTML Source |
||
52 | * |
||
53 | * @param string $html HTML |
||
54 | * @param string $path XPath |
||
55 | * @param int $count how many times should XPath exist in HTML |
||
56 | * @return mixed |
||
57 | */ |
||
58 | public function assertXPath($html, $path, $count = 1) |
||
69 | |||
70 | /** |
||
71 | * assert not xpath |
||
72 | * |
||
73 | * @param string $html path |
||
74 | * @param string $path path |
||
75 | * @return bool |
||
76 | */ |
||
77 | public function assertNotXPath($html, $path) |
||
81 | |||
82 | /** |
||
83 | * get dom xpath |
||
84 | * |
||
85 | * @param string $html HTML |
||
86 | * @return \DOMXPath |
||
87 | */ |
||
88 | protected function _getDOMXPath($html) |
||
98 | } |
||
99 |
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.