diff --git a/tests/TenantDatabaseManagerTest.php b/tests/TenantDatabaseManagerTest.php index 42905497..3c16378f 100644 --- a/tests/TenantDatabaseManagerTest.php +++ b/tests/TenantDatabaseManagerTest.php @@ -11,41 +11,7 @@ use Stancl\Tenancy\Jobs\QueuedTenantDatabaseDeleter; class TenantDatabaseManagerTest extends TestCase { /** @test */ - public function sqlite_database_is_created() - { - $db_name = 'testdatabase' . $this->randomString(10) . '.sqlite'; - app(DatabaseManager::class)->create($db_name, 'sqlite'); - $this->assertFileExists(database_path($db_name)); - } - - /** @test */ - public function mysql_database_is_created() - { - if (! $this->isTravis()) { - $this->markTestSkipped('As to not bloat your MySQL instance with test databases, this test is not run by default.'); - } - - config()->set('database.default', 'mysql'); - - $db_name = 'testdatabase' . $this->randomString(10); - app(DatabaseManager::class)->create($db_name, 'mysql'); - $this->assertNotEmpty(DB::select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '$db_name'")); - } - - /** @test */ - public function database_creation_can_be_queued() - { - Queue::fake(); - - config()->set('tenancy.queue_database_creation', true); - $db_name = 'testdatabase' . $this->randomString(10) . '.sqlite'; - app(DatabaseManager::class)->create($db_name, 'sqlite'); - - Queue::assertPushed(QueuedTenantDatabaseCreator::class); - } - - /** @test */ - public function sqlite_database_is_deleted() + public function sqlite_database_can_be_created_and_deleted() { $db_name = 'testdatabase' . $this->randomString(10) . '.sqlite'; app(DatabaseManager::class)->create($db_name, 'sqlite'); @@ -56,7 +22,7 @@ class TenantDatabaseManagerTest extends TestCase } /** @test */ - public function mysql_database_is_deleted() + public function mysql_database_can_be_created_and_deleted() { if (! $this->isTravis()) { $this->markTestSkipped('As to not bloat your MySQL instance with test databases, this test is not run by default.'); @@ -72,6 +38,18 @@ class TenantDatabaseManagerTest extends TestCase $this->assertEmpty(DB::select("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '$db_name'")); } + /** @test */ + public function database_creation_can_be_queued() + { + Queue::fake(); + + config()->set('tenancy.queue_database_creation', true); + $db_name = 'testdatabase' . $this->randomString(10) . '.sqlite'; + app(DatabaseManager::class)->create($db_name, 'sqlite'); + + Queue::assertPushed(QueuedTenantDatabaseCreator::class); + } + /** @test */ public function database_deletion_can_be_queued() {