client = new Client(); $this->client ->setEndpoint($this->endpoint) ; $this->demoEmail = 'user.' . rand(0,1000000) . '@appwrite.io'; $this->demoPassword = 'password.' . rand(0,1000000); } public function tearDown() { $this->client = null; } public function testRegisterSuccess() { $response = $this->client->call(Client::METHOD_POST, '/auth/register', [ 'origin' => 'http://localhost', 'content-type' => 'application/json', ], [ 'email' => $this->demoEmail, 'password' => $this->demoPassword, 'redirect' => 'http://localhost/confirm', 'success' => 'http://localhost/success', 'failure' => 'http://localhost/failure', 'name' => 'Demo User', ]); $this->assertEquals('http://localhost/success', $response['headers']['location']); $this->assertEquals("\n", $response['body']); return [ 'demoEmail' => $this->demoEmail, 'demoPassword' => $this->demoPassword, ]; } /** * @depends testRegisterSuccess */ public function testLoginSuccess($data) { $response = $this->client->call(Client::METHOD_POST, '/auth/login', [ 'origin' => 'http://localhost', 'content-type' => 'application/json', ], [ 'email' => $data['demoEmail'], 'password' => $data['demoPassword'], 'success' => 'http://localhost/success', 'failure' => 'http://localhost/failure', ]); $session = $this->client->parseCookie($response['headers']['set-cookie'])['a-session-console']; var_dump($response['headers']); $this->assertEquals('http://localhost/success', $response['headers']['location']); $this->assertEquals("\n", $response['body']); return ['session' => $session]; } /** * @depends testLoginSuccess */ public function xtestLogoutSuccess($data) { $response = $this->client->call(Client::METHOD_DELETE, '/auth/logout', [ 'origin' => 'http://localhost', 'content-type' => 'application/json', 'cookie' => 'a-session-console=' . $data['session'], ], []); var_dump($response); $this->assertEquals('http://localhost/success', $response['headers']['location']); $this->assertEquals("\n", $response['body']); } // public function testLogoutFailure() // { // $response = $this->client->call(Client::METHOD_DELETE, '/auth/logout', [ // 'origin' => 'http://localhost', // 'content-type' => 'application/json', // ], []); // $this->assertEquals('401', $response['body']['code']); // } }