1
0
Fork 0
mirror of synced 2024-07-01 04:30:59 +12:00
appwrite/tests/e2e/ConsoleTest.php
2019-09-14 08:57:27 +03:00

81 lines
2.3 KiB
PHP

<?php
namespace Tests\E2E;
use Tests\E2E\Client;
use PHPUnit\Framework\TestCase;
class ConsoleTest extends TestCase
{
/**
* @var Client
*/
protected $client = null;
protected $endpoint = 'http://localhost/v1';
public function setUp()
{
$this->client = new Client(null);
$this->client
->setEndpoint($this->endpoint)
;
}
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' => 'username1@appwrite.io',
'password' => 'password',
'redirect' => 'http://localhost/confirm',
'success' => 'http://localhost/success',
'failure' => 'http://localhost/failure',
'name' => 'User 1',
]);
var_dump($response);
$this->assertEquals('http://localhost/failure', $response['headers']['location']);
$this->assertEquals("\n", $response['body']);
}
public function testLoginFailure()
{
$response = $this->client->call(Client::METHOD_POST, '/auth/login', [
'origin' => 'http://localhost',
'content-type' => 'application/json',
], [
'email' => 'username@appwrite.io',
'password' => 'password1',
'success' => 'http://localhost/success',
'failure' => 'http://localhost/failure',
]);
$this->assertEquals('http://localhost/failure', $response['headers']['location']);
$this->assertEquals("\n", $response['body']);
}
public function testLoginSuccess()
{
$response = $this->client->call(Client::METHOD_POST, '/auth/login', [
'origin' => 'http://localhost',
'content-type' => 'application/json',
], [
'email' => 'username@appwrite.io',
'password' => 'password',
'success' => 'http://localhost/success',
'failure' => 'http://localhost/failure',
]);
$this->assertEquals('http://localhost/success', $response['headers']['location']);
$this->assertEquals("\n", $response['body']);
}
}