1 | <?php |
||
11 | trait FormManipulationTrait { |
||
12 | |||
13 | |||
14 | /** |
||
15 | * Returns the value of a given xpath element |
||
16 | * @param string $xpath |
||
17 | * @return string |
||
18 | * @throws DriverException |
||
19 | */ |
||
20 | public function getValue($xpath) { |
||
25 | |||
26 | /** |
||
27 | * @param string $xpath |
||
28 | * @param string $value |
||
29 | * @throws DriverException |
||
30 | */ |
||
31 | public function setValue($xpath, $value) { |
||
41 | |||
42 | |||
43 | /** |
||
44 | * Submits a form given an xpath selector |
||
45 | * @param string $xpath |
||
46 | * @throws DriverException |
||
47 | */ |
||
48 | public function submitForm($xpath) { |
||
56 | |||
57 | /** |
||
58 | * Helper method needed for twig and javascript stuff |
||
59 | * @param $boolValue |
||
60 | * @return string |
||
61 | */ |
||
62 | protected function boolToString($boolValue) { |
||
68 | |||
69 | /** |
||
70 | * Selects an option |
||
71 | * @param string $xpath |
||
72 | * @param string $value |
||
73 | * @param bool $multiple |
||
74 | * @return bool |
||
75 | * @throws DriverException |
||
76 | */ |
||
77 | public function selectOption($xpath, $value, $multiple = false) { |
||
92 | |||
93 | /** |
||
94 | * Check control over an input element of radio or checkbox type |
||
95 | * @param $xpath |
||
96 | * @return bool |
||
97 | * @throws DriverException |
||
98 | */ |
||
99 | protected function inputCheckableControl($xpath) { |
||
111 | |||
112 | /** |
||
113 | * We click on the checkbox or radio when possible and needed |
||
114 | * @param string $xpath |
||
115 | * @throws DriverException |
||
116 | */ |
||
117 | public function check($xpath) { |
||
122 | |||
123 | /** |
||
124 | * We click on the checkbox or radio when possible and needed |
||
125 | * @param string $xpath |
||
126 | * @throws DriverException |
||
127 | */ |
||
128 | public function uncheck($xpath) { |
||
133 | |||
134 | /** |
||
135 | * Checks if the radio or checkbox is checked |
||
136 | * @param string $xpath |
||
137 | * @return bool |
||
138 | * @throws DriverException |
||
139 | */ |
||
140 | public function isChecked($xpath) { |
||
151 | |||
152 | /** |
||
153 | * Checks if the option is selected or not |
||
154 | * @param string $xpath |
||
155 | * @return bool |
||
156 | * @throws DriverException |
||
157 | */ |
||
158 | public function isSelected($xpath) { |
||
168 | } |
||
169 |
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.