From 57e3e8f5f4104508dfa368083ec45efa54748194 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sat, 4 Oct 2025 21:10:50 +1300 Subject: [PATCH] Fix test scope --- .../Legacy/Transactions/TransactionsBase.php | 30 +++---------------- .../TransactionsConsoleClientTest.php | 3 +- .../TransactionsCustomClientTest.php | 3 +- .../TransactionsCustomServerTest.php | 3 +- .../Transactions/TransactionsBase.php | 30 +++---------------- 5 files changed, 14 insertions(+), 55 deletions(-) diff --git a/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsBase.php b/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsBase.php index 7c84295a4f..836f1ca966 100644 --- a/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsBase.php +++ b/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsBase.php @@ -1416,7 +1416,7 @@ trait TransactionsBase $transactionId = $transaction['body']['$id']; - // Try to update non-existent document + // Try to update non-existent document - should fail at staging time with early validation $response = $this->client->call(Client::METHOD_POST, "/databases/transactions/{$transactionId}/operations", array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -1433,20 +1433,9 @@ trait TransactionsBase ] ]); - $this->assertEquals(201, $response['headers']['status-code']); // Operation added + $this->assertEquals(404, $response['headers']['status-code']); // Document not found at staging time - // Commit should fail - $response = $this->client->call(Client::METHOD_PATCH, "/databases/transactions/{$transactionId}", array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - 'x-appwrite-key' => $this->getProject()['apiKey'] - ]), [ - 'commit' => true - ]); - - $this->assertEquals(404, $response['headers']['status-code']); // Document not found - - // Test delete non-existent document + // Test delete non-existent document - should also fail at staging time with early validation $transaction2 = $this->client->call(Client::METHOD_POST, '/databases/transactions', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -1470,18 +1459,7 @@ trait TransactionsBase ] ]); - $this->assertEquals(201, $response['headers']['status-code']); - - // Commit should fail - $response = $this->client->call(Client::METHOD_PATCH, "/databases/transactions/{$transactionId2}", array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - 'x-appwrite-key' => $this->getProject()['apiKey'] - ]), [ - 'commit' => true - ]); - - $this->assertEquals(404, $response['headers']['status-code']); // Document not found + $this->assertEquals(404, $response['headers']['status-code']); // Document not found at staging time } /** diff --git a/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsConsoleClientTest.php b/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsConsoleClientTest.php index 427e79fb3a..ef6e9d15d0 100644 --- a/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsConsoleClientTest.php +++ b/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsConsoleClientTest.php @@ -3,9 +3,10 @@ namespace Tests\E2E\Services\Databases\Legacy\Transactions; use Tests\E2E\Scopes\ProjectCustom; +use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideConsole; -class TransactionsConsoleClientTest +class TransactionsConsoleClientTest extends Scope { use TransactionsBase; use ProjectCustom; diff --git a/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsCustomClientTest.php b/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsCustomClientTest.php index 3ee685d778..cdc9a325dc 100644 --- a/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsCustomClientTest.php +++ b/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsCustomClientTest.php @@ -3,9 +3,10 @@ namespace Tests\E2E\Services\Databases\Legacy\Transactions; use Tests\E2E\Scopes\ProjectCustom; +use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideClient; -class TransactionsCustomClientTest +class TransactionsCustomClientTest extends Scope { use TransactionsBase; use ProjectCustom; diff --git a/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsCustomServerTest.php b/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsCustomServerTest.php index 425f731ef3..7b3d092128 100644 --- a/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsCustomServerTest.php +++ b/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsCustomServerTest.php @@ -3,9 +3,10 @@ namespace Tests\E2E\Services\Databases\Legacy\Transactions; use Tests\E2E\Scopes\ProjectCustom; +use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; -class TransactionsCustomServerTest +class TransactionsCustomServerTest extends Scope { use TransactionsBase; use ProjectCustom; diff --git a/tests/e2e/Services/Databases/TablesDB/Transactions/TransactionsBase.php b/tests/e2e/Services/Databases/TablesDB/Transactions/TransactionsBase.php index c972137cee..1ea8d0cc9a 100644 --- a/tests/e2e/Services/Databases/TablesDB/Transactions/TransactionsBase.php +++ b/tests/e2e/Services/Databases/TablesDB/Transactions/TransactionsBase.php @@ -1416,7 +1416,7 @@ trait TransactionsBase $transactionId = $transaction['body']['$id']; - // Try to update non-existent row + // Try to update non-existent row - should fail at staging time with early validation $response = $this->client->call(Client::METHOD_POST, "/tablesdb/transactions/{$transactionId}/operations", array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -1433,20 +1433,9 @@ trait TransactionsBase ] ]); - $this->assertEquals(201, $response['headers']['status-code']); // Operation added + $this->assertEquals(404, $response['headers']['status-code']); // Document not found at staging time - // Commit should fail - $response = $this->client->call(Client::METHOD_PATCH, "/tablesdb/transactions/{$transactionId}", array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - 'x-appwrite-key' => $this->getProject()['apiKey'] - ]), [ - 'commit' => true - ]); - - $this->assertEquals(404, $response['headers']['status-code']); // Document not found - - // Test delete non-existent row + // Test delete non-existent row - should also fail at staging time with early validation $transaction2 = $this->client->call(Client::METHOD_POST, '/tablesdb/transactions', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -1470,18 +1459,7 @@ trait TransactionsBase ] ]); - $this->assertEquals(201, $response['headers']['status-code']); - - // Commit should fail - $response = $this->client->call(Client::METHOD_PATCH, "/tablesdb/transactions/{$transactionId2}", array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - 'x-appwrite-key' => $this->getProject()['apiKey'] - ]), [ - 'commit' => true - ]); - - $this->assertEquals(404, $response['headers']['status-code']); // Document not found + $this->assertEquals(404, $response['headers']['status-code']); // Document not found at staging time } /**