1
0
Fork 0
mirror of synced 2024-07-03 05:31:38 +12:00
appwrite/tests/e2e/ConsoleTest.php

79 lines
2.3 KiB
PHP
Raw Normal View History

2019-09-14 16:37:37 +12:00
<?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',
'confirm' => 'http://localhost/confirm',
'success' => 'http://localhost/success',
'failure' => 'http://localhost/failure',
'name' => 'User 1',
]);
$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']);
}
}