|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Tests\integration; |
|
6
|
|
|
|
|
7
|
|
|
class DefaultTest extends BaseTestCase |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* Test that default endpoint show a help. |
|
11
|
|
|
*/ |
|
12
|
|
|
public function testApiHelp(): void |
|
13
|
|
|
{ |
|
14
|
|
|
$response = $this->runApp('GET', '/'); |
|
15
|
|
|
|
|
16
|
|
|
$result = (string) $response->getBody(); |
|
17
|
|
|
|
|
18
|
|
|
$this->assertEquals(200, $response->getStatusCode()); |
|
19
|
|
|
$this->assertEquals('application/json', $response->getHeaderLine('Content-Type')); |
|
20
|
|
|
$this->assertStringContainsString('status', $result); |
|
21
|
|
|
$this->assertStringContainsString('success', $result); |
|
22
|
|
|
$this->assertStringContainsString('version', $result); |
|
23
|
|
|
$this->assertStringContainsString('time', $result); |
|
24
|
|
|
$this->assertStringContainsString('endpoints', $result); |
|
25
|
|
|
$this->assertStringContainsString('help', $result); |
|
26
|
|
|
$this->assertStringNotContainsString('error', $result); |
|
27
|
|
|
$this->assertStringNotContainsString('Failed', $result); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Test that status endpoint, show the API status. |
|
32
|
|
|
*/ |
|
33
|
|
|
public function testStatus(): void |
|
34
|
|
|
{ |
|
35
|
|
|
$response = $this->runApp('GET', '/status'); |
|
36
|
|
|
|
|
37
|
|
|
$result = (string) $response->getBody(); |
|
38
|
|
|
|
|
39
|
|
|
$this->assertEquals(200, $response->getStatusCode()); |
|
40
|
|
|
$this->assertEquals('application/json', $response->getHeaderLine('Content-Type')); |
|
41
|
|
|
$this->assertStringContainsString('status', $result); |
|
42
|
|
|
$this->assertStringContainsString('success', $result); |
|
43
|
|
|
$this->assertStringContainsString('message', $result); |
|
44
|
|
|
$this->assertStringContainsString('stats', $result); |
|
45
|
|
|
$this->assertStringContainsString('MySQL', $result); |
|
46
|
|
|
$this->assertStringContainsString('Redis', $result); |
|
47
|
|
|
$this->assertStringContainsString('Logger', $result); |
|
48
|
|
|
$this->assertStringContainsString('version', $result); |
|
49
|
|
|
$this->assertStringContainsString('time', $result); |
|
50
|
|
|
$this->assertStringNotContainsString('error', $result); |
|
51
|
|
|
$this->assertStringNotContainsString('Failed', $result); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Test Route Not Found. |
|
56
|
|
|
*/ |
|
57
|
|
|
public function testRouteNotFound(): void |
|
58
|
|
|
{ |
|
59
|
|
|
$response = $this->runApp('GET', '/route-not-found'); |
|
60
|
|
|
|
|
61
|
|
|
$result = (string) $response->getBody(); |
|
62
|
|
|
|
|
63
|
|
|
$this->assertEquals(404, $response->getStatusCode()); |
|
64
|
|
|
$this->assertEquals('application/problem+json', $response->getHeaderLine('Content-Type')); |
|
65
|
|
|
$this->assertStringContainsString('error', $result); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|