@@ -947,13 +947,29 @@ function testUrlParsing() {
947
947
$ result = Router::parse ('/posts/view/foo:bar/routing:fun/answer:42 ' );
948
948
$ expected = array ('pass ' => array (), 'named ' => array ('foo ' => 'bar ' , 'routing ' => 'fun ' , 'answer ' => '42 ' ), 'plugin ' => null , 'controller ' => 'posts ' , 'action ' => 'view ' );
949
949
$ this ->assertEqual ($ result , $ expected );
950
+ }
950
951
952
+ /**
953
+ * test that the persist key works.
954
+ *
955
+ * @return void
956
+ */
957
+ function testPersistentParameters () {
951
958
Router::reload ();
952
- Router::connect ('/:lang/:color/posts/view/* ' , array ('controller ' => 'posts ' , 'action ' => 'view ' ), array ('persist ' => array ('lang ' , 'color ' )));
953
- Router::connect ('/:lang/:color/posts/index ' , array ('controller ' => 'posts ' , 'action ' => 'index ' ), array ('persist ' => array ('lang ' )));
959
+ Router::connect (
960
+ '/:lang/:color/posts/view/* ' ,
961
+ array ('controller ' => 'posts ' , 'action ' => 'view ' ),
962
+ array ('persist ' => array ('lang ' , 'color ' )
963
+ ));
964
+ Router::connect (
965
+ '/:lang/:color/posts/index ' ,
966
+ array ('controller ' => 'posts ' , 'action ' => 'index ' ),
967
+ array ('persist ' => array ('lang ' )
968
+ ));
954
969
Router::connect ('/:lang/:color/posts/edit/* ' , array ('controller ' => 'posts ' , 'action ' => 'index ' ));
955
970
Router::connect ('/about ' , array ('controller ' => 'pages ' , 'action ' => 'view ' , 'about ' ));
956
971
Router::parse ('/en/red/posts/view/5 ' );
972
+
957
973
Router::setRequestInfo (array (
958
974
array ('controller ' => 'posts ' , 'action ' => 'view ' , 'lang ' => 'en ' , 'color ' => 'red ' , 'form ' => array (), 'url ' => array (), 'plugin ' => null ),
959
975
array ('base ' => '/ ' , 'here ' => '/en/red/posts/view/5 ' , 'webroot ' => '/ ' , 'passedArgs ' => array (), 'argSeparator ' => ': ' , 'namedArgs ' => array ())
@@ -966,6 +982,10 @@ function testUrlParsing() {
966
982
$ result = Router::url (array ('controller ' => 'posts ' , 'action ' => 'index ' , 'color ' => 'blue ' ));
967
983
$ this ->assertEqual ($ result , $ expected );
968
984
985
+ $ expected = '/posts/edit/6 ' ;
986
+ $ result = Router::url (array ('controller ' => 'posts ' , 'action ' => 'edit ' , 6 , 'color ' => null , 'lang ' => null ));
987
+ $ this ->assertEqual ($ result , $ expected );
988
+
969
989
$ expected = '/posts ' ;
970
990
$ result = Router::url (array ('controller ' => 'posts ' , 'action ' => 'index ' ));
971
991
$ this ->assertEqual ($ result , $ expected );
0 commit comments