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

Simplify the slack channel usage test

This commit is contained in:
lukinovec 2025-07-29 12:24:06 +02:00
parent a13110c880
commit 718afd3069

View file

@ -363,35 +363,24 @@ test('slack channel uses correct webhook urls', function () {
]; ];
// Test central context - should attempt to use central webhook // Test central context - should attempt to use central webhook
// Because the Slack channel uses cURL to send messages, we cannot use Http::fake() here.
// Instead, we catch the exception and check the error message which contains the actual webhook URL.
try { try {
logger('central'); logger('central');
} catch (Exception $e) { } catch (Exception $e) {
expect($e->getMessage())->toContain('central-webhook'); expect($e->getMessage())->toContain('central-webhook');
} }
// Test tenant 1 context - should attempt to use tenant1 webhook // Slack channel should attempt to use the tenant-specific webhooks
tenancy()->initialize($tenant1); tenancy()->runForMultiple([$tenant1, $tenant2], function (Tenant $tenant) {
try {
logger($tenant->id);
} catch (Exception $e) {
expect($e->getMessage())->toContain($tenant->slackUrl);
}
});
try { // Central context, central webhook should be used again
logger('tenant1');
} catch (Exception $e) {
expect($e->getMessage())->toContain('tenant1-webhook');
}
tenancy()->end();
// Test tenant 2 context - should attempt to use tenant2 webhook
tenancy()->initialize($tenant2);
try {
logger('tenant2');
} catch (Exception $e) {
expect($e->getMessage())->toContain('tenant2-webhook');
}
tenancy()->end();
// Back to central - should use central webhook again
try { try {
logger('central'); logger('central');
} catch (Exception $e) { } catch (Exception $e) {