Skip to content

Commit 97cf06b

Browse files
committed
Add config option to determine current tenant during tests
1 parent 9c14fd1 commit 97cf06b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

config/multitenancy.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
*/
2424
'tenant_finder' => null,
2525

26+
/*
27+
* Set this to true if you want to determine the current tenant
28+
* when running tests (e.g., during Pest browser tests).
29+
*/
30+
'determine_current_tenant_in_tests' => false,
31+
2632
/*
2733
* These fields are used by tenant:artisan command to match one or more tenant.
2834
*/

src/Multitenancy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected function registerTenantFinder(): static
7474

7575
protected function configureRequests(): static
7676
{
77-
if (! $this->app->runningInConsole()) {
77+
if (! $this->app->runningInConsole() || ($this->app->runningUnitTests() && $this->app['config']->get('multitenancy.determine_current_tenant_in_tests'))) {
7878
$this->determineCurrentTenant();
7979
}
8080

0 commit comments

Comments
 (0)