1 | <?php |
||
21 | trait KumbiaTestTrait |
||
22 | { |
||
23 | /** |
||
24 | * Asserts HTTP response code |
||
25 | * |
||
26 | * @param int $code |
||
27 | */ |
||
28 | public function assertResponseCode($code) |
||
37 | /** |
||
38 | * Request to Controller |
||
39 | * |
||
40 | * @param string $method HTTP method |
||
41 | * @param string $url controller/method/arg|uri |
||
42 | * @param array $params POST parameters/Query string |
||
43 | */ |
||
44 | protected function request($method, $url, $params = []) |
||
59 | /** |
||
60 | * GET Request to Controller |
||
61 | * |
||
62 | * @param string $url controller/method/arg|uri |
||
63 | * @param array $params Query string |
||
64 | */ |
||
65 | public function get($url, $params = []) |
||
69 | } |
||
70 |
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.