1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 20:34:03 +00:00
tenancy/tests/TenantAwareCommandTest.php
2022-06-28 20:56:04 +00:00

28 lines
742 B
PHP

<?php
declare(strict_types=1);
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
use Stancl\Tenancy\Tests\Etc\Tenant;
uses(Stancl\Tenancy\Tests\TestCase::class);
test('commands run globally are tenant aware and return valid exit code', function () {
$tenant1 = Tenant::create();
$tenant2 = Tenant::create();
Artisan::call('tenants:migrate', [
'--tenants' => [$tenant1['id'], $tenant2['id']],
]);
$this->artisan('user:add')
->assertExitCode(0);
tenancy()->initialize($tenant1);
$this->assertNotEmpty(DB::table('users')->get());
tenancy()->end();
tenancy()->initialize($tenant2);
$this->assertNotEmpty(DB::table('users')->get());
tenancy()->end();
});