1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Tests\Ds\Router\Adaptor; |
4
|
|
|
|
5
|
|
|
use Ds\Router\Adaptor\FastRouteAdaptor; |
6
|
|
|
use Ds\Router\Exceptions\RouterException; |
7
|
|
|
use Ds\Router\Interfaces\SerializerInterface; |
8
|
|
|
use Tests\Ds\Router\Helpers\Reflection; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class FastRouteAdaptorTest |
12
|
|
|
* @package Tests\Rs\Router\Adaptor |
13
|
|
|
*/ |
14
|
|
|
class FastRouteAdaptorTest extends \PHPUnit_Framework_TestCase |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var FastRouteAdaptor |
19
|
|
|
*/ |
20
|
|
|
public $fastRoute; |
21
|
|
|
/** |
22
|
|
|
* @var array |
23
|
|
|
*/ |
24
|
|
|
public $options; |
25
|
|
|
/** |
26
|
|
|
* @var \PHPUnit_Framework_MockObject_MockObject|SerializerInterface |
27
|
|
|
*/ |
28
|
|
|
public $serializer; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* |
32
|
|
|
*/ |
33
|
|
|
public function setUp() |
34
|
|
|
{ |
35
|
|
|
$this->options = [ |
36
|
|
|
'cacheDisabled' => true, |
37
|
|
|
'errorHandlers' => [ |
38
|
|
|
'default' => [ |
39
|
|
|
'handler' => 'errorController::method404', |
40
|
|
|
'name' => ['error'] |
41
|
|
|
] |
42
|
|
|
] |
43
|
|
|
]; |
44
|
|
|
|
45
|
|
|
$this->serializer = $this->getMockBuilder(SerializerInterface::class)->getMock(); |
46
|
|
|
$this->fastRoute = new FastRouteAdaptor($this->serializer, $this->options); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* |
51
|
|
|
*/ |
52
|
|
|
public function testConstructMissingOptions() |
53
|
|
|
{ |
54
|
|
|
$this->setExpectedException(RouterException::class); |
55
|
|
|
return new FastRouteAdaptor($this->serializer, []); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* |
60
|
|
|
*/ |
61
|
|
|
public function testIsCachedWithCacheEnabled() |
62
|
|
|
{ |
63
|
|
|
$expected = false; |
64
|
|
|
$adaptor = new FastRouteAdaptor($this->serializer, [ |
65
|
|
|
'cacheDisabled' => $expected, |
66
|
|
|
'cacheFile' => __DIR__, |
67
|
|
|
'errorHandlers' => [ |
68
|
|
|
'default' => [ |
69
|
|
|
'handler' => 'errorController::method404', |
70
|
|
|
'name' => ['error'] |
71
|
|
|
] |
72
|
|
|
] |
73
|
|
|
]); |
74
|
|
|
|
75
|
|
|
$options = Reflection::getProperty(FastRouteAdaptor::class, 'options', $adaptor); |
76
|
|
|
$this->assertEquals($expected, $options['cacheDisabled']); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* |
81
|
|
|
*/ |
82
|
|
|
public function testMatch() |
83
|
|
|
{ |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* |
88
|
|
|
*/ |
89
|
|
|
public function testGetCachedRoutes() |
90
|
|
|
{ |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* |
95
|
|
|
*/ |
96
|
|
|
public function testIsCached() |
97
|
|
|
{ |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Internal Methods |
102
|
|
|
*/ |
103
|
|
|
public function test_checkCacheExpires() |
104
|
|
|
{ |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* |
109
|
|
|
*/ |
110
|
|
|
public function test_getCachedDispatcher() |
111
|
|
|
{ |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* |
116
|
|
|
*/ |
117
|
|
|
public function test_createFastRouteHandler() |
118
|
|
|
{ |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* |
123
|
|
|
*/ |
124
|
|
|
public function test_findOptionsHandler() |
125
|
|
|
{ |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* |
130
|
|
|
*/ |
131
|
|
|
public function test_createRouterResponse() |
132
|
|
|
{ |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|