-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest.php
43 lines (33 loc) · 1.05 KB
/
Test.php
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
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use ZankoKhaledi\PhpSimpleRouter\Router;
require_once __DIR__ . '/App/Controllers/FooController.php';
class Test extends TestCase
{
protected string $baseUri = 'http://localhost:8000';
public function test_get_route()
{
$request = Router::assertRequest($this->baseUri);
$response = $request->assertGet('/foo', []);
$this->assertEquals(200, $response->status());
$this->assertJson($response->json());
$this->assertSame(json_encode([
'name' => 'Zanko'
]), $response->body());
}
public function test_zanko_post()
{
$request = Router::assertRequest($this->baseUri);
$response = $request->assertPost('/foo', [
'form_params' => [
'name' => 'Teddy'
]
]);
$this->assertEquals(201, $response->status());
$this->assertJson($response->json());
$this->assertSame(json_encode([
'name' => 'Foo'
]), $response->json());
}
}