Move component assertion
This commit is contained in:
parent
5482d47f0c
commit
73633d7628
|
@ -25,9 +25,8 @@ class IndexTest extends EndToEndTestCase
|
|||
]);
|
||||
|
||||
sleep(1);
|
||||
$response = $this->get('/member');
|
||||
$response = $this->get('/member')->assertComponent('member/VIndex');
|
||||
|
||||
$this->assertComponent('member/VIndex', $response);
|
||||
$this->assertInertiaHas('::firstname::', $response, 'data.data.0.firstname');
|
||||
$this->assertInertiaHas(false, $response, 'data.data.0.has_nami');
|
||||
$this->assertInertiaHas('Kölner Str 3, 33333 Hilden', $response, 'data.data.0.full_address');
|
||||
|
|
|
@ -15,9 +15,7 @@ class ForgotPasswordTest extends TestCase
|
|||
public function testItShowsResetForm(): void
|
||||
{
|
||||
$this->withoutExceptionHandling();
|
||||
$response = $this->get('/password/reset');
|
||||
|
||||
$this->assertComponent('authentication/PasswordReset', $response);
|
||||
$this->get('/password/reset')->assertComponent('authentication/PasswordReset');
|
||||
}
|
||||
|
||||
public function testItRequiresAnEmailAddress(): void
|
||||
|
|
|
@ -33,4 +33,11 @@ class FileshareIndexActionTest extends FileshareTestCase
|
|||
->assertInertiaPath('data.meta.types.0.defaults.base_url', '')
|
||||
->assertInertiaPath('data.meta.types.0.fields.1', ['label' => 'Benutzer', 'key' => 'user', 'type' => 'text']);
|
||||
}
|
||||
|
||||
public function testItRendersComponent(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
|
||||
$this->get('/setting/fileshare')->assertComponent('fileshareconnection/Index');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,11 +22,6 @@ trait TestsInertia
|
|||
$this->assertInertiaDeepNest($bindings, $viewData);
|
||||
}
|
||||
|
||||
public function assertComponent(string $component, TestResponse $response): void
|
||||
{
|
||||
PHPUnit::assertEquals($component, $response->viewData('page')['component']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $should
|
||||
* @param mixed $is
|
||||
|
|
|
@ -133,6 +133,13 @@ abstract class TestCase extends BaseTestCase
|
|||
return $this;
|
||||
});
|
||||
|
||||
TestResponse::macro('assertComponent', function (string $component) {
|
||||
/** @var TestResponse */
|
||||
$response = $this;
|
||||
Assert::assertEquals($component, data_get($response->viewData('page'), 'component'));
|
||||
return $this;
|
||||
});
|
||||
|
||||
TestResponse::macro('assertPdfPageCount', function (int $count) {
|
||||
/** @var TestResponse */
|
||||
$response = $this;
|
||||
|
|
|
@ -10,6 +10,7 @@ use Symfony\Component\HttpFoundation\File\File;
|
|||
* @method self assertPdfPageCount(int $count)
|
||||
* @method self assertPdfName(string $filename)
|
||||
* @method self assertHasJsonPath(string $path)
|
||||
* @method self assertComponnet(string $component)
|
||||
* @method File getFile()
|
||||
*/
|
||||
class TestResponse
|
||||
|
|
Loading…
Reference in New Issue