Commit 267f619
I've improved the code coverage for the
I added specific test cases to ensure full coverage of branches within the `fromJson` and `jsonSerialize` methods.
The following branches were targeted:
fromJson:
- `!array_key_exists('id', $data)`: I ensured that responses or errors missing an 'id' field are handled. I added `testFromJsonResponseMissingId` and `testFromJsonErrorResponseMissingId`.
- `!is_array($data['error'])`: I ensured that error messages with a non-array 'error' field are handled. I added `testFromJsonErrorFieldNotAnArray`.
jsonSerialize:
- `$this->id !== null` (for requests/notifications): I ensured that the 'id' field is correctly serialized for messages that are requests (i.e., have an ID and are not errors/results). I added `testJsonSerializeRequestWithId` for explicit coverage, complementing existing indirect coverage.
All new and existing tests pass, and linters are clean.JsonRpcMessage class.1 parent 8d01ed2 commit 267f619
1 file changed
+46
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
362 | 408 | | |
0 commit comments