|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OpCacheGUITest\Unit\Network; |
|
4
|
|
|
|
|
5
|
|
|
use OpCacheGUI\Network\Route; |
|
6
|
|
|
use PHPUnit\Framework\TestCase; |
|
7
|
|
|
|
|
8
|
|
|
class RouteTest extends TestCase |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @covers OpCacheGUI\Network\Route::__construct |
|
12
|
|
|
* @covers OpCacheGUI\Network\Route::matchesRequest |
|
13
|
|
|
*/ |
|
14
|
|
|
public function testMatchesRequestNoMatch() |
|
15
|
|
|
{ |
|
16
|
|
|
$route = new Route('id', 'GET', function () {}); |
|
17
|
|
|
|
|
18
|
|
|
$this->assertFalse($route->matchesRequest('notid', 'notGET')); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @covers OpCacheGUI\Network\Route::__construct |
|
23
|
|
|
* @covers OpCacheGUI\Network\Route::matchesRequest |
|
24
|
|
|
*/ |
|
25
|
|
|
public function testMatchesRequestNoMatchIdentifier() |
|
26
|
|
|
{ |
|
27
|
|
|
$route = new Route('id', 'GET', function () {}); |
|
28
|
|
|
|
|
29
|
|
|
$this->assertFalse($route->matchesRequest('notid', 'GET')); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @covers OpCacheGUI\Network\Route::__construct |
|
34
|
|
|
* @covers OpCacheGUI\Network\Route::matchesRequest |
|
35
|
|
|
*/ |
|
36
|
|
|
public function testMatchesRequestNoMatchVerb() |
|
37
|
|
|
{ |
|
38
|
|
|
$route = new Route('id', 'GET', function () {}); |
|
39
|
|
|
|
|
40
|
|
|
$this->assertFalse($route->matchesRequest('id', 'notGET')); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @covers OpCacheGUI\Network\Route::__construct |
|
45
|
|
|
* @covers OpCacheGUI\Network\Route::matchesRequest |
|
46
|
|
|
*/ |
|
47
|
|
|
public function testMatchesRequestValid() |
|
48
|
|
|
{ |
|
49
|
|
|
$route = new Route('id', 'GET', function () {}); |
|
50
|
|
|
|
|
51
|
|
|
$this->assertTrue($route->matchesRequest('id', 'GET')); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @covers OpCacheGUI\Network\Route::__construct |
|
56
|
|
|
* @covers OpCacheGUI\Network\Route::run |
|
57
|
|
|
*/ |
|
58
|
|
|
public function testRun() |
|
59
|
|
|
{ |
|
60
|
|
|
$route = new Route('id', 'GET', function () { |
|
61
|
|
|
return 'foo'; |
|
62
|
|
|
}); |
|
63
|
|
|
|
|
64
|
|
|
$this->assertSame('foo', $route->run()); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|