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