Fixed tests removed redundant $collection attribute
This commit is contained in:
parent
f19cd3ddb8
commit
1ecd9c865e
|
@ -93,7 +93,6 @@ $attributesCallback = function ($attribute, $response, $dbForExternal, $database
|
|||
//
|
||||
// TODO@kodumbeats should $signed and $filters be part of the response model?
|
||||
$attribute = new Document([
|
||||
'$collection' => $collectionId,
|
||||
'$id' => $attributeId,
|
||||
'type' => $type,
|
||||
'size' => $size,
|
||||
|
@ -460,7 +459,6 @@ App::post('/v1/database/collections/:collectionId/attributes/string')
|
|||
/** @var Appwrite\Event\Event $audits */
|
||||
|
||||
return $attributesCallback(new Document([
|
||||
'$collection' => $collectionId,
|
||||
'$id' => $attributeId,
|
||||
'type' => Database::VAR_STRING,
|
||||
'size' => $size,
|
||||
|
@ -498,7 +496,6 @@ App::post('/v1/database/collections/:collectionId/attributes/email')
|
|||
/** @var Appwrite\Event\Event $audits */
|
||||
|
||||
return $attributesCallback(new Document([
|
||||
'$collection' => $collectionId,
|
||||
'$id' => $attributeId,
|
||||
'type' => Database::VAR_STRING,
|
||||
'size' => 254,
|
||||
|
@ -537,7 +534,6 @@ App::post('/v1/database/collections/:collectionId/attributes/ip')
|
|||
/** @var Appwrite\Event\Event $audits */
|
||||
|
||||
return $attributesCallback(new Document([
|
||||
'$collection' => $collectionId,
|
||||
'$id' => $attributeId,
|
||||
'type' => Database::VAR_STRING,
|
||||
'size' => 39,
|
||||
|
@ -577,7 +573,6 @@ App::post('/v1/database/collections/:collectionId/attributes/url')
|
|||
/** @var Appwrite\Event\Event $audits */
|
||||
|
||||
return $attributesCallback(new Document([
|
||||
'$collection' => $collectionId,
|
||||
'$id' => $attributeId,
|
||||
'type' => Database::VAR_STRING,
|
||||
'size' => $size,
|
||||
|
@ -618,7 +613,6 @@ App::post('/v1/database/collections/:collectionId/attributes/integer')
|
|||
/** @var Appwrite\Event\Event $audits */
|
||||
|
||||
return $attributesCallback(new Document([
|
||||
'$collection' => $collectionId,
|
||||
'$id' => $attributeId,
|
||||
'type' => Database::VAR_INTEGER,
|
||||
'size' => 0,
|
||||
|
@ -663,7 +657,6 @@ App::post('/v1/database/collections/:collectionId/attributes/float')
|
|||
/** @var Appwrite\Event\Event $audits */
|
||||
|
||||
return $attributesCallback(new Document([
|
||||
'$collection' => $collectionId,
|
||||
'$id' => $attributeId,
|
||||
'type' => Database::VAR_FLOAT,
|
||||
'required' => $required,
|
||||
|
@ -706,7 +699,6 @@ App::post('/v1/database/collections/:collectionId/attributes/boolean')
|
|||
/** @var Appwrite\Event\Event $audits */
|
||||
|
||||
return $attributesCallback(new Document([
|
||||
'$collection' => $collectionId,
|
||||
'$id' => $attributeId,
|
||||
'type' => Database::VAR_BOOLEAN,
|
||||
'size' => 0,
|
||||
|
@ -833,7 +825,6 @@ App::delete('/v1/database/collections/:collectionId/attributes/:attributeId')
|
|||
$attribute = null;
|
||||
foreach ($attributes as $a) {
|
||||
if ($a->getId() === $attributeId) {
|
||||
$attribute = $a->setAttribute('$collection', $collectionId); // set the collectionId
|
||||
break; // break once attribute is found
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,6 @@ App::post('/v1/projects')
|
|||
|
||||
$project = $dbForConsole->createDocument('projects', new Document([
|
||||
'$id' => $projectId == 'unique()' ? $dbForConsole->getId() : $projectId,
|
||||
'$collection' => 'projects',
|
||||
'$read' => ['team:' . $teamId],
|
||||
'$write' => ['team:' . $teamId . '/owner', 'team:' . $teamId . '/developer'],
|
||||
'name' => $name,
|
||||
|
|
|
@ -56,12 +56,12 @@ App::get('/')
|
|||
;
|
||||
|
||||
if ('console' === $project->getId() || $project->isEmpty()) {
|
||||
$whitlistRoot = App::getEnv('_APP_CONSOLE_WHITELIST_ROOT', 'enabled');
|
||||
$whitelistRoot = App::getEnv('_APP_CONSOLE_WHITELIST_ROOT', 'enabled');
|
||||
|
||||
if($whitlistRoot !== 'disabled') {
|
||||
$sum = $dbForConsole->count('users', [], APP_LIMIT_USERS);
|
||||
if($whitelistRoot !== 'disabled') {
|
||||
$count = $dbForConsole->count('users', [], 1);
|
||||
|
||||
if($sum !== 0) {
|
||||
if($count !== 0) {
|
||||
return $response->redirect('/auth/signin');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,21 +68,18 @@ trait DatabaseBase
|
|||
]);
|
||||
|
||||
$this->assertEquals($title['headers']['status-code'], 201);
|
||||
$this->assertEquals($title['body']['$collection'], $data['moviesId']);
|
||||
$this->assertEquals($title['body']['$id'], 'title');
|
||||
$this->assertEquals($title['body']['type'], 'string');
|
||||
$this->assertEquals($title['body']['size'], 256);
|
||||
$this->assertEquals($title['body']['required'], true);
|
||||
|
||||
$this->assertEquals($releaseYear['headers']['status-code'], 201);
|
||||
$this->assertEquals($releaseYear['body']['$collection'], $data['moviesId']);
|
||||
$this->assertEquals($releaseYear['body']['$id'], 'releaseYear');
|
||||
$this->assertEquals($releaseYear['body']['type'], 'integer');
|
||||
$this->assertEquals($releaseYear['body']['size'], 0);
|
||||
$this->assertEquals($releaseYear['body']['required'], true);
|
||||
|
||||
$this->assertEquals($actors['headers']['status-code'], 201);
|
||||
$this->assertEquals($actors['body']['$collection'], $data['moviesId']);
|
||||
$this->assertEquals($actors['body']['$id'], 'actors');
|
||||
$this->assertEquals($actors['body']['type'], 'string');
|
||||
$this->assertEquals($actors['body']['size'], 256);
|
||||
|
@ -98,9 +95,6 @@ trait DatabaseBase
|
|||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), []);
|
||||
|
||||
$this->assertEquals($movies['body']['$id'], $title['body']['$collection']);
|
||||
$this->assertEquals($movies['body']['$id'], $releaseYear['body']['$collection']);
|
||||
$this->assertEquals($movies['body']['$id'], $actors['body']['$collection']);
|
||||
$this->assertIsArray($movies['body']['attributesInQueue']);
|
||||
$this->assertCount(0, $movies['body']['attributesInQueue']);
|
||||
$this->assertIsArray($movies['body']['attributes']);
|
||||
|
@ -128,7 +122,6 @@ trait DatabaseBase
|
|||
]);
|
||||
|
||||
$this->assertEquals($titleIndex['headers']['status-code'], 201);
|
||||
$this->assertEquals($titleIndex['body']['$collection'], $data['moviesId']);
|
||||
$this->assertEquals($titleIndex['body']['$id'], 'titleIndex');
|
||||
$this->assertEquals($titleIndex['body']['type'], 'fulltext');
|
||||
$this->assertCount(1, $titleIndex['body']['attributes']);
|
||||
|
@ -143,7 +136,6 @@ trait DatabaseBase
|
|||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), []);
|
||||
|
||||
$this->assertEquals($movies['body']['$id'], $titleIndex['body']['$collection']);
|
||||
$this->assertIsArray($movies['body']['indexes']);
|
||||
$this->assertCount(1, $movies['body']['indexes']);
|
||||
$this->assertEquals($movies['body']['indexes'][0]['$id'], $titleIndex['body']['$id']);
|
||||
|
@ -221,7 +213,6 @@ trait DatabaseBase
|
|||
]);
|
||||
|
||||
$this->assertEquals($document1['headers']['status-code'], 201);
|
||||
$this->assertEquals($document1['body']['$collection'], $data['moviesId']);
|
||||
$this->assertEquals($document1['body']['title'], 'Captain America');
|
||||
$this->assertEquals($document1['body']['releaseYear'], 1944);
|
||||
$this->assertIsArray($document1['body']['$read']);
|
||||
|
@ -233,7 +224,6 @@ trait DatabaseBase
|
|||
$this->assertEquals($document1['body']['actors'][1], 'Samuel Jackson');
|
||||
|
||||
$this->assertEquals($document2['headers']['status-code'], 201);
|
||||
$this->assertEquals($document2['body']['$collection'], $data['moviesId']);
|
||||
$this->assertEquals($document2['body']['title'], 'Spider-Man: Far From Home');
|
||||
$this->assertEquals($document2['body']['releaseYear'], 2019);
|
||||
$this->assertIsArray($document2['body']['$read']);
|
||||
|
@ -246,7 +236,6 @@ trait DatabaseBase
|
|||
$this->assertEquals($document2['body']['actors'][2], 'Samuel Jackson');
|
||||
|
||||
$this->assertEquals($document3['headers']['status-code'], 201);
|
||||
$this->assertEquals($document3['body']['$collection'], $data['moviesId']);
|
||||
$this->assertEquals($document3['body']['title'], 'Spider-Man: Homecoming');
|
||||
$this->assertEquals($document3['body']['releaseYear'], 2017);
|
||||
$this->assertIsArray($document3['body']['$read']);
|
||||
|
@ -545,7 +534,6 @@ trait DatabaseBase
|
|||
]);
|
||||
|
||||
$id = $document['body']['$id'];
|
||||
$collection = $document['body']['$collection'];
|
||||
|
||||
$this->assertEquals($document['headers']['status-code'], 201);
|
||||
$this->assertEquals($document['body']['title'], 'Thor: Ragnaroc');
|
||||
|
@ -553,7 +541,7 @@ trait DatabaseBase
|
|||
$this->assertEquals($document['body']['$read'][1], 'user:testx');
|
||||
$this->assertEquals($document['body']['$write'][1], 'user:testy');
|
||||
|
||||
$document = $this->client->call(Client::METHOD_PATCH, '/database/collections/' . $collection . '/documents/' . $id, array_merge([
|
||||
$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()), [
|
||||
|
@ -566,13 +554,12 @@ trait DatabaseBase
|
|||
$this->assertEquals($document['body']['title'], 'Thor: Ragnarok');
|
||||
$this->assertEquals($document['body']['releaseYear'], 2017);
|
||||
|
||||
$document = $this->client->call(Client::METHOD_GET, '/database/collections/' . $collection . '/documents/' . $id, array_merge([
|
||||
$document = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents/' . $id, array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$id = $document['body']['$id'];
|
||||
$collection = $document['body']['$collection'];
|
||||
|
||||
$this->assertEquals($document['headers']['status-code'], 200);
|
||||
$this->assertEquals($document['body']['title'], 'Thor: Ragnarok');
|
||||
|
@ -601,25 +588,24 @@ trait DatabaseBase
|
|||
]);
|
||||
|
||||
$id = $document['body']['$id'];
|
||||
$collection = $document['body']['$collection'];
|
||||
|
||||
$this->assertEquals($document['headers']['status-code'], 201);
|
||||
|
||||
$document = $this->client->call(Client::METHOD_GET, '/database/collections/' . $collection . '/documents/' . $id, array_merge([
|
||||
$document = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents/' . $id, array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals($document['headers']['status-code'], 200);
|
||||
|
||||
$document = $this->client->call(Client::METHOD_DELETE, '/database/collections/' . $collection . '/documents/' . $id, array_merge([
|
||||
$document = $this->client->call(Client::METHOD_DELETE, '/database/collections/' . $data['moviesId'] . '/documents/' . $id, array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals($document['headers']['status-code'], 204);
|
||||
|
||||
$document = $this->client->call(Client::METHOD_GET, '/database/collections/' . $collection . '/documents/' . $id, array_merge([
|
||||
$document = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents/' . $id, array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
@ -988,7 +974,6 @@ trait DatabaseBase
|
|||
$id = $document['body']['$id'];
|
||||
|
||||
$this->assertEquals($document['headers']['status-code'], 201);
|
||||
$this->assertEquals($document['body']['$collection'], $data['moviesId']);
|
||||
$this->assertEquals($document['body']['title'], 'Captain America');
|
||||
$this->assertEquals($document['body']['releaseYear'], 1944);
|
||||
$this->assertIsArray($document['body']['$read']);
|
||||
|
|
|
@ -170,8 +170,6 @@ class DatabaseCustomServerTest extends Scope
|
|||
|
||||
$unneededId = $unneeded['body']['$id'];
|
||||
|
||||
$this->assertEquals($collection['body']['$id'], $firstName['body']['$collection']);
|
||||
$this->assertEquals($collection['body']['$id'], $lastName['body']['$collection']);
|
||||
$this->assertIsArray($collection['body']['attributes']);
|
||||
$this->assertCount(3, $collection['body']['attributes']);
|
||||
$this->assertEquals($collection['body']['attributes'][0]['$id'], $firstName['body']['$id']);
|
||||
|
@ -195,8 +193,6 @@ class DatabaseCustomServerTest extends Scope
|
|||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), []);
|
||||
|
||||
$this->assertEquals($collection['body']['$id'], $firstName['body']['$collection']);
|
||||
$this->assertEquals($collection['body']['$id'], $lastName['body']['$collection']);
|
||||
$this->assertIsArray($collection['body']['attributes']);
|
||||
$this->assertCount(2, $collection['body']['attributes']);
|
||||
$this->assertEquals($collection['body']['attributes'][0]['$id'], $firstName['body']['$id']);
|
||||
|
@ -267,7 +263,6 @@ class DatabaseCustomServerTest extends Scope
|
|||
]);
|
||||
|
||||
$this->assertEquals($document1['headers']['status-code'], 201);
|
||||
$this->assertEquals($document1['body']['$collection'], $collectionId);
|
||||
$this->assertIsArray($document1['body']['$read']);
|
||||
$this->assertIsArray($document1['body']['$write']);
|
||||
$this->assertCount(1, $document1['body']['$read']);
|
||||
|
@ -276,7 +271,6 @@ class DatabaseCustomServerTest extends Scope
|
|||
$this->assertEquals($document1['body']['lastName'], 'Holland');
|
||||
|
||||
$this->assertEquals($document2['headers']['status-code'], 201);
|
||||
$this->assertEquals($document2['body']['$collection'], $collectionId);
|
||||
$this->assertIsArray($document2['body']['$read']);
|
||||
$this->assertIsArray($document2['body']['$write']);
|
||||
$this->assertCount(1, $document2['body']['$read']);
|
||||
|
|
|
@ -72,10 +72,8 @@ trait WebhooksBase
|
|||
]);
|
||||
|
||||
$this->assertEquals($firstName['headers']['status-code'], 201);
|
||||
$this->assertEquals($firstName['body']['$collection'], $data['actorsId']);
|
||||
$this->assertEquals($firstName['body']['$id'], 'firstName');
|
||||
$this->assertEquals($lastName['headers']['status-code'], 201);
|
||||
$this->assertEquals($lastName['body']['$collection'], $data['actorsId']);
|
||||
$this->assertEquals($lastName['body']['$id'], 'lastName');
|
||||
|
||||
// wait for database worker to kick in
|
||||
|
|
|
@ -70,7 +70,6 @@ class WebhooksCustomServerTest extends Scope
|
|||
]);
|
||||
|
||||
$this->assertEquals($index['headers']['status-code'], 201);
|
||||
$this->assertEquals($index['body']['$collection'], $data['actorsId']);
|
||||
$this->assertEquals($index['body']['$id'], 'fullname');
|
||||
|
||||
// wait for database worker to create index
|
||||
|
|
Loading…
Reference in a new issue