1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 09:54:03 +00:00

Refactor tests to use pest() helper

This commit is contained in:
Samuel Štancl 2022-07-23 01:16:50 +02:00
parent 05f2a828a1
commit f9c9d8615f
26 changed files with 128 additions and 127 deletions

View file

@ -34,7 +34,7 @@ test('tenant can be identified by path', function () {
expect(tenancy()->initialized)->toBeFalse();
$this->get('/acme/foo/abc/xyz');
pest()->get('/acme/foo/abc/xyz');
expect(tenancy()->initialized)->toBeTrue();
expect(tenant('id'))->toBe('acme');
@ -47,7 +47,7 @@ test('route actions dont get the tenant id', function () {
expect(tenancy()->initialized)->toBeFalse();
$this
pest()
->get('/acme/foo/abc/xyz')
->assertContent('abc + xyz');
@ -56,7 +56,7 @@ test('route actions dont get the tenant id', function () {
});
test('exception is thrown when tenant cannot be identified by path', function () {
$this->expectException(TenantCouldNotBeIdentifiedByPathException::class);
pest()->expectException(TenantCouldNotBeIdentifiedByPathException::class);
$this
->withoutExceptionHandling()
@ -70,7 +70,7 @@ test('onfail logic can be customized', function () {
return 'foo';
};
$this
pest()
->get('/acme/foo/abc/xyz')
->assertContent('foo');
});
@ -89,7 +89,7 @@ test('an exception is thrown when the routes first parameter is not tenant', fun
'id' => 'acme',
]);
$this->expectException(RouteIsMissingTenantParameterException::class);
pest()->expectException(RouteIsMissingTenantParameterException::class);
$this
->withoutExceptionHandling()
@ -112,12 +112,12 @@ test('tenant parameter name can be customized', function () {
'id' => 'acme',
]);
$this
pest()
->get('/acme/bar/abc/xyz')
->assertContent('abc + xyz');
// Parameter for resolver is changed, so the /{tenant}/foo route will no longer work.
$this->expectException(RouteIsMissingTenantParameterException::class);
pest()->expectException(RouteIsMissingTenantParameterException::class);
$this
->withoutExceptionHandling()