HttpTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test() 0 29 1
A testResolver() 0 5 1
1
<?php
2
3
namespace Test;
4
5
use Basis\Http;
6
use Controller\Index;
7
use Basis\Test;
8
9
class HttpTest extends Test
10
{
11
    public function test()
12
    {
13
        $http = $this->app->get(Http::class);
14
15
        // index method
16
        $this->assertSame(['index', 'index'], $http->getChain('/'));
17
        $this->assertSame(['hello', 'index'], $http->getChain('/hello/'));
18
        $this->assertSame(['hello', 'index'], $http->getChain('/hello/////'));
19
        $this->assertSame(['hello', 'nekufa'], $http->getChain('/hello/nekufa'));
20
        $this->assertSame(['hello', 'nekufa'], $http->getChain('/hello/nekufa?querystring'));
21
22
        // class exists
23
        $this->assertTrue(class_exists(Index::class));
24
        $this->assertTrue(method_exists(Index::class, 'index'));
25
26
        // index routing
27
        $this->assertSame('index page', $http->process("/"));
28
        $this->assertSame('index page', $http->process("/index"));
29
        $this->assertSame('index page', $http->process("/index/index"));
30
31
        //
32
        $this->assertSame('url: ', $http->process("/dynamic"));
33
        $this->assertSame('url: ', $http->process("/dynamic/"));
34
        $this->assertSame('url: slug', $http->process("/dynamic/slug"));
35
        $this->assertSame('url: slug/sub', $http->process("/dynamic/slug/sub"));
36
37
        $meta = $this->app->dispatch('module.meta');
38
        $this->assertContains('index/index', $meta->routes);
39
    }
40
41
    public function testResolver()
42
    {
43
        $http = $this->app->get(Http::class);
44
        $this->assertSame('hello world!', $http->process("/index/hello"));
45
    }
46
}
47