Some relation tests
This commit is contained in:
parent
00c1418246
commit
038f4fc073
2 changed files with 5682 additions and 0 deletions
5606
composer.lock
generated
Normal file
5606
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -4,6 +4,7 @@ namespace Tests\E2E\Services\Databases;
|
||||||
|
|
||||||
use Appwrite\Extend\Exception;
|
use Appwrite\Extend\Exception;
|
||||||
use Tests\E2E\Client;
|
use Tests\E2E\Client;
|
||||||
|
use Utopia\Database\Database;
|
||||||
use Utopia\Database\DateTime;
|
use Utopia\Database\DateTime;
|
||||||
use Utopia\Database\Helpers\ID;
|
use Utopia\Database\Helpers\ID;
|
||||||
use Utopia\Database\Helpers\Permission;
|
use Utopia\Database\Helpers\Permission;
|
||||||
|
@ -232,6 +233,81 @@ trait DatabasesBase
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testCreateAttributes
|
||||||
|
*/
|
||||||
|
public function testRelations(array $data): array
|
||||||
|
{
|
||||||
|
$databaseId = $data['databaseId'];
|
||||||
|
$person = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||||
|
]), [
|
||||||
|
'collectionId' => 'person',
|
||||||
|
'name' => 'person',
|
||||||
|
'permissions' => [
|
||||||
|
Permission::read(Role::user($this->getUser()['$id'])),
|
||||||
|
//Permission::update(Role::user($this->getUser()['$id'])),
|
||||||
|
// Permission::delete(Role::user($this->getUser()['$id'])),
|
||||||
|
],
|
||||||
|
'documentSecurity' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$library = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||||
|
]), [
|
||||||
|
'collectionId' => 'library',
|
||||||
|
'name' => 'library',
|
||||||
|
'permissions' => [
|
||||||
|
Permission::read(Role::user($this->getUser()['$id'])),
|
||||||
|
//Permission::update(Role::user($this->getUser()['$id'])),
|
||||||
|
// Permission::delete(Role::user($this->getUser()['$id'])),
|
||||||
|
],
|
||||||
|
'documentSecurity' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$relation = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $person['body']['$id'] . '/attributes/relationship', array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||||
|
]), [
|
||||||
|
'key' => 'library',
|
||||||
|
'relatedCollectionId' => 'library',
|
||||||
|
'type' => Database::RELATION_ONE_TO_ONE,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$name = $this->client->call(Client::METHOD_POST, '/databases/' . $library['body']['$id'] . '/string', array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||||
|
]), [
|
||||||
|
'key' => 'name',
|
||||||
|
'size' => 255,
|
||||||
|
'required' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$area = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/string', array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||||
|
]), [
|
||||||
|
'key' => 'area',
|
||||||
|
'size' => 255,
|
||||||
|
'required' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
die;
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @depends testCreateAttributes
|
* @depends testCreateAttributes
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue