1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 20:34:03 +00:00

Convert test cases

This commit is contained in:
Shift 2022-06-28 20:56:04 +00:00
parent 405b91085e
commit a8dcd0dfc9
No known key found for this signature in database
GPG key ID: 5A96F038425C5A1C
27 changed files with 3059 additions and 3658 deletions

View file

@ -2,32 +2,27 @@
declare(strict_types=1);
namespace Stancl\Tenancy\Tests;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
use Stancl\Tenancy\Tests\Etc\Tenant;
class TenantAwareCommandTest extends TestCase
{
/** @test */
public function commands_run_globally_are_tenant_aware_and_return_valid_exit_code()
{
$tenant1 = Tenant::create();
$tenant2 = Tenant::create();
Artisan::call('tenants:migrate', [
'--tenants' => [$tenant1['id'], $tenant2['id']],
]);
uses(Stancl\Tenancy\Tests\TestCase::class);
$this->artisan('user:add')
->assertExitCode(0);
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']],
]);
tenancy()->initialize($tenant1);
$this->assertNotEmpty(DB::table('users')->get());
tenancy()->end();
$this->artisan('user:add')
->assertExitCode(0);
tenancy()->initialize($tenant2);
$this->assertNotEmpty(DB::table('users')->get());
tenancy()->end();
}
}
tenancy()->initialize($tenant1);
$this->assertNotEmpty(DB::table('users')->get());
tenancy()->end();
tenancy()->initialize($tenant2);
$this->assertNotEmpty(DB::table('users')->get());
tenancy()->end();
});