Passed
Pull Request — main (#19)
by Chema
02:28
created

RouterTest::test_get_route_found()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 13
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpLightningTest\Unit\Router;
6
7
use PhpLightning\Router\Router;
8
use PHPUnit\Framework\TestCase;
9
10
final class RouterTest extends TestCase
11
{
12
    public function test_404_no_route_found(): void
13
    {
14
        $router = Router::withServer([
15
            'REQUEST_METHOD' => 'GET',
16
            'REQUEST_URI' => '/foo/?bar=123000',
17
        ]);
18
19
        $router->listen();
20
21
        $this->expectOutputString('404: route \'/foo\' not found');
22
    }
23
24
    public function test_get_route_found(): void
25
    {
26
        $router = Router::withServer([
27
            'REQUEST_METHOD' => 'GET',
28
            'REQUEST_URI' => '/foo/?bar=123000',
29
        ]);
30
        $router->get('/foo', static function (): void {
31
            echo 'route found';
32
        });
33
34
        $router->listen();
35
36
        $this->expectOutputString('route found');
37
    }
38
}
39