@@ -19,11 +19,10 @@ class GroupingTest extends TestCase
1919 */
2020 public function test_with_no_attribute ()
2121 {
22- $ router = $ this ->router ();
23-
24- $ router ->group ([], function (Router $ router ) {
25- $ router ->get ('/ ' , $ this ->controller ());
26- })->dispatch ();
22+ $ router = $ this ->router ()
23+ ->group ([], function (Router $ router ) {
24+ $ router ->get ('/ ' , $ this ->controller ());
25+ })->dispatch ();
2726
2827 $ this ->assertEquals ('OK ' , $ this ->outputOf ($ router ));
2928 }
@@ -35,11 +34,10 @@ public function test_with_a_middleware()
3534 {
3635 $ middleware = new SampleMiddleware (666 );
3736
38- $ router = $ this ->router ();
39-
40- $ router ->group (['middleware ' => $ middleware ], function (Router $ router ) {
41- $ router ->get ('/ ' , $ this ->controller ());
42- })->dispatch ();
37+ $ router = $ this ->router ()
38+ ->group (['middleware ' => $ middleware ], function (Router $ router ) {
39+ $ router ->get ('/ ' , $ this ->controller ());
40+ })->dispatch ();
4341
4442 $ this ->assertEquals ('OK ' , $ this ->outputOf ($ router ));
4543 $ this ->assertContains ($ middleware ->content , SampleMiddleware::$ output );
@@ -53,11 +51,10 @@ public function test_with_route_and_group_middleware()
5351 $ groupMiddleware = new SampleMiddleware (13 );
5452 $ routeMiddleware = new SampleMiddleware (666 );
5553
56- $ router = $ this ->router ();
57-
58- $ router ->group (['middleware ' => $ groupMiddleware ], function (Router $ router ) use ($ routeMiddleware ) {
59- $ router ->get ('/ ' , $ this ->controller (), $ routeMiddleware );
60- })->dispatch ();
54+ $ router = $ this ->router ()
55+ ->group (['middleware ' => $ groupMiddleware ], function (Router $ router ) use ($ routeMiddleware ) {
56+ $ router ->get ('/ ' , $ this ->controller (), $ routeMiddleware );
57+ })->dispatch ();
6158
6259 $ this ->assertEquals ('OK ' , $ this ->outputOf ($ router ));
6360 $ this ->assertContains ($ groupMiddleware ->content , SampleMiddleware::$ output );
@@ -72,13 +69,12 @@ public function test_nested_groups_with_middleware()
7269 $ group1Middleware = new SampleMiddleware (mt_rand (1 , 9999999 ));
7370 $ group2Middleware = new SampleMiddleware (mt_rand (1 , 9999999 ));
7471
75- $ router = $ this ->router ();
76-
77- $ router ->group (['middleware ' => $ group1Middleware ], function (Router $ router ) use ($ group2Middleware ) {
78- $ router ->group (['middleware ' => $ group2Middleware ], function (Router $ router ) {
79- $ router ->get ('/ ' , $ this ->controller ());
80- });
81- })->dispatch ();
72+ $ router = $ this ->router ()
73+ ->group (['middleware ' => $ group1Middleware ], function (Router $ router ) use ($ group2Middleware ) {
74+ $ router ->group (['middleware ' => $ group2Middleware ], function (Router $ router ) {
75+ $ router ->get ('/ ' , $ this ->controller ());
76+ });
77+ })->dispatch ();
8278
8379 $ this ->assertEquals ('OK ' , $ this ->outputOf ($ router ));
8480 $ this ->assertContains ($ group1Middleware ->content , SampleMiddleware::$ output );
@@ -92,11 +88,10 @@ public function test_with_a_prefix()
9288 {
9389 $ this ->mockRequest (HttpMethods::GET , 'http://example.com/group/page ' );
9490
95- $ router = $ this ->router ();
96-
97- $ router ->group (['prefix ' => '/group ' ], function (Router $ router ) {
98- $ router ->get ('/page ' , $ this ->controller ());
99- })->dispatch ();
91+ $ router = $ this ->router ()
92+ ->group (['prefix ' => '/group ' ], function (Router $ router ) {
93+ $ router ->get ('/page ' , $ this ->controller ());
94+ })->dispatch ();
10095
10196 $ this ->assertEquals ('OK ' , $ this ->outputOf ($ router ));
10297 }
@@ -108,13 +103,12 @@ public function test_nested_groups_with_prefix()
108103 {
109104 $ this ->mockRequest (HttpMethods::GET , 'http://example.com/group1/group2/page ' );
110105
111- $ router = $ this ->router ();
112-
113- $ router ->group (['prefix ' => '/group1 ' ], function (Router $ router ) {
114- $ router ->group (['prefix ' => '/group2 ' ], function (Router $ router ) {
115- $ router ->get ('/page ' , $ this ->controller ());
116- });
117- })->dispatch ();
106+ $ router = $ this ->router ()
107+ ->group (['prefix ' => '/group1 ' ], function (Router $ router ) {
108+ $ router ->group (['prefix ' => '/group2 ' ], function (Router $ router ) {
109+ $ router ->get ('/page ' , $ this ->controller ());
110+ });
111+ })->dispatch ();
118112
119113 $ this ->assertEquals ('OK ' , $ this ->outputOf ($ router ));
120114 }
@@ -126,11 +120,10 @@ public function test_with_namespace()
126120 {
127121 $ namespace = 'MiladRahimi\PhpRouter\Tests\Classes ' ;
128122
129- $ router = $ this ->router ();
130-
131- $ router ->group (['namespace ' => $ namespace ], function (Router $ router ) {
132- $ router ->get ('/ ' , 'SampleController@home ' );
133- })->dispatch ();
123+ $ router = $ this ->router ()
124+ ->group (['namespace ' => $ namespace ], function (Router $ router ) {
125+ $ router ->get ('/ ' , 'SampleController@home ' );
126+ })->dispatch ();
134127
135128 $ this ->assertEquals ('Home ' , $ this ->outputOf ($ router ));
136129 }
@@ -142,11 +135,10 @@ public function test_with_domain()
142135 {
143136 $ this ->mockRequest (HttpMethods::GET , 'http://sub.domain.tld/ ' );
144137
145- $ router = $ this ->router ();
146-
147- $ router ->group (['domain ' => 'sub.domain.tld ' ], function (Router $ router ) {
148- $ router ->get ('/ ' , $ this ->controller ());
149- })->dispatch ();
138+ $ router = $ this ->router ()
139+ ->group (['domain ' => 'sub.domain.tld ' ], function (Router $ router ) {
140+ $ router ->get ('/ ' , $ this ->controller ());
141+ })->dispatch ();
150142
151143 $ this ->assertEquals ('OK ' , $ this ->outputOf ($ router ));
152144 }
@@ -158,11 +150,10 @@ public function test_with_group_and_route_domain_it_should_only_consider_route_d
158150 {
159151 $ this ->mockRequest (HttpMethods::GET , 'http://sub2.domain.com/ ' );
160152
161- $ router = $ this ->router ();
162-
163- $ router ->group (['domain ' => 'sub1.domain.com ' ], function (Router $ router ) {
164- $ router ->get ('/ ' , $ this ->controller (), [], 'sub2.domain.com ' );
165- })->dispatch ();
153+ $ router = $ this ->router ()
154+ ->group (['domain ' => 'sub1.domain.com ' ], function (Router $ router ) {
155+ $ router ->get ('/ ' , $ this ->controller (), [], 'sub2.domain.com ' );
156+ })->dispatch ();
166157
167158 $ this ->assertEquals ('OK ' , $ this ->outputOf ($ router ));
168159 }
@@ -174,14 +165,13 @@ public function test_nested_groups_with_domain_it_should_consider_the_inner_grou
174165 {
175166 $ this ->mockRequest (HttpMethods::GET , 'http://sub2.domain.com/ ' );
176167
177- $ router = $ this ->router ();
168+ $ router = $ this ->router ()
169+ ->group (['domain ' => 'sub1.domain.com ' ], function (Router $ router ) {
170+ $ router ->group (['domain ' => 'sub2.domain.com ' ], function (Router $ router ) {
171+ $ router ->get ('/ ' , $ this ->controller ());
178172
179- $ router ->group (['domain ' => 'sub1.domain.com ' ], function (Router $ router ) {
180- $ router ->group (['domain ' => 'sub2.domain.com ' ], function (Router $ router ) {
181- $ router ->get ('/ ' , $ this ->controller ());
182-
183- });
184- })->dispatch ();
173+ });
174+ })->dispatch ();
185175
186176 $ this ->assertEquals ('OK ' , $ this ->outputOf ($ router ));
187177 }
@@ -191,13 +181,11 @@ public function test_nested_groups_with_domain_it_should_consider_the_inner_grou
191181 */
192182 public function test_naming_it_should_remove_existing_name_before_the_group ()
193183 {
194- $ router = $ this ->router ();
195-
196- $ router ->name ('NameForNothing ' );
197-
198- $ router ->group ([], function (Router $ router ) {
199- $ router ->get ('/ ' , $ this ->controller ());
200- })->dispatch ();
184+ $ router = $ this ->router ()
185+ ->name ('NameForNothing ' )
186+ ->group ([], function (Router $ router ) {
187+ $ router ->get ('/ ' , $ this ->controller ());
188+ })->dispatch ();
201189
202190 $ this ->assertEquals ('OK ' , $ this ->outputOf ($ router ));
203191 $ this ->assertFalse ($ router ->currentRoute ()->getName () == 'NameForNothing ' );
0 commit comments