Update tests

This commit is contained in:
Jake Barnby
2025-08-19 00:38:23 +12:00
parent 867a950abd
commit 6dd058d6e1
3 changed files with 85 additions and 85 deletions
@@ -493,7 +493,7 @@ trait DatabasesBase
sleep(1);
/**
* Update attribute size to exceed Index maximum length
* Update column size to exceed Index maximum length
*/
$attribute = $this->client->call(Client::METHOD_PATCH, '/tablesdb/'.$databaseId.'/tables/'.$table['body']['$id'].'/columns/string/'.$attribute['body']['key'], array_merge([
'content-type' => 'application/json',
@@ -533,7 +533,7 @@ trait DatabasesBase
],
]);
// Create enum attribute
// Create enum column
$attribute = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $database['body']['$id'] . '/tables/' . $players['body']['$id'] . '/columns/enum', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -551,7 +551,7 @@ trait DatabasesBase
\sleep(2);
// Update enum attribute
// Update enum column
$attribute = $this->client->call(Client::METHOD_PATCH, '/tablesdb/' . $database['body']['$id'] . '/tables/' . $players['body']['$id'] . '/columns/enum/' . $attribute['body']['key'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -1417,7 +1417,7 @@ trait DatabasesBase
]), [
'key' => 'integers-order',
'type' => 'key',
'columns' => ['integers'], // array attribute
'columns' => ['integers'], // array column
'orders' => ['DESC'], // Check order is removed in API
]);
@@ -1430,7 +1430,7 @@ trait DatabasesBase
]), [
'key' => 'integers-size',
'type' => 'key',
'columns' => ['integers'], // array attribute
'columns' => ['integers'], // array column
]);
$this->assertEquals(202, $index2['headers']['status-code']);
@@ -2033,7 +2033,7 @@ trait DatabasesBase
$this->assertEquals(204, $deleteResponse['headers']['status-code']);
if ($this->getSide() === 'client') {
// Skipped on server side: Creating a document with no permissions results in an empty permissions array, whereas on client side it assigns permissions to the current user
// Skipped on server side: Creating a row with no permissions results in an empty permissions array, whereas on client side it assigns permissions to the current user
// test without passing permissions
$document = $this->client->call(Client::METHOD_PUT, '/tablesdb/' . $databaseId . '/tables/' . $data['moviesId'] . '/rows/' . $rowId, array_merge([
@@ -2133,7 +2133,7 @@ trait DatabasesBase
$this->assertEquals(204, $deleteResponse['headers']['status-code']);
// upsertion for the related document without passing permissions
// upsertion for the related row without passing permissions
// data should get added
$newPersonId = ID::unique();
$personNoPerm = $this->client->call(Client::METHOD_PUT, '/tablesdb/' . $databaseId . '/tables/' . $person['body']['$id'] . '/rows/' . $newPersonId, array_merge([
@@ -2232,7 +2232,7 @@ trait DatabasesBase
$this->assertEquals(2019, $rows['body']['rows'][0]['releaseYear']);
$this->assertCount(3, $rows['body']['rows']);
// changing description attribute to be null by default instead of empty string
// changing description column to be null by default instead of empty string
$patchNull = $this->client->call(Client::METHOD_PATCH, '/tablesdb/' . $databaseId . '/tables/' . $data['moviesId'] . '/columns/string/description', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -3762,15 +3762,15 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'key' => 'attribute',
'key' => 'column',
'size' => 64,
'required' => true,
]);
$this->assertEquals(202, $attribute['headers']['status-code'], 202);
$this->assertEquals('attribute', $attribute['body']['key']);
$this->assertEquals('column', $attribute['body']['key']);
// wait for db to add attribute
// wait for db to add column
sleep(2);
$index = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/indexes', array_merge([
@@ -3786,7 +3786,7 @@ trait DatabasesBase
$this->assertEquals(202, $index['headers']['status-code']);
$this->assertEquals('key_attribute', $index['body']['key']);
// wait for db to add attribute
// wait for db to add column
sleep(2);
$row1 = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/rows', array_merge([
@@ -3795,7 +3795,7 @@ trait DatabasesBase
], $this->getHeaders()), [
'rowId' => ID::unique(),
'data' => [
'attribute' => 'one',
'column' => 'one',
],
'permissions' => [
Permission::read(Role::user($user)),
@@ -3812,7 +3812,7 @@ trait DatabasesBase
], $this->getHeaders()), [
'rowId' => ID::unique(),
'data' => [
'attribute' => 'one',
'column' => 'one',
],
'permissions' => [
Permission::update(Role::user($user)),
@@ -3829,7 +3829,7 @@ trait DatabasesBase
], [
'rowId' => ID::unique(),
'data' => [
'attribute' => 'one',
'column' => 'one',
],
'permissions' => [
Permission::read(Role::user(ID::custom('other'))),
@@ -3952,13 +3952,13 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'key' => 'attribute',
'key' => 'column',
'size' => 64,
'required' => true,
]);
$this->assertEquals(202, $attribute['headers']['status-code'], 202);
$this->assertEquals('attribute', $attribute['body']['key']);
$this->assertEquals('column', $attribute['body']['key']);
\sleep(2);
@@ -3983,7 +3983,7 @@ trait DatabasesBase
], $this->getHeaders()), [
'rowId' => ID::unique(),
'data' => [
'attribute' => 'one',
'column' => 'one',
],
'permissions' => [
Permission::read(Role::user($user)),
@@ -4000,7 +4000,7 @@ trait DatabasesBase
], $this->getHeaders()), [
'rowId' => ID::unique(),
'data' => [
'attribute' => 'one',
'column' => 'one',
],
'permissions' => [
Permission::update(Role::user($user)),
@@ -4017,7 +4017,7 @@ trait DatabasesBase
], [
'rowId' => ID::unique(),
'data' => [
'attribute' => 'one',
'column' => 'one',
],
'permissions' => [
Permission::read(Role::user(ID::custom('other2'))),
@@ -4302,7 +4302,7 @@ trait DatabasesBase
$moviesId = $movies['body']['$id'];
// create attribute
// create column
$title = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $moviesId . '/columns/string', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -4849,7 +4849,7 @@ trait DatabasesBase
],
]);
// Create album name attribute
// Create album name column
$this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $albums['body']['$id'] . '/columns/string', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -4875,7 +4875,7 @@ trait DatabasesBase
],
]);
// Create artist name attribute
// Create artist name column
$this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $artists['body']['$id'] . '/columns/string', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -5001,7 +5001,7 @@ trait DatabasesBase
],
]);
// Create sport name attribute
// Create sport name column
$this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $sports['body']['$id'] . '/columns/string', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -5027,7 +5027,7 @@ trait DatabasesBase
],
]);
// Create player name attribute
// Create player name column
$this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $players['body']['$id'] . '/columns/string', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -6872,7 +6872,7 @@ trait DatabasesBase
]);
$tableId = $table['body']['$id'];
// Add integer attribute
// Add integer column
$this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/columns/integer', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -6940,7 +6940,7 @@ trait DatabasesBase
]), ['max' => 8]);
$this->assertEquals(400, $err['headers']['status-code']);
// Test attribute not found
// Test column not found
$notFound = $this->client->call(Client::METHOD_PATCH, "/tablesdb/$databaseId/tables/$tableId/rows/$rowId/unknown/increment", array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -6986,7 +6986,7 @@ trait DatabasesBase
$tableId = $table['body']['$id'];
// Add integer attribute
// Add integer column
$this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/columns/integer', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -7050,7 +7050,7 @@ trait DatabasesBase
]), ['min' => 7]);
$this->assertEquals(400, $err['headers']['status-code']);
// Test type error on non-numeric attribute
// Test type error on non-numeric column
$typeErr = $this->client->call(Client::METHOD_PATCH, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/rows/' . $rowId . '/count/decrement', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -34,7 +34,7 @@ class DatabasesCustomClientTest extends Scope
$databaseId = $database['body']['$id'];
// Collection aliases write to create, update, delete
// table aliases write to create, update, delete
$movies = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -109,7 +109,7 @@ class DatabasesCustomClientTest extends Scope
public function testUpdateWithoutPermission(): array
{
// If document has been created by server and client tried to update it without adjusting permissions, permission validation should be skipped
// If row has been created by server and client tried to update it without adjusting permissions, permission validation should be skipped
// As a part of preparation, we get ID of currently logged-in user
$response = $this->client->call(Client::METHOD_GET, '/account', array_merge([
@@ -132,7 +132,7 @@ class DatabasesCustomClientTest extends Scope
$this->assertEquals('Test Database', $database['body']['name']);
$databaseId = $database['body']['$id'];
// Create collection
// Create table
$response = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -145,7 +145,7 @@ class DatabasesCustomClientTest extends Scope
]);
$this->assertEquals(201, $response['headers']['status-code']);
// Add attribute to collection
// Add column to table
$response = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/permissionCheck/columns/string', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -160,7 +160,7 @@ class DatabasesCustomClientTest extends Scope
// Wait for database worker to finish creating attributes
sleep(2);
// Creating document by server, give read permission to our user + some other user
// Creating row by server, give read permission to our user + some other user
$response = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/permissionCheck/rows', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -180,7 +180,7 @@ class DatabasesCustomClientTest extends Scope
$this->assertEquals(201, $response['headers']['status-code']);
// Update document
// Update row
// This is the point of this test. We should be allowed to do this action, and it should not fail on permission check
$response = $this->client->call(Client::METHOD_PATCH, '/tablesdb/' . $databaseId . '/tables/permissionCheck/rows/permissionCheckDocument', array_merge([
'content-type' => 'application/json',
@@ -193,7 +193,7 @@ class DatabasesCustomClientTest extends Scope
$this->assertEquals(200, $response['headers']['status-code']);
// Get name of the document, should be the new one
// Get name of the row, should be the new one
$response = $this->client->call(Client::METHOD_GET, '/tablesdb/' . $databaseId . '/tables/permissionCheck/rows/permissionCheckDocument', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -202,7 +202,7 @@ class DatabasesCustomClientTest extends Scope
$this->assertEquals("AppwriteExpert", $response['body']['name']);
// Cleanup to prevent collision with other tests
// Delete collection
// Delete table
$response = $this->client->call(Client::METHOD_DELETE, '/tablesdb/' . $databaseId . '/tables/permissionCheck', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -212,10 +212,10 @@ class DatabasesCustomClientTest extends Scope
$this->assertEquals(204, $response['headers']['status-code']);
// Wait for database worker to finish deleting collection
// Wait for database worker to finish deleting table
sleep(2);
// Make sure collection has been deleted
// Make sure table has been deleted
$response = $this->client->call(Client::METHOD_GET, '/tablesdb/' . $databaseId . '/tables/permissionCheck', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -241,7 +241,7 @@ class DatabasesCustomClientTest extends Scope
$databaseId = $database['body']['$id'];
// Creating collection 1
// Creating table 1
$table1 = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -258,7 +258,7 @@ class DatabasesCustomClientTest extends Scope
]
]);
// Creating collection 2
// Creating table 2
$table2 = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -277,7 +277,7 @@ class DatabasesCustomClientTest extends Scope
\sleep(2);
// Creating two way relationship between collection 1 and collection 2 from collection 1
// Creating two way relationship between table 1 and table 2 from table 1
$relation = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -293,7 +293,7 @@ class DatabasesCustomClientTest extends Scope
\sleep(3);
// Update relation from collection 2 to on delete restrict
// Update relation from table 2 to on delete restrict
$this->client->call(Client::METHOD_PATCH, '/tablesdb/' . $databaseId . '/tables/' . $table2['body']['$id'] . '/columns/' . $table1['body']['$id'] . '/relationship', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -455,7 +455,7 @@ class DatabasesCustomClientTest extends Scope
$this->assertEquals(202, $relation['headers']['status-code']);
$this->assertArrayHasKey('twoWayKey', $relation['body']);
// Second RelationshipManyToMany on Same collections
// Second RelationshipManyToMany on Same tables
$relation = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -472,7 +472,7 @@ class DatabasesCustomClientTest extends Scope
\sleep(2);
$this->assertEquals(409, $relation['body']['code']);
$this->assertEquals('Creating more than one "manyToMany" relationship on the same table is currently not permitted.', $relation['body']['message']);
$this->assertEquals('Creating more than one "manyToMany" relationship on the same collection is currently not permitted.', $relation['body']['message']);
}
public function testUpdateWithoutRelationPermission(): void
@@ -489,14 +489,14 @@ class DatabasesCustomClientTest extends Scope
$databaseId = $database['body']['$id'];
// Creating collection 1
// Creating table 1
$table1 = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'tableId' => ID::custom('collection1'),
'name' => ID::custom('collection1'),
'tableId' => ID::custom('table1'),
'name' => ID::custom('table1'),
'rowSecurity' => false,
'permissions' => [
Permission::create(Role::user($userId)),
@@ -505,14 +505,14 @@ class DatabasesCustomClientTest extends Scope
]
]);
// Creating collection 2
// Creating table 2
$table2 = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'tableId' => ID::custom('collection2'),
'name' => ID::custom('collection2'),
'tableId' => ID::custom('table2'),
'name' => ID::custom('table2'),
'rowSecurity' => false,
'permissions' => [
Permission::read(Role::user($userId)),
@@ -524,8 +524,8 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'tableId' => ID::custom('collection3'),
'name' => ID::custom('collection3'),
'tableId' => ID::custom('table3'),
'name' => ID::custom('table3'),
'rowSecurity' => false,
'permissions' => [
Permission::create(Role::user($userId)),
@@ -539,8 +539,8 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'tableId' => ID::custom('collection4'),
'name' => ID::custom('collection4'),
'tableId' => ID::custom('table4'),
'name' => ID::custom('table4'),
'rowSecurity' => false,
'permissions' => [
Permission::read(Role::user($userId)),
@@ -552,8 +552,8 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'tableId' => ID::custom('collection5'),
'name' => ID::custom('collection5'),
'tableId' => ID::custom('table5'),
'name' => ID::custom('table5'),
'rowSecurity' => false,
'permissions' => [
Permission::create(Role::user($userId)),
@@ -562,7 +562,7 @@ class DatabasesCustomClientTest extends Scope
]
]);
// Creating one to one relationship from collection 1 to colletion 2
// Creating one to one relationship from table 1 to colletion 2
$this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/columns/relationship', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -575,7 +575,7 @@ class DatabasesCustomClientTest extends Scope
'key' => $table2['body']['$id']
]);
// Creating one to one relationship from collection 2 to colletion 3
// Creating one to one relationship from table 2 to colletion 3
$this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $table2['body']['$id'] . '/columns/relationship', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -588,7 +588,7 @@ class DatabasesCustomClientTest extends Scope
'key' => $table3['body']['$id']
]);
// Creating one to one relationship from collection 3 to colletion 4
// Creating one to one relationship from table 3 to colletion 4
$this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $table3['body']['$id'] . '/columns/relationship', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -601,7 +601,7 @@ class DatabasesCustomClientTest extends Scope
'key' => $table4['body']['$id']
]);
// Creating one to one relationship from collection 4 to colletion 5
// Creating one to one relationship from table 4 to colletion 5
$this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $table4['body']['$id'] . '/columns/relationship', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -675,7 +675,7 @@ class DatabasesCustomClientTest extends Scope
]);
\sleep(2);
// Creating parent document with a child reference to test the permissions
// Creating parent row with a child reference to test the permissions
$parentDocument = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/rows', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -704,7 +704,7 @@ class DatabasesCustomClientTest extends Scope
]);
$this->assertEquals(201, $parentDocument['headers']['status-code']);
// This is the point of the test. We should not need any authorization permission to update the document with same data.
// This is the point of the test. We should not need any authorization permission to update the row with same data.
$response = $this->client->call(Client::METHOD_PATCH, '/tablesdb/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/rows/' . $table1['body']['$id'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -733,14 +733,14 @@ class DatabasesCustomClientTest extends Scope
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals($parentDocument['body'], $response['body']);
// Giving update permission of collection 3 to user.
$this->client->call(Client::METHOD_PUT, '/tablesdb/' . $databaseId . '/tables/collection3', array_merge([
// Giving update permission of table 3 to user.
$this->client->call(Client::METHOD_PUT, '/tablesdb/' . $databaseId . '/tables/table3', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'tableId' => ID::custom('collection3'),
'name' => ID::custom('collection3'),
'tableId' => ID::custom('table3'),
'name' => ID::custom('table3'),
'rowSecurity' => false,
'permissions' => [
Permission::create(Role::user($userId)),
@@ -777,9 +777,9 @@ class DatabasesCustomClientTest extends Scope
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(11, $response['body'][$table2['body']['$id']]['collection3']['Rating']);
$this->assertEquals(11, $response['body'][$table2['body']['$id']]['table3']['Rating']);
// We should not be allowed to update the document as we do not have permission for collection 2.
// We should not be allowed to update the row as we do not have permission for table 2.
$response = $this->client->call(Client::METHOD_PATCH, '/tablesdb/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/rows/' . $table1['body']['$id'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -796,7 +796,7 @@ class DatabasesCustomClientTest extends Scope
$this->assertEquals(401, $response['headers']['status-code']);
// We should not be allowed to update the document as we do not have permission for collection 2.
// We should not be allowed to update the row as we do not have permission for table 2.
$response = $this->client->call(Client::METHOD_PATCH, '/tablesdb/' . $databaseId . '/tables/' . $table2['body']['$id'] . '/rows/' . $table2['body']['$id'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -808,14 +808,14 @@ class DatabasesCustomClientTest extends Scope
$this->assertEquals(401, $response['headers']['status-code']);
// Removing update permission from collection 3.
$this->client->call(Client::METHOD_PUT, '/tablesdb/' . $databaseId . '/tables/collection3', array_merge([
// Removing update permission from table 3.
$this->client->call(Client::METHOD_PUT, '/tablesdb/' . $databaseId . '/tables/table3', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'tableId' => ID::custom('collection3'),
'name' => ID::custom('collection3'),
'tableId' => ID::custom('table3'),
'name' => ID::custom('table3'),
'rowSecurity' => false,
'permissions' => [
Permission::create(Role::user($userId)),
@@ -824,14 +824,14 @@ class DatabasesCustomClientTest extends Scope
]
]);
// Giving update permission to collection 2.
$this->client->call(Client::METHOD_PUT, '/tablesdb/' . $databaseId . '/tables/collection2', array_merge([
// Giving update permission to table 2.
$this->client->call(Client::METHOD_PUT, '/tablesdb/' . $databaseId . '/tables/table2', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'tableId' => ID::custom('collection2'),
'name' => ID::custom('collection2'),
'tableId' => ID::custom('table2'),
'name' => ID::custom('table2'),
'rowSecurity' => false,
'permissions' => [
Permission::create(Role::user($userId)),
@@ -841,13 +841,13 @@ class DatabasesCustomClientTest extends Scope
]
]);
// Creating collection 3 new document
// Creating table 3 new row
$response = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $table3['body']['$id'] . '/rows', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'rowId' => ID::custom('collection3Doc1'),
'rowId' => ID::custom('table3Doc1'),
'data' => [
'Rating' => '20'
]
@@ -855,7 +855,7 @@ class DatabasesCustomClientTest extends Scope
$this->assertEquals(201, $response['headers']['status-code']);
// We should be allowed to link a new document from collection 3 to collection 2.
// We should be allowed to link a new row from table 3 to table 2.
$response = $this->client->call(Client::METHOD_PATCH, '/tablesdb/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/rows/' . $table1['body']['$id'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -864,7 +864,7 @@ class DatabasesCustomClientTest extends Scope
'Title' => 'Captain America',
$table2['body']['$id'] => [
'$id' => ID::custom($table2['body']['$id']),
$table3['body']['$id'] => 'collection3Doc1',
$table3['body']['$id'] => 'table3Doc1',
]
]
]);
@@ -872,7 +872,7 @@ class DatabasesCustomClientTest extends Scope
$this->assertEquals(200, $response['headers']['status-code']);
// We should be allowed to link and create a new document from collection 3 to collection 2.
// We should be allowed to link and create a new row from table 3 to table 2.
$response = $this->client->call(Client::METHOD_PATCH, '/tablesdb/' . $databaseId . '/tables/' . $table1['body']['$id'] . '/rows/' . $table1['body']['$id'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@@ -882,7 +882,7 @@ class DatabasesCustomClientTest extends Scope
$table2['body']['$id'] => [
'$id' => ID::custom($table2['body']['$id']),
$table3['body']['$id'] => [
'$id' => ID::custom('collection3Doc2')
'$id' => ID::custom('table3Doc2')
],
]
]
@@ -173,7 +173,7 @@ class DatabasesPermissionsGuestTest extends Scope
$this->assertEquals(401, $privateResponse['headers']['status-code']);
// Create a row in private collection with API key so we can test that update and delete are also not allowed
// Create a row in private table with API key so we can test that update and delete are also not allowed
$privateResponse = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $privateTableId . '/rows', $this->getServerHeader(), [
'rowId' => ID::unique(),
'data' => [