1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-08-06 08:54:03 +00:00

Re-resolve all stack channels that include any of the configured channels

Reverting the LogTenancyBootstrapper changes will make the new "stack channels that include any configured channel are re-resolved" test fali
This commit is contained in:
lukinovec 2026-06-29 17:51:35 +02:00
parent eaedd4a2e5
commit 68e6fd6c02
2 changed files with 63 additions and 19 deletions

View file

@ -350,6 +350,45 @@ test('stack logs are written to all configured channels with tenant-specific pat
->not()->toContain('tenant');
});
test('stack channels that include any configured channel are re-resolved', function () {
config([
'tenancy.bootstrappers' => [
FilesystemTenancyBootstrapper::class,
LogTenancyBootstrapper::class,
],
'logging.channels.custom_stack' => [
'driver' => 'stack',
'channels' => ['single'],
],
]);
$tenant = Tenant::create(['id' => 'stack-tenant']);
$centralLogPath = storage_path('logs/laravel.log');
// Resolve the stack channel in the central context first
// (this caches the stack with its members still pointing at the central logs).
Log::channel('custom_stack')->info('central');
expect(file_get_contents($centralLogPath))->toContain('central');
tenancy()->initialize($tenant);
Log::channel('custom_stack')->info('tenant log message');
// The stack channel should have been re-resolved with the
// updated (tenant) config for its member channels,
// so 'tenant log message' should be logged to the tenant log,
// not the central log.
expect(file_get_contents($centralLogPath))
->toContain('central')
->not()->toContain('tenant log message');
$tenantLogPath = storage_path('logs/laravel.log');
expect(file_exists($tenantLogPath))->toBeTrue();
expect(file_get_contents($tenantLogPath))
->toContain('tenant log message');
});
test('slack channel uses correct webhook urls', function () {
config([
'logging.channels.slack.url' => 'central-webhook',