diff --git a/phpunit.xml b/phpunit.xml index 2a0531cfd..7469c5341 100755 --- a/phpunit.xml +++ b/phpunit.xml @@ -7,8 +7,7 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="false" -> + stopOnFailure="true"> ./tests/unit diff --git a/src/Database/Adapter.php b/src/Database/Adapter.php index bac76fc73..715cab030 100644 --- a/src/Database/Adapter.php +++ b/src/Database/Adapter.php @@ -388,19 +388,6 @@ public function withTransaction(callable $callback): mixed } catch (\Throwable $action) { try { $this->rollbackTransaction(); - - if ( - $action instanceof DuplicateException || - $action instanceof RestrictedException || - $action instanceof AuthorizationException || - $action instanceof RelationshipException || - $action instanceof ConflictException || - $action instanceof LimitException - ) { - $this->inTransaction = 0; - throw $action; - } - } catch (\Throwable $rollback) { if ($attempts < $retries) { \usleep($sleep * ($attempts + 1)); @@ -411,6 +398,18 @@ public function withTransaction(callable $callback): mixed throw $rollback; } + if ( + $action instanceof DuplicateException || + $action instanceof RestrictedException || + $action instanceof AuthorizationException || + $action instanceof RelationshipException || + $action instanceof ConflictException || + $action instanceof LimitException + ) { + $this->inTransaction = 0; + throw $action; + } + if ($attempts < $retries) { \usleep($sleep * ($attempts + 1)); continue; diff --git a/tests/e2e/Adapter/Scopes/CollectionTests.php b/tests/e2e/Adapter/Scopes/CollectionTests.php index 5178a414d..44c82191d 100644 --- a/tests/e2e/Adapter/Scopes/CollectionTests.php +++ b/tests/e2e/Adapter/Scopes/CollectionTests.php @@ -44,6 +44,23 @@ public function testCreateListExistsDeleteCollection(): void /** @var Database $database */ $database = static::getDatabase(); + + $database->createCollection('shmuel', permissions: [ + Permission::create(Role::any()), + Permission::read(Role::any()), + ]); + + $database->createDocument('shmuel', new Document([ + '$id' => 'doc1', + ])); + + $database->createDocument('shmuel', new Document([ + '$id' => 'doc1', + ])); + + $this->assertEquals(1,222); + + $this->assertInstanceOf('Utopia\Database\Document', $database->createCollection('actors', permissions: [ Permission::create(Role::any()), Permission::read(Role::any()),