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:
parent
405b91085e
commit
a8dcd0dfc9
27 changed files with 3059 additions and 3658 deletions
|
|
@ -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();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue