Add macros for TestResponse
This commit is contained in:
parent
adf9341dd7
commit
31c582e81d
|
@ -119,12 +119,24 @@ class TestCase extends BaseTestCase
|
|||
/** @var TestResponse */
|
||||
$response = $this;
|
||||
$props = data_get($response->viewData('page'), 'props');
|
||||
Assert::assertTrue(Arr::has($props, $path), 'Failed that key ' . $path . ' is in Response.');
|
||||
Assert::assertNotNull($props);
|
||||
$json = new AssertableJsonString($props);
|
||||
$json->assertPath($path, $value);
|
||||
return $this;
|
||||
});
|
||||
|
||||
TestResponse::macro('assertInertiaPathArray', function ($arr) {
|
||||
/** @var TestResponse */
|
||||
$response = $this;
|
||||
|
||||
foreach ($arr as $key => $value) {
|
||||
$response->assertInertiaPath($key, $value);
|
||||
}
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
TestResponse::macro('assertInertiaCount', function ($path, $count) {
|
||||
/** @var TestResponse */
|
||||
$response = $this;
|
||||
|
@ -171,5 +183,13 @@ class TestCase extends BaseTestCase
|
|||
|
||||
return $this;
|
||||
});
|
||||
|
||||
TestResponse::macro('assertNull', function (string $path) {
|
||||
/** @var TestResponse */
|
||||
$response = $this;
|
||||
$response->assertHasJsonPath($path)->assertJsonPath($path, null);
|
||||
|
||||
return $this;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue