File tree Expand file tree Collapse file tree 1 file changed +60
-3
lines changed
cake/tests/cases/libs/route Expand file tree Collapse file tree 1 file changed +60
-3
lines changed Original file line number Diff line number Diff line change @@ -490,16 +490,73 @@ function testPassedArgumentParsing() {
490
490
'named ' => array ()
491
491
);
492
492
$ this ->assertEquals ($ expected , $ result );
493
-
494
- $ result = $ route ->parse ('/posts/edit/a-string/page:1 ' );
493
+
494
+ $ result = $ route ->parse ('/posts/edit/a-string/page:1/sort:value ' );
495
495
$ expected = array (
496
496
'controller ' => 'posts ' ,
497
497
'action ' => 'edit ' ,
498
498
'pass ' => array ('a-string ' ),
499
499
'named ' => array (
500
- 'page ' => 1
500
+ 'page ' => 1 ,
501
+ 'sort ' => 'value '
501
502
)
502
503
);
503
504
$ this ->assertEquals ($ expected , $ result );
504
505
}
506
+
507
+ /**
508
+ * test that parsing array format named parameters works
509
+ *
510
+ * @return void
511
+ */
512
+ function testArrayNamedParameters () {
513
+ $ route = new CakeRoute ('/:controller/:action/* ' );
514
+ $ result = $ route ->parse ('/tests/action/var[]:val1/var[]:val2 ' );
515
+ $ expected = array (
516
+ 'controller ' => 'tests ' ,
517
+ 'action ' => 'action ' ,
518
+ 'named ' => array (
519
+ 'var ' => array (
520
+ 'val1 ' ,
521
+ 'val2 '
522
+ )
523
+ ),
524
+ 'pass ' => array (),
525
+ );
526
+ $ this ->assertEqual ($ result , $ expected );
527
+
528
+ $ result = $ route ->parse ('/tests/action/theanswer[is]:42/var[]:val2/var[]:val3 ' );
529
+ $ expected = array (
530
+ 'controller ' => 'tests ' ,
531
+ 'action ' => 'action ' ,
532
+ 'named ' => array (
533
+ 'theanswer ' => array (
534
+ 'is ' => 42
535
+ ),
536
+ 'var ' => array (
537
+ 'val2 ' ,
538
+ 'val3 '
539
+ )
540
+ ),
541
+ 'pass ' => array (),
542
+ );
543
+ $ this ->assertEqual ($ result , $ expected );
544
+
545
+ $ result = $ route ->parse ('/tests/action/theanswer[is][not]:42/theanswer[]:5/theanswer[is]:6 ' );
546
+ $ expected = array (
547
+ 'controller ' => 'tests ' ,
548
+ 'action ' => 'action ' ,
549
+ 'named ' => array (
550
+ 'theanswer ' => array (
551
+ 5 ,
552
+ 'is ' => array (
553
+ 6 ,
554
+ 'not ' => 42
555
+ )
556
+ ),
557
+ ),
558
+ 'pass ' => array (),
559
+ );
560
+ $ this ->assertEqual ($ result , $ expected );
561
+ }
505
562
}
You can’t perform that action at this time.
0 commit comments