More database tests
This commit is contained in:
parent
b5e478966b
commit
50b1eb902a
|
@ -9,7 +9,6 @@ class BaseProjects extends BaseConsole
|
|||
/**
|
||||
* @var Client
|
||||
*/
|
||||
protected $projectClient = null;
|
||||
protected $projectsDemoEmail = '';
|
||||
protected $projectsDemoPassword = '';
|
||||
|
||||
|
@ -17,12 +16,6 @@ class BaseProjects extends BaseConsole
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->projectClient = new Client();
|
||||
|
||||
$this->projectClient
|
||||
->setEndpoint($this->endpoint)
|
||||
;
|
||||
|
||||
$this->projectsDemoEmail = 'user.' . rand(0,1000000) . '@appwrite.io';
|
||||
$this->projectsDemoPassword = 'password.' . rand(0,1000000);
|
||||
}
|
||||
|
@ -36,7 +29,7 @@ class BaseProjects extends BaseConsole
|
|||
|
||||
public function projectRegister($projectId)
|
||||
{
|
||||
$response = $this->projectClient->call(Client::METHOD_POST, '/auth/register', [
|
||||
$response = $this->client->call(Client::METHOD_POST, '/auth/register', [
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
|
|
|
@ -71,24 +71,36 @@ class ProjectDatabaseTest extends BaseProjects
|
|||
'password' => $this->demoPassword,
|
||||
'session' => $session,
|
||||
'projectUid' => $project['body']['$uid'],
|
||||
'projectAPIKeyUid' => $key['body']['$uid'],
|
||||
'projectAPIKeySecret' => $key['body']['secret'],
|
||||
'projectSession' => $this->projectClient->parseCookie($user['headers']['set-cookie'])['a-session-' . $project['body']['$uid']],
|
||||
'projectSession' => $this->client->parseCookie($user['headers']['set-cookie'])['a-session-' . $project['body']['$uid']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testRegisterSuccess
|
||||
*/
|
||||
public function testProjectsList($data) {
|
||||
$response = $this->client->call(Client::METHOD_GET, '/projects', [
|
||||
'origin' => 'http://localhost',
|
||||
public function testCollectionCreateSuccess($data) {
|
||||
$collection = $this->client->call(Client::METHOD_POST, '/database', [
|
||||
'content-type' => 'application/json',
|
||||
'cookie' => 'a-session-console=' . $data['session'],
|
||||
], []);
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
'x-appwrite-key' => $data['projectAPIKeySecret'],
|
||||
], [
|
||||
'name' => 'Test Collection',
|
||||
'read' => ['*'],
|
||||
'write' => ['role:1', 'role:2'],
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertIsArray($response['body']);
|
||||
$this->assertEquals($collection['headers']['status-code'], 201);
|
||||
$this->assertEquals($collection['body']['$collection'], 0);
|
||||
$this->assertEquals($collection['body']['name'], 'Test Collection');
|
||||
$this->assertIsArray($collection['body']['$permissions']);
|
||||
$this->assertIsArray($collection['body']['$permissions']['read']);
|
||||
$this->assertIsArray($collection['body']['$permissions']['write']);
|
||||
$this->assertEquals(count($collection['body']['$permissions']['read']), 1);
|
||||
$this->assertEquals(count($collection['body']['$permissions']['write']), 2);
|
||||
|
||||
return [
|
||||
'collectionId' => $collection['body']['$uid']
|
||||
];
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue