mirror of
https://github.com/archtechx/tenancy.git
synced 2026-05-06 17:04:04 +00:00
Throw exception if override closure doesn't return array
This commit is contained in:
parent
cdea112ad5
commit
8fda84fcee
2 changed files with 17 additions and 3 deletions
|
|
@ -140,6 +140,11 @@ test('channel overrides work correctly with both arrays and closures', function
|
|||
|
||||
$tenant = Tenant::create(['webhookUrl' => 'tenant-webhook']);
|
||||
|
||||
// Channel override closures must return an array, otherwise an exception is thrown
|
||||
LogTenancyBootstrapper::$channelOverrides['slack'] = fn (Tenant $tenant, array $channel) => 'invalid override';
|
||||
|
||||
expect(fn() => tenancy()->initialize($tenant))->toThrow(InvalidArgumentException::class);
|
||||
|
||||
// Test both array mapping and closure-based overrides
|
||||
LogTenancyBootstrapper::$channelOverrides = [
|
||||
'slack' => ['url' => 'webhookUrl'], // slack.url will be mapped to $tenant->webhookUrl
|
||||
|
|
@ -148,7 +153,8 @@ test('channel overrides work correctly with both arrays and closures', function
|
|||
},
|
||||
];
|
||||
|
||||
tenancy()->initialize($tenant);
|
||||
// Reinitialize tenancy to apply the new overrides
|
||||
tenancy()->reinitialize();
|
||||
|
||||
// Array mapping overrides work
|
||||
expect(config('logging.channels.slack.url'))->toBe($tenant->webhookUrl);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue