From c9e2e15545e42814425e62b725ebc1658b750dd9 Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 30 Sep 2025 08:20:21 +0300 Subject: [PATCH 1/2] Delete schema fails --- tests/e2e/Adapter/Scopes/GeneralTests.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/e2e/Adapter/Scopes/GeneralTests.php b/tests/e2e/Adapter/Scopes/GeneralTests.php index 1664273c1..0081a1f96 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,8 +437,13 @@ public function testSharedTablesTenantPerDocument(): void return; } - if ($database->exists(__FUNCTION__)) { + try { + /** + * MirrorTest returning false $database->exists(__FUNCTION__) + */ $database->delete(__FUNCTION__); + } catch (\Throwable $e) { + } $database From 9cc17c394682952ffd499ff98750382321bfca3a Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 30 Sep 2025 09:08:00 +0300 Subject: [PATCH 2/2] Delete schema in mirrow adapter --- tests/e2e/Adapter/MirrorTest.php | 40 ++++++++++------------- tests/e2e/Adapter/Scopes/GeneralTests.php | 11 ++----- 2 files changed, 21 insertions(+), 30 deletions(-) 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 0081a1f96..b4bab2067 100644 --- a/tests/e2e/Adapter/Scopes/GeneralTests.php +++ b/tests/e2e/Adapter/Scopes/GeneralTests.php @@ -437,17 +437,12 @@ public function testSharedTablesTenantPerDocument(): void return; } - try { - /** - * MirrorTest returning false $database->exists(__FUNCTION__) - */ - $database->delete(__FUNCTION__); - } catch (\Throwable $e) { - + if ($database->exists('sharedTablesTenantPerDocument')) { + $database->delete('sharedTablesTenantPerDocument'); } $database - ->setDatabase(__FUNCTION__) + ->setDatabase('sharedTablesTenantPerDocument') ->setNamespace('') ->setSharedTables(true) ->setTenant(null)