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
|
|
|
|