-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpTest.php
More file actions
33 lines (25 loc) · 884 Bytes
/
Copy pathHttpTest.php
File metadata and controls
33 lines (25 loc) · 884 Bytes
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
<?php
declare(strict_types=1);
use Infra\Enums\HttpMethod;
use Infra\Http\Request;
use Infra\Http\Response;
use Infra\Http\Router;
use Tests\Doubles\MockRequestHandler;
describe('http module', function () {
it('should return a response', function () {
$path = '/test';
$method = HttpMethod::GET;
$data = [
'test' => 'data',
];
$request = new Request($path, $method, $data);
$router = new Router($request);
$mockHandler = new MockRequestHandler(body: json_encode($data));
$router->get('/test', $mockHandler);
$response = $router->handleRequest();
expect($router)->toBeInstanceOf(Router::class)
->and($request)->toBeInstanceOf(Request::class)
->and($request->toArray())->toBe($data)
->and($response)->toBeInstanceOf(Response::class);
});
});