1
0
Fork 0
mirror of synced 2024-09-29 08:51:28 +13:00

remove dependency

This commit is contained in:
gepd 2022-06-20 18:24:51 -04:00 committed by GitHub
parent 43ed2591d0
commit dab6f97a31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1294,71 +1294,6 @@ trait DatabaseBase
return [];
}
/**
* @depends testCreateDocument
*/
public function testUpdatePermissionsWithEmptyPayload(array $data): array
{
$document = $this->client->call(Client::METHOD_POST, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'data' => [
'title' => 'Captain America',
'releaseYear' => 1944,
'actors' => [],
],
]);
$id = $document['body']['$id'];
$this->assertEquals($document['headers']['status-code'], 201);
$this->assertEquals($document['body']['title'], 'Captain America');
$this->assertEquals($document['body']['releaseYear'], 1944);
$this->assertIsArray($document['body']['$read']);
$this->assertIsArray($document['body']['$write']);
if ($this->getSide() == 'client') {
$this->assertCount(1, $document['body']['$read']);
$this->assertCount(1, $document['body']['$write']);
$this->assertEquals(['user:' . $this->getUser()['$id']], $document['body']['$read']);
$this->assertEquals(['user:' . $this->getUser()['$id']], $document['body']['$write']);
}
if ($this->getSide() == 'server') {
$this->assertCount(0, $document['body']['$read']);
$this->assertCount(0, $document['body']['$write']);
$this->assertEquals([], $document['body']['$read']);
$this->assertEquals([], $document['body']['$write']);
}
// Reset Permissions
$document = $this->client->call(Client::METHOD_PATCH, '/database/collections/' . $data['moviesId'] . '/documents/' . $id, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'data' => [],
'read' => [],
'write' => [],
]);
if ($this->getSide() == 'client') {
$this->assertEquals($document['headers']['status-code'], 401);
}
if ($this->getSide() == 'server') {
$this->assertEquals($document['headers']['status-code'], 200);
$this->assertCount(0, $document['body']['$read']);
$this->assertCount(0, $document['body']['$write']);
$this->assertEquals([], $document['body']['$read']);
$this->assertEquals([], $document['body']['$write']);
}
return $data;
}
/**
* @depends testCreateDocument
*/
@ -2227,4 +2162,66 @@ trait DatabaseBase
return $data;
}
public function testUpdatePermissionsWithEmptyPayload(array $data): array
{
$document = $this->client->call(Client::METHOD_POST, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'data' => [
'title' => 'Captain America',
'releaseYear' => 1944,
'actors' => [],
],
]);
$id = $document['body']['$id'];
$this->assertEquals($document['headers']['status-code'], 201);
$this->assertEquals($document['body']['title'], 'Captain America');
$this->assertEquals($document['body']['releaseYear'], 1944);
$this->assertIsArray($document['body']['$read']);
$this->assertIsArray($document['body']['$write']);
if ($this->getSide() == 'client') {
$this->assertCount(1, $document['body']['$read']);
$this->assertCount(1, $document['body']['$write']);
$this->assertEquals(['user:' . $this->getUser()['$id']], $document['body']['$read']);
$this->assertEquals(['user:' . $this->getUser()['$id']], $document['body']['$write']);
}
if ($this->getSide() == 'server') {
$this->assertCount(0, $document['body']['$read']);
$this->assertCount(0, $document['body']['$write']);
$this->assertEquals([], $document['body']['$read']);
$this->assertEquals([], $document['body']['$write']);
}
// Reset Permissions
$document = $this->client->call(Client::METHOD_PATCH, '/database/collections/' . $data['moviesId'] . '/documents/' . $id, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'data' => [],
'read' => [],
'write' => [],
]);
if ($this->getSide() == 'client') {
$this->assertEquals($document['headers']['status-code'], 401);
}
if ($this->getSide() == 'server') {
$this->assertEquals($document['headers']['status-code'], 200);
$this->assertCount(0, $document['body']['$read']);
$this->assertCount(0, $document['body']['$write']);
$this->assertEquals([], $document['body']['$read']);
$this->assertEquals([], $document['body']['$write']);
}
return $data;
}
}