mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 10:34:04 +00:00
Clarify fortify test
This commit is contained in:
parent
d554dfb547
commit
3621cc08c2
1 changed files with 16 additions and 10 deletions
|
|
@ -27,12 +27,13 @@ afterEach(function () {
|
||||||
test('fortify route tenancy bootstrapper updates fortify config correctly', function() {
|
test('fortify route tenancy bootstrapper updates fortify config correctly', function() {
|
||||||
config(['tenancy.bootstrappers' => [FortifyRouteBootstrapper::class]]);
|
config(['tenancy.bootstrappers' => [FortifyRouteBootstrapper::class]]);
|
||||||
|
|
||||||
|
// The bootstrapper uses resolver config for generating Fortify route URLs.
|
||||||
// Config used for generating Fortify route URLs
|
// Config used for generating Fortify route URLs
|
||||||
// when FortifyRouteBootstrapper::$passQueryParameter is true (default)
|
// when FortifyRouteBootstrapper::$passQueryParameter is true (default)
|
||||||
config([
|
config([
|
||||||
// Parameter name (RequestDataTenantResolver::queryParameterName())
|
// Parameter name (RequestDataTenantResolver::queryParameterName())
|
||||||
'tenancy.identification.resolvers.' . RequestDataTenantResolver::class . '.query_parameter' => 'team_query',
|
'tenancy.identification.resolvers.' . RequestDataTenantResolver::class . '.query_parameter' => 'team_query',
|
||||||
// Parameter value (RequestDataTenantResolver::payloadValue())
|
// Parameter value (RequestDataTenantResolver::payloadValue() gets the tenant model column value)
|
||||||
'tenancy.identification.resolvers.' . RequestDataTenantResolver::class . '.tenant_model_column' => 'company',
|
'tenancy.identification.resolvers.' . RequestDataTenantResolver::class . '.tenant_model_column' => 'company',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -41,7 +42,7 @@ test('fortify route tenancy bootstrapper updates fortify config correctly', func
|
||||||
config([
|
config([
|
||||||
// Parameter name (PathTenantResolver::tenantParameterName())
|
// Parameter name (PathTenantResolver::tenantParameterName())
|
||||||
'tenancy.identification.resolvers.' . PathTenantResolver::class . '.tenant_parameter_name' => 'team_path',
|
'tenancy.identification.resolvers.' . PathTenantResolver::class . '.tenant_parameter_name' => 'team_path',
|
||||||
// Parameter value (PathTenantResolver::tenantParameterValue())
|
// Parameter value (PathTenantResolver::tenantParameterValue() gets the tenant model column value)
|
||||||
'tenancy.identification.resolvers.' . PathTenantResolver::class . '.tenant_model_column' => 'name',
|
'tenancy.identification.resolvers.' . PathTenantResolver::class . '.tenant_model_column' => 'name',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -57,15 +58,22 @@ test('fortify route tenancy bootstrapper updates fortify config correctly', func
|
||||||
expect(config('fortify.home'))->toBe($originalFortifyHome);
|
expect(config('fortify.home'))->toBe($originalFortifyHome);
|
||||||
expect(config('fortify.redirects'))->toBe($originalFortifyRedirects);
|
expect(config('fortify.redirects'))->toBe($originalFortifyRedirects);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When $passQueryParameter is true, use the RequestDataTenantResolver config
|
||||||
|
* - tenant parameter is 'team_query'
|
||||||
|
* - parameter value is the tenant's company ('Acme')
|
||||||
|
*
|
||||||
|
* When $passQueryParameter is false, use the PathTenantResolver config
|
||||||
|
* - tenant parameter is 'team_path'
|
||||||
|
* - parameter value is the tenant's name ('Foo')
|
||||||
|
*/
|
||||||
$tenant = Tenant::create([
|
$tenant = Tenant::create([
|
||||||
'company' => 'Acme', // Tenant parameter value $passQueryParameter is true
|
'company' => 'Acme',
|
||||||
'name' => 'Foo', // Tenant parameter value when $passQueryParameter is false
|
'name' => 'Foo',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// The bootstrapper overrides the URLs in the Fortify config correctly (the URLs have the correct tenant parameter + parameter value)
|
// The bootstrapper overrides the URLs in the Fortify config correctly (the URLs have the correct tenant parameter + parameter value)
|
||||||
// When $passQueryParameter is true, use the RequestDataTenantResolver config
|
// RequestDataTenantResolver config should be used
|
||||||
// - tenant parameter is 'team_query'
|
|
||||||
// - parameter value is the tenant's company ('Acme')
|
|
||||||
FortifyRouteBootstrapper::$passQueryParameter = true;
|
FortifyRouteBootstrapper::$passQueryParameter = true;
|
||||||
|
|
||||||
tenancy()->initialize($tenant);
|
tenancy()->initialize($tenant);
|
||||||
|
|
@ -79,9 +87,7 @@ test('fortify route tenancy bootstrapper updates fortify config correctly', func
|
||||||
expect(config('fortify.home'))->toBe($originalFortifyHome);
|
expect(config('fortify.home'))->toBe($originalFortifyHome);
|
||||||
expect(config('fortify.redirects'))->toBe($originalFortifyRedirects);
|
expect(config('fortify.redirects'))->toBe($originalFortifyRedirects);
|
||||||
|
|
||||||
// When $passQueryParameter is false, use the PathTenantResolver config
|
// PathTenantResolver config should be used now
|
||||||
// - tenant parameter is 'team_path'
|
|
||||||
// - parameter value is the tenant's name ('Foo')
|
|
||||||
FortifyRouteBootstrapper::$passQueryParameter = false;
|
FortifyRouteBootstrapper::$passQueryParameter = false;
|
||||||
|
|
||||||
tenancy()->initialize($tenant);
|
tenancy()->initialize($tenant);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue