AssertableJsonString
class AssertableJsonString implements ArrayAccess, Countable
Properties
| Jsonable|JsonSerializable|array|string | $json | The original encoded json. |
|
| protected mixed | $decoded | The decoded json contents. |
Methods
Create a new assertable JSON string instance.
Validate and return the decoded response JSON.
Return the decoded JSON with objects as stdClass instances.
Assert that the response JSON has the expected count of items at the given key.
Assert that the response has the exact given JSON.
Assert that the response has the similar JSON as given.
Assert that the response contains the given JSON fragment.
Assert that the response does not contain the given JSON fragment.
Assert that the response does not contain the exact JSON fragment.
Assert that the response does not contain the given path.
Determine whether a JSON path exists, where each wildcard matches any child at its level.
Assert that the expected value and type exists at the given path in the response.
Assert that the given path in the response contains all of the expected values without looking at the order.
Assert that the response has a given JSON structure.
Assert that the response is a superset of the given JSON.
Reorder associative array keys to make it easy to compare arrays.
Get the assertion message for assertJson.
Get the strings we need to search for when examining the JSON.
Get the total number of items in the underlying JSON array.
Determine whether an offset exists.
Get the value at the given offset.
Set the value at the given offset.
Unset the value at the given offset.
Details
at line 37
__construct(Jsonable|JsonSerializable|array|string $jsonable)
Create a new assertable JSON string instance.
at line 59
mixed
json(string|null $key = null)
Validate and return the decoded response JSON.
at line 71
mixed
object(string|null $key = null)
Return the decoded JSON with objects as stdClass instances.
Unlike json(), this keeps empty and numeric-key JSON objects distinct from arrays.
at line 83
AssertableJsonString
assertCount(int $count, string|null $key = null)
Assert that the response JSON has the expected count of items at the given key.
at line 109
AssertableJsonString
assertExact(array $data)
Assert that the response has the exact given JSON.
at line 128
AssertableJsonString
assertSimilar(array $data)
Assert that the response has the similar JSON as given.
at line 145
AssertableJsonString
assertFragment(array $data)
Assert that the response contains the given JSON fragment.
at line 172
AssertableJsonString
assertMissing(array $data, bool $exact = false)
Assert that the response does not contain the given JSON fragment.
at line 203
AssertableJsonString
assertMissingExact(array $data)
Assert that the response does not contain the exact JSON fragment.
at line 231
AssertableJsonString
assertMissingPath(string $path)
Assert that the response does not contain the given path.
at line 252
protected bool
hasJsonPath(mixed $data, array $segments)
Determine whether a JSON path exists, where each wildcard matches any child at its level.
at line 282
AssertableJsonString
assertPath(string $path, mixed $expect)
Assert that the expected value and type exists at the given path in the response.
at line 298
AssertableJsonString
assertPathCanonicalizing(string $path, array $expect)
Assert that the given path in the response contains all of the expected values without looking at the order.
at line 308
AssertableJsonString
assertStructure(array|null $structure = null, array|null $responseData = null, bool $exact = false)
Assert that the response has a given JSON structure.
at line 352
AssertableJsonString
assertSubset(array $data, bool $strict = false)
Assert that the response is a superset of the given JSON.
at line 367
protected array
reorderAssocKeys(array $data)
Reorder associative array keys to make it easy to compare arrays.
at line 384
protected string
assertJsonMessage(array $data)
Get the assertion message for assertJson.
at line 399
protected array
jsonSearchStrings(string|int $key, mixed $value)
Get the strings we need to search for when examining the JSON.
at line 413
int
count()
Get the total number of items in the underlying JSON array.
at line 421
bool
offsetExists(mixed $offset)
Determine whether an offset exists.
at line 429
mixed
offsetGet(mixed $offset)
Get the value at the given offset.
at line 437
void
offsetSet(mixed $offset, mixed $value)
Set the value at the given offset.
at line 445
void
offsetUnset(mixed $offset)
Unset the value at the given offset.