1 | <?php |
||
7 | trait AssertJsonResponse |
||
8 | { |
||
9 | use AssertArrays; |
||
10 | |||
11 | public function __construct() |
||
17 | |||
18 | /** |
||
19 | * Add the functions to the TestResponse objects. |
||
20 | */ |
||
21 | 1 | public function addJsonResponseMacros() |
|
33 | |||
34 | /** |
||
35 | * Assert that the JSON response has exactly the given structure. |
||
36 | * |
||
37 | * @param array $structure |
||
38 | * @param array|null $responseData |
||
39 | * |
||
40 | * @return $this |
||
41 | */ |
||
42 | 2 | public function seeJsonStructureEquals($structure, $responseData = null) |
|
50 | |||
51 | /** |
||
52 | * Return the json response or a part of it as an array. |
||
53 | * |
||
54 | * @param string $key |
||
55 | * @param array|null $responseData |
||
56 | * |
||
57 | * @return mixed |
||
58 | */ |
||
59 | 2 | public function jsonResponse($key = null, $responseData = null) |
|
67 | } |
||
68 |
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.