| @@ 263-276 (lines=14) @@ | ||
| 260 | * @param Stream|null $body | |
| 261 | * @param string $msg | |
| 262 | */ | |
| 263 | final protected static function assertRequestBody(Spec $spec, $template, $method, Stream $body = null, $msg = '') | |
| 264 |     { | |
| 265 | $schema = $spec->getRequestBodySchema($template, strtolower($method)); | |
| 266 | ||
| 267 |         if ($schema) { | |
| 268 | Assert::assertThat( | |
| 269 | json_decode($body), | |
| 270 | new JsonSchemaConstraint($schema, 'request body'), | |
| 271 | $msg | |
| 272 | ); | |
| 273 |         } else { | |
| 274 | Assert::assertEmpty(json_decode($body), $msg); | |
| 275 | } | |
| 276 | } | |
| 277 | ||
| 278 | /** | |
| 279 | * @param Spec $spec | |
| @@ 286-299 (lines=14) @@ | ||
| 283 | * @param Stream|null $body | |
| 284 | * @param string $msg | |
| 285 | */ | |
| 286 | final protected static function assertResponseBody(Spec $spec, $template, $method, $status, Stream $body = null, $msg = '') | |
| 287 |     { | |
| 288 | $schema = $spec->getResponseBodySchema($template, strtolower($method), $status); | |
| 289 | ||
| 290 |         if ($schema) { | |
| 291 | Assert::assertThat( | |
| 292 | json_decode($body), | |
| 293 | new JsonSchemaConstraint($schema, 'response body'), | |
| 294 | $msg | |
| 295 | ); | |
| 296 |         } else { | |
| 297 | Assert::assertEmpty(json_decode($body), $msg); | |
| 298 | } | |
| 299 | } | |
| 300 | ||
| 301 | /** | |
| 302 | * @param Spec $spec | |