diff --git a/tests/e2e/BaseProjects.php b/tests/e2e/BaseProjects.php index ec44b5cd3d..0c3f74741c 100644 --- a/tests/e2e/BaseProjects.php +++ b/tests/e2e/BaseProjects.php @@ -9,7 +9,6 @@ class BaseProjects extends BaseConsole /** * @var Client */ - protected $projectClient = null; protected $projectsDemoEmail = ''; protected $projectsDemoPassword = ''; @@ -17,12 +16,6 @@ public function setUp() { 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 @@ public function tearDown() 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, diff --git a/tests/e2e/ProjectDatabaseTest.php b/tests/e2e/ProjectDatabaseTest.php index 17f0c08d49..ac6f8f17f7 100644 --- a/tests/e2e/ProjectDatabaseTest.php +++ b/tests/e2e/ProjectDatabaseTest.php @@ -71,24 +71,36 @@ public function testRegisterSuccess() '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'] + ]; + } } \ No newline at end of file