| 1 | <?php |
||
| 11 | trait MouseTrait { |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Generates a mouseover event on the given element by xpath |
||
| 15 | * @param string $xpath |
||
| 16 | * @throws DriverException |
||
| 17 | */ |
||
| 18 | public function mouseOver($xpath) { |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Clicks if possible on an element given by xpath |
||
| 25 | * @param string $xpath |
||
| 26 | * @return mixed |
||
| 27 | * @throws DriverException |
||
| 28 | */ |
||
| 29 | public function click($xpath) { |
||
| 33 | |||
| 34 | /** |
||
| 35 | * {@inheritdoc} |
||
| 36 | */ |
||
| 37 | /** |
||
| 38 | * Double click on element found via xpath |
||
| 39 | * @param string $xpath |
||
| 40 | * @throws DriverException |
||
| 41 | */ |
||
| 42 | public function doubleClick($xpath) { |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Right click on element found via xpath |
||
| 49 | * @param string $xpath |
||
| 50 | * @throws DriverException |
||
| 51 | */ |
||
| 52 | public function rightClick($xpath) { |
||
| 56 | |||
| 57 | } |
||
| 58 |
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
Idableprovides a methodequalsIdthat 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.