| 1 | <?php |
||
| 11 | trait ApiTestHelperTrait |
||
| 12 | { |
||
| 13 | public function assertCollectionContainsObject($object, $collection) |
||
| 17 | |||
| 18 | public function assertJsonResponse($response) |
||
| 24 | |||
| 25 | public function assertForbidden($response) |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param string $role |
||
| 32 | */ |
||
| 33 | protected function logIn($role) |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @param string $method |
||
| 49 | * @param string $url |
||
| 50 | */ |
||
| 51 | protected function makeJsonRequest($method, $url, $body = []) |
||
| 62 | |||
| 63 | protected function getResponseContent($asJson = false) |
||
| 73 | } |
||
| 74 |
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.