ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
FastRoute\RouteCollectorTest Class Reference
+ Inheritance diagram for FastRoute\RouteCollectorTest:
+ Collaboration diagram for FastRoute\RouteCollectorTest:

Public Member Functions

 testShortcuts ()
 
 testGroups ()
 

Detailed Description

Definition at line 7 of file RouteCollectorTest.php.

Member Function Documentation

◆ testGroups()

FastRoute\RouteCollectorTest::testGroups ( )

Definition at line 32 of file RouteCollectorTest.php.

References $r, FastRoute\RouteCollector\addGroup(), FastRoute\RouteCollector\delete(), FastRoute\RouteCollector\get(), FastRoute\RouteCollector\head(), FastRoute\RouteCollector\patch(), FastRoute\RouteCollector\post(), and FastRoute\RouteCollector\put().

33  {
34  $r = new DummyRouteCollector();
35 
36  $r->delete('/delete', 'delete');
37  $r->get('/get', 'get');
38  $r->head('/head', 'head');
39  $r->patch('/patch', 'patch');
40  $r->post('/post', 'post');
41  $r->put('/put', 'put');
42 
43  $r->addGroup('/group-one', function (DummyRouteCollector $r) {
44  $r->delete('/delete', 'delete');
45  $r->get('/get', 'get');
46  $r->head('/head', 'head');
47  $r->patch('/patch', 'patch');
48  $r->post('/post', 'post');
49  $r->put('/put', 'put');
50 
51  $r->addGroup('/group-two', function (DummyRouteCollector $r) {
52  $r->delete('/delete', 'delete');
53  $r->get('/get', 'get');
54  $r->head('/head', 'head');
55  $r->patch('/patch', 'patch');
56  $r->post('/post', 'post');
57  $r->put('/put', 'put');
58  });
59  });
60 
61  $r->addGroup('/admin', function (DummyRouteCollector $r) {
62  $r->get('-some-info', 'admin-some-info');
63  });
64  $r->addGroup('/admin-', function (DummyRouteCollector $r) {
65  $r->get('more-info', 'admin-more-info');
66  });
67 
68  $expected = [
69  ['DELETE', '/delete', 'delete'],
70  ['GET', '/get', 'get'],
71  ['HEAD', '/head', 'head'],
72  ['PATCH', '/patch', 'patch'],
73  ['POST', '/post', 'post'],
74  ['PUT', '/put', 'put'],
75  ['DELETE', '/group-one/delete', 'delete'],
76  ['GET', '/group-one/get', 'get'],
77  ['HEAD', '/group-one/head', 'head'],
78  ['PATCH', '/group-one/patch', 'patch'],
79  ['POST', '/group-one/post', 'post'],
80  ['PUT', '/group-one/put', 'put'],
81  ['DELETE', '/group-one/group-two/delete', 'delete'],
82  ['GET', '/group-one/group-two/get', 'get'],
83  ['HEAD', '/group-one/group-two/head', 'head'],
84  ['PATCH', '/group-one/group-two/patch', 'patch'],
85  ['POST', '/group-one/group-two/post', 'post'],
86  ['PUT', '/group-one/group-two/put', 'put'],
87  ['GET', '/admin-some-info', 'admin-some-info'],
88  ['GET', '/admin-more-info', 'admin-more-info'],
89  ];
90 
91  $this->assertSame($expected, $r->routes);
92  }
$r
Definition: example_031.php:79
+ Here is the call graph for this function:

◆ testShortcuts()

FastRoute\RouteCollectorTest::testShortcuts ( )

Definition at line 9 of file RouteCollectorTest.php.

References $r.

10  {
11  $r = new DummyRouteCollector();
12 
13  $r->delete('/delete', 'delete');
14  $r->get('/get', 'get');
15  $r->head('/head', 'head');
16  $r->patch('/patch', 'patch');
17  $r->post('/post', 'post');
18  $r->put('/put', 'put');
19 
20  $expected = [
21  ['DELETE', '/delete', 'delete'],
22  ['GET', '/get', 'get'],
23  ['HEAD', '/head', 'head'],
24  ['PATCH', '/patch', 'patch'],
25  ['POST', '/post', 'post'],
26  ['PUT', '/put', 'put'],
27  ];
28 
29  $this->assertSame($expected, $r->routes);
30  }
$r
Definition: example_031.php:79

The documentation for this class was generated from the following file: