More database tests
This commit is contained in:
parent
b5e478966b
commit
50b1eb902a
2 changed files with 23 additions and 18 deletions
|
@ -9,7 +9,6 @@ class BaseProjects extends BaseConsole
|
||||||
/**
|
/**
|
||||||
* @var Client
|
* @var Client
|
||||||
*/
|
*/
|
||||||
protected $projectClient = null;
|
|
||||||
protected $projectsDemoEmail = '';
|
protected $projectsDemoEmail = '';
|
||||||
protected $projectsDemoPassword = '';
|
protected $projectsDemoPassword = '';
|
||||||
|
|
||||||
|
@ -17,12 +16,6 @@ class BaseProjects extends BaseConsole
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->projectClient = new Client();
|
|
||||||
|
|
||||||
$this->projectClient
|
|
||||||
->setEndpoint($this->endpoint)
|
|
||||||
;
|
|
||||||
|
|
||||||
$this->projectsDemoEmail = 'user.' . rand(0,1000000) . '@appwrite.io';
|
$this->projectsDemoEmail = 'user.' . rand(0,1000000) . '@appwrite.io';
|
||||||
$this->projectsDemoPassword = 'password.' . rand(0,1000000);
|
$this->projectsDemoPassword = 'password.' . rand(0,1000000);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +29,7 @@ class BaseProjects extends BaseConsole
|
||||||
|
|
||||||
public function projectRegister($projectId)
|
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',
|
'origin' => 'http://localhost',
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
'x-appwrite-project' => $projectId,
|
'x-appwrite-project' => $projectId,
|
||||||
|
|
|
@ -71,24 +71,36 @@ class ProjectDatabaseTest extends BaseProjects
|
||||||
'password' => $this->demoPassword,
|
'password' => $this->demoPassword,
|
||||||
'session' => $session,
|
'session' => $session,
|
||||||
'projectUid' => $project['body']['$uid'],
|
'projectUid' => $project['body']['$uid'],
|
||||||
'projectAPIKeyUid' => $key['body']['$uid'],
|
|
||||||
'projectAPIKeySecret' => $key['body']['secret'],
|
'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
|
* @depends testRegisterSuccess
|
||||||
*/
|
*/
|
||||||
public function testProjectsList($data) {
|
public function testCollectionCreateSuccess($data) {
|
||||||
$response = $this->client->call(Client::METHOD_GET, '/projects', [
|
$collection = $this->client->call(Client::METHOD_POST, '/database', [
|
||||||
'origin' => 'http://localhost',
|
|
||||||
'content-type' => 'application/json',
|
'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->assertEquals($collection['headers']['status-code'], 201);
|
||||||
$this->assertIsArray($response['body']);
|
$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