1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 09:34:04 +00:00
This commit is contained in:
Samuel Štancl 2019-07-25 23:26:36 +02:00
parent ae5527c9a9
commit a3f37b7f77
7 changed files with 78 additions and 6 deletions

View file

@ -4,6 +4,8 @@ namespace Stancl\Tenancy\Tests;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
use Stancl\Tenancy\Tests\Etc\ExampleSeeder;
class CommandsTest extends TestCase
{
@ -72,4 +74,27 @@ class CommandsTest extends TestCase
{
$this->markTestIncomplete();
}
/** @test */
public function database_connection_is_switched_to_default_after_migrating_or_seeding_or_rolling_back()
{
$originalDBName = DB::connection()->getDatabaseName();
Artisan::call('tenants:migrate');
$this->assertSame($originalDBName, DB::connection()->getDatabaseName());
Artisan::call('tenants:seed', ['--class' => ExampleSeeder::class]);
$this->assertSame($originalDBName, DB::connection()->getDatabaseName());
Artisan::call('tenants:rollback');
$this->assertSame($originalDBName, DB::connection()->getDatabaseName());
}
/** @test */
public function database_connection_is_switched_to_default_after_migrating_or_seeding_or_rolling_back_when_tenancy_has_been_initialized()
{
tenancy()->init('localhost');
$this->database_connection_is_switched_to_default_after_migrating_or_seeding_or_rolling_back();
}
}