diff --git a/tests/e2e/Adapter/MirrorTest.php b/tests/e2e/Adapter/MirrorTest.php index 71793b881..b0de36be2 100644 --- a/tests/e2e/Adapter/MirrorTest.php +++ b/tests/e2e/Adapter/MirrorTest.php @@ -71,34 +71,30 @@ protected static function getDatabase(bool $fresh = false): Mirror $database = new Mirror(self::$source, self::$destination); - // Handle cases where the source and destination databases are not in sync because of previous tests - if ($database->getSource()->exists('schema1')) { - $database->getSource()->setDatabase('schema1')->delete(); - } - if ($database->getDestination()->exists('schema1')) { - $database->getDestination()->setDatabase('schema1')->delete(); - } - if ($database->getSource()->exists('schema2')) { - $database->getSource()->setDatabase('schema2')->delete(); - } - if ($database->getDestination()->exists('schema2')) { - $database->getDestination()->setDatabase('schema2')->delete(); - } - if ($database->getSource()->exists('sharedTables')) { - $database->getSource()->setDatabase('sharedTables')->delete(); - } - if ($database->getDestination()->exists('sharedTables')) { - $database->getDestination()->setDatabase('sharedTables')->delete(); + $schemas = [ + 'utopiaTests', + 'schema1', + 'schema2', + 'sharedTables', + 'sharedTablesTenantPerDocument' + ]; + + /** + * Handle cases where the source and destination databases are not in sync because of previous tests + */ + foreach ($schemas as $schema) { + if ($database->getSource()->exists($schema)) { + $database->getSource()->setDatabase($schema)->delete(); + } + if ($database->getDestination()->exists($schema)) { + $database->getDestination()->setDatabase($schema)->delete(); + } } $database ->setDatabase('utopiaTests') ->setNamespace(static::$namespace = 'myapp_' . uniqid()); - if ($database->exists()) { - $database->delete(); - } - $database->create(); return self::$database = $database; diff --git a/tests/e2e/Adapter/Scopes/GeneralTests.php b/tests/e2e/Adapter/Scopes/GeneralTests.php index 1664273c1..b4bab2067 100644 --- a/tests/e2e/Adapter/Scopes/GeneralTests.php +++ b/tests/e2e/Adapter/Scopes/GeneralTests.php @@ -424,7 +424,9 @@ public function testNestedQueryValidation(): void public function testSharedTablesTenantPerDocument(): void { + /** @var Database $database */ $database = static::getDatabase(); + $sharedTables = $database->getSharedTables(); $tenantPerDocument = $database->getTenantPerDocument(); $namespace = $database->getNamespace(); @@ -435,12 +437,12 @@ public function testSharedTablesTenantPerDocument(): void return; } - if ($database->exists(__FUNCTION__)) { - $database->delete(__FUNCTION__); + if ($database->exists('sharedTablesTenantPerDocument')) { + $database->delete('sharedTablesTenantPerDocument'); } $database - ->setDatabase(__FUNCTION__) + ->setDatabase('sharedTablesTenantPerDocument') ->setNamespace('') ->setSharedTables(true) ->setTenant(null)