@@ -186,10 +186,6 @@ public function testMapResources() {
186
186
$ result = Router::parse ('/posts/13 ' );
187
187
$ this ->assertEquals ($ expected , $ result );
188
188
189
- $ _SERVER ['REQUEST_METHOD ' ] = 'GET ' ;
190
- $ result = Router::parse ('/posts/add ' );
191
- $ this ->assertSame ([], $ result );
192
-
193
189
Router::reload ();
194
190
$ result = Router::mapResources ('Posts ' , ['id ' => '[a-z0-9_]+ ' ]);
195
191
$ this ->assertEquals (['posts ' ], $ result );
@@ -590,7 +586,6 @@ public function testUrlGenerationBasic() {
590
586
591
587
Router::reload ();
592
588
Router::connect ('/:plugin/:id/* ' , array ('controller ' => 'posts ' , 'action ' => 'view ' ), array ('id ' => $ ID ));
593
- Router::parse ('/ ' );
594
589
595
590
$ result = Router::url (array (
596
591
'plugin ' => 'cake_plugin ' ,
@@ -613,15 +608,13 @@ public function testUrlGenerationBasic() {
613
608
614
609
Router::reload ();
615
610
Router::connect ('/:controller/:action/:id ' , [], array ('id ' => $ ID ));
616
- Router::parse ('/ ' );
617
611
618
612
$ result = Router::url (array ('controller ' => 'posts ' , 'action ' => 'view ' , 'id ' => '1 ' ));
619
613
$ expected = '/posts/view/1 ' ;
620
614
$ this ->assertEquals ($ expected , $ result );
621
615
622
616
Router::reload ();
623
617
Router::connect ('/:controller/:id ' , array ('action ' => 'view ' ));
624
- Router::parse ('/ ' );
625
618
626
619
$ result = Router::url (array ('controller ' => 'posts ' , 'action ' => 'view ' , 'id ' => '1 ' ));
627
620
$ expected = '/posts/1 ' ;
@@ -634,7 +627,6 @@ public function testUrlGenerationBasic() {
634
627
635
628
Router::reload ();
636
629
Router::connect ('/:controller/:action ' );
637
- Router::parse ('/ ' );
638
630
$ request = new Request ();
639
631
$ request ->addParams (array (
640
632
'action ' => 'index ' ,
@@ -652,7 +644,6 @@ public function testUrlGenerationBasic() {
652
644
653
645
Router::reload ();
654
646
Router::connect ('/contact/:action ' , array ('plugin ' => 'contact ' , 'controller ' => 'contact ' ));
655
- Router::parse ('/ ' );
656
647
657
648
$ result = Router::url (array (
658
649
'plugin ' => 'contact ' ,
@@ -780,7 +771,6 @@ public function testUrlGenerationWithRegexQualifiedParams() {
780
771
array ('plugin ' => 'shows ' , 'controller ' => 'shows ' , 'action ' => 'calendar ' ),
781
772
array ('month ' => '0[1-9]|1[012] ' , 'year ' => '[12][0-9]{3} ' )
782
773
);
783
- Router::parse ('/ ' );
784
774
785
775
$ result = Router::url (array (
786
776
'plugin ' => 'shows ' ,
@@ -799,7 +789,6 @@ public function testUrlGenerationWithRegexQualifiedParams() {
799
789
array ('month ' => '0[1-9]|1[012] ' , 'year ' => '[12][0-9]{3} ' )
800
790
);
801
791
Router::connect ('/kalender/* ' , array ('plugin ' => 'shows ' , 'controller ' => 'shows ' , 'action ' => 'calendar ' ));
802
- Router::parse ('/ ' );
803
792
804
793
$ result = Router::url (array ('plugin ' => 'shows ' , 'controller ' => 'shows ' , 'action ' => 'calendar ' , 'min-forestilling ' ));
805
794
$ expected = '/kalender/min-forestilling ' ;
@@ -852,7 +841,6 @@ public function testUrlGenerationWithPrefix() {
852
841
Router::reload ();
853
842
Router::connect ('/admin/subscriptions/:action/* ' , array ('controller ' => 'subscribe ' , 'prefix ' => 'admin ' ));
854
843
Router::connect ('/admin/:controller/:action/* ' , array ('prefix ' => 'admin ' ));
855
- Router::parse ('/ ' );
856
844
857
845
$ request = new Request ();
858
846
$ request ->addParams (array (
@@ -888,7 +876,6 @@ public function testUrlGenerationWithPrefix() {
888
876
Router::setRequestInfo ($ request );
889
877
890
878
Router::connect ('/page/* ' , array ('controller ' => 'pages ' , 'action ' => 'view ' , 'prefix ' => 'admin ' ));
891
- Router::parse ('/ ' );
892
879
893
880
$ result = Router::url (array ('prefix ' => 'admin ' , 'controller ' => 'pages ' , 'action ' => 'view ' , 'my-page ' ));
894
881
$ expected = '/page/my-page ' ;
@@ -908,15 +895,13 @@ public function testUrlGenerationWithPrefix() {
908
895
$ request ->here = '/admin/pages/add ' ;
909
896
$ request ->webroot = '/ ' ;
910
897
Router::setRequestInfo ($ request );
911
- Router::parse ('/ ' );
912
898
913
899
$ result = Router::url (array ('plugin ' => null , 'controller ' => 'pages ' , 'action ' => 'add ' , 'id ' => false ));
914
900
$ expected = '/admin/pages/add ' ;
915
901
$ this ->assertEquals ($ expected , $ result );
916
902
917
903
Router::reload ();
918
904
Router::connect ('/admin/:controller/:action/* ' , array ('prefix ' => 'admin ' ));
919
- Router::parse ('/ ' );
920
905
$ request = new Request ();
921
906
$ request ->addParams (array (
922
907
'plugin ' => null ,
@@ -935,7 +920,6 @@ public function testUrlGenerationWithPrefix() {
935
920
936
921
Router::reload ();
937
922
Router::connect ('/admin/:controller/:action/:id ' , array ('prefix ' => 'admin ' ), array ('id ' => '[0-9]+ ' ));
938
- Router::parse ('/ ' );
939
923
$ request = new Request ();
940
924
Router::setRequestInfo (
941
925
$ request ->addParams (array (
@@ -957,7 +941,6 @@ public function testUrlGenerationWithPrefix() {
957
941
958
942
Router::reload ();
959
943
Router::connect ('/admin/:controller/:action/* ' , array ('prefix ' => 'admin ' ));
960
- Router::parse ('/ ' );
961
944
962
945
$ request = new Request ();
963
946
Router::setRequestInfo (
@@ -974,7 +957,6 @@ public function testUrlGenerationWithPrefix() {
974
957
975
958
Router::reload ();
976
959
Router::connect ('/admin/:controller/:action/* ' , array ('prefix ' => 'admin ' ));
977
- Router::parse ('/ ' );
978
960
979
961
$ request = new Request ();
980
962
Router::setRequestInfo (
@@ -992,7 +974,6 @@ public function testUrlGenerationWithPrefix() {
992
974
993
975
Router::reload ();
994
976
Router::connect ('/admin/posts/* ' , array ('controller ' => 'posts ' , 'action ' => 'index ' , 'prefix ' => 'admin ' ));
995
- Router::parse ('/ ' );
996
977
Router::setRequestInfo (
997
978
$ request ->addParams (array (
998
979
'plugin ' => null , 'controller ' => 'posts ' , 'action ' => 'index ' , 'prefix ' => 'admin ' ,
@@ -1015,7 +996,6 @@ public function testUrlGenerationWithPrefix() {
1015
996
public function testUrlGenerationWithExtensions () {
1016
997
Router::connect ('/:controller ' , array ('action ' => 'index ' ));
1017
998
Router::connect ('/:controller/:action ' );
1018
- Router::parse ('/ ' );
1019
999
1020
1000
$ result = Router::url (array (
1021
1001
'plugin ' => null ,
@@ -1459,7 +1439,6 @@ public function testRouteSymmetry() {
1459
1439
array ('controller ' => 'pages ' , 'action ' => 'view ' , 'extra ' => null ),
1460
1440
array ("extra " => '[a-z1-9_]* ' , "slug " => '[a-z1-9_]+ ' )
1461
1441
);
1462
- Router::parse ('/ ' );
1463
1442
1464
1443
$ result = Router::url (array (
1465
1444
'admin ' => null ,
@@ -1484,6 +1463,16 @@ public function testRouteSymmetry() {
1484
1463
$ this ->assertEquals ($ expected , $ result );
1485
1464
}
1486
1465
1466
+ /**
1467
+ * Test exceptions when parsing fails.
1468
+ *
1469
+ * @expectedException Cake\Routing\Error\MissingRouteException
1470
+ */
1471
+ public function testParseError () {
1472
+ Router::connect ('/ ' , ['controller ' => 'Pages ' , 'action ' => 'display ' , 'home ' ]);
1473
+ Router::parse ('/nope ' );
1474
+ }
1475
+
1487
1476
/**
1488
1477
* Test parse and reverse symmetry
1489
1478
*
@@ -1502,7 +1491,6 @@ public function testParseReverseSymmetry($url) {
1502
1491
*/
1503
1492
public function parseReverseSymmetryData () {
1504
1493
return array (
1505
- array ('/ ' ),
1506
1494
array ('/controller/action ' ),
1507
1495
array ('/controller/action/param ' ),
1508
1496
array ('/controller/action?param1=value1¶m2=value2 ' ),
@@ -1559,7 +1547,6 @@ public function testPrefixRoutingAndPlugins() {
1559
1547
'webroot ' => '/base/ ' ,
1560
1548
))
1561
1549
);
1562
- Router::parse ('/ ' );
1563
1550
1564
1551
$ result = Router::url (array (
1565
1552
'plugin ' => 'test_plugin ' ,
@@ -1738,8 +1725,6 @@ public function testUrlGenerationWithAutoPrefixes() {
1738
1725
Router::connect ('/admin/:controller/:action/* ' , array ('prefix ' => 'admin ' ));
1739
1726
Router::connect ('/:controller/:action/* ' );
1740
1727
1741
- Router::parse ('/ ' );
1742
-
1743
1728
$ request = new Request ();
1744
1729
Router::setRequestInfo (
1745
1730
$ request ->addParams (array (
@@ -1863,7 +1848,6 @@ public function testPrefixRoutePersistence() {
1863
1848
Router::reload ();
1864
1849
Router::connect ('/protected/:controller/:action ' , array ('prefix ' => 'protected ' ));
1865
1850
Router::connect ('/:controller/:action ' );
1866
- Router::parse ('/ ' );
1867
1851
1868
1852
$ request = new Request ();
1869
1853
Router::setRequestInfo (
@@ -2058,6 +2042,7 @@ public function testParsingWithTrailingPeriodAndParseExtensions() {
2058
2042
/**
2059
2043
* test that patterns work for :action
2060
2044
*
2045
+ * @expectedException Cake\Routing\Error\MissingRouteException
2061
2046
* @return void
2062
2047
*/
2063
2048
public function testParsingWithPatternOnAction () {
@@ -2076,8 +2061,7 @@ public function testParsingWithPatternOnAction() {
2076
2061
);
2077
2062
$ this ->assertEquals ($ expected , $ result );
2078
2063
2079
- $ result = Router::parse ('/blog/foobar ' );
2080
- $ this ->assertSame ([], $ result );
2064
+ Router::parse ('/blog/foobar ' );
2081
2065
}
2082
2066
2083
2067
/**
@@ -2086,7 +2070,7 @@ public function testParsingWithPatternOnAction() {
2086
2070
* @expectedException Cake\Routing\Error\MissingRouteException
2087
2071
* @return void
2088
2072
*/
2089
- public function testUrlPatterOnAction () {
2073
+ public function testUrlPatternOnAction () {
2090
2074
Router::connect (
2091
2075
'/blog/:action/* ' ,
2092
2076
array ('controller ' => 'blog_posts ' ),
@@ -2241,7 +2225,6 @@ public function testPassedArgsOrder() {
2241
2225
Router::connect ('/test-passed/* ' , array ('controller ' => 'pages ' , 'action ' => 'display ' , 'home ' ));
2242
2226
Router::connect ('/test2/* ' , array ('controller ' => 'pages ' , 'action ' => 'display ' , 2 ));
2243
2227
Router::connect ('/test/* ' , array ('controller ' => 'pages ' , 'action ' => 'display ' , 1 ));
2244
- Router::parse ('/ ' );
2245
2228
2246
2229
$ result = Router::url (array ('controller ' => 'pages ' , 'action ' => 'display ' , 1 , 'whatever ' ));
2247
2230
$ expected = '/test/whatever ' ;
@@ -2267,9 +2250,17 @@ public function testRegexRouteMatching() {
2267
2250
$ result = Router::parse ('/eng/test/test_action ' );
2268
2251
$ expected = array ('pass ' => [], 'locale ' => 'eng ' , 'controller ' => 'test ' , 'action ' => 'test_action ' , 'plugin ' => null );
2269
2252
$ this ->assertEquals ($ expected , $ result );
2253
+ }
2270
2254
2271
- $ result = Router::parse ('/badness/test/test_action ' );
2272
- $ this ->assertSame ([], $ result );
2255
+ /**
2256
+ * testRegexRouteMatching error
2257
+ *
2258
+ * @expectedException Cake\Routing\Error\MissingRouteException
2259
+ * @return void
2260
+ */
2261
+ public function testRegexRouteMatchingError () {
2262
+ Router::connect ('/:locale/:controller/:action/* ' , [], array ('locale ' => 'dan|eng ' ));
2263
+ Router::parse ('/badness/test/test_action ' );
2273
2264
}
2274
2265
2275
2266
/**
@@ -2304,18 +2295,6 @@ public function testRegexRouteMatchUrl() {
2304
2295
$ this ->assertEquals ($ expected , $ result );
2305
2296
}
2306
2297
2307
- /**
2308
- * test that connectDefaults() can disable default route connection
2309
- *
2310
- * @return void
2311
- */
2312
- public function testDefaultsMethod () {
2313
- Router::connect ('/test/* ' , array ('controller ' => 'pages ' , 'action ' => 'display ' , 2 ));
2314
- $ result = Router::parse ('/posts/edit/5 ' );
2315
- $ this ->assertFalse (isset ($ result ['controller ' ]));
2316
- $ this ->assertFalse (isset ($ result ['action ' ]));
2317
- }
2318
-
2319
2298
/**
2320
2299
* test that the required default routes are connected.
2321
2300
*
0 commit comments