-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathBaseTest.php
More file actions
71 lines (59 loc) · 2.53 KB
/
Copy pathBaseTest.php
File metadata and controls
71 lines (59 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace Utopia\Http\Tests;
use Tests\E2E\Client;
trait BaseTest
{
public function testResponse()
{
$response = $this->client->call(Client::METHOD_GET, '/');
$this->assertEquals('Hello World!', $response['body']);
}
public function testResponseValue()
{
$response = $this->client->call(Client::METHOD_GET, '/value/123');
$this->assertEquals('123', $response['body']);
}
public function testChunkResponse()
{
$response = $this->client->call(Client::METHOD_GET, '/chunked');
$this->assertEquals('Hello World!', $response['body']);
}
public function testRedirect()
{
$response = $this->client->call(Client::METHOD_GET, '/redirect');
$this->assertEquals('Hello World!', $response['body']);
}
public function testFile()
{
$response = $this->client->call(Client::METHOD_GET, '/humans.txt');
$this->assertEquals(204, $response['headers']['status-code']);
}
public function testCookie()
{
// One cookie
$cookie = 'cookie1=value1';
$response = $this->client->call(Client::METHOD_GET, '/cookies', [ 'Cookie: ' . $cookie ]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals($cookie, $response['body']);
// Two cookiees
$cookie = 'cookie1=value1; cookie2=value2';
$response = $this->client->call(Client::METHOD_GET, '/cookies', [ 'Cookie: ' . $cookie ]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals($cookie, $response['body']);
// Two cookies without optional space
$cookie = 'cookie1=value1;cookie2=value2';
$response = $this->client->call(Client::METHOD_GET, '/cookies', [ 'Cookie: ' . $cookie ]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals($cookie, $response['body']);
// Cookie with "=" in value
$cookie = 'cookie1=value1=value2';
$response = $this->client->call(Client::METHOD_GET, '/cookies', [ 'Cookie: ' . $cookie ]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals($cookie, $response['body']);
// Case sensitivity for cookie names
$cookie = 'cookie1=v1; Cookie1=v2';
$response = $this->client->call(Client::METHOD_GET, '/cookies', [ 'Cookie: ' . $cookie ]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals($cookie, $response['body']);
}
}