From 4d25277499aa89f409c30a33dc14d4a159ead1b1 Mon Sep 17 00:00:00 2001 From: nickl- Date: Fri, 22 Jun 2012 10:03:38 +0200 Subject: [PATCH] Unit test for commit 3e8d536 --- tests/library/Respect/Rest/RouterTest.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/library/Respect/Rest/RouterTest.php b/tests/library/Respect/Rest/RouterTest.php index 6555b5f..17cbe3f 100644 --- a/tests/library/Respect/Rest/RouterTest.php +++ b/tests/library/Respect/Rest/RouterTest.php @@ -432,6 +432,22 @@ function test_single_last_param2() $r->dispatch('get', '/documents/foo/bar')->response(); $this->assertEquals(array(array('foo', 'bar')), $args); } + /** + * Unit test for Commit: 3e8d536 + * + * Catchall route called with / only would not get passed a parameter + * to the callback function. + */ + function test_catchall_on_root_call_should_get_callback_parameter() + { + $r = new Router(); + $args = array(); + $r->any('/**', function($documentsPath) use (&$args) { + $args = func_get_args(); + }); + $r->dispatch('get', '/')->response(); + $this->assertTrue(\is_array($args[0])); + } /** * @ticket 46 @@ -522,7 +538,7 @@ function test_optional_parameters_should_be_allowed_only_at_the_end_of_the_path( } function test_route_ordering_with_when() - { + { $when = false; $r = new Router(); @@ -555,7 +571,7 @@ function test_when_should_be_called_only_on_existent_methods() $router->isAutoDispatched = false; $r1 = $router->any('/meow/*', __NAMESPACE__.'\\RouteKnowsGet'); - $r1->accept(array('application/json' => 'json_encode')); // some routine inheriting from AbstractAccept + $r1->accept(array('application/json' => 'json_encode')); // some routine inheriting from AbstractAccept $router->any('/moo/*', __NAMESPACE__.'\\RouteKnowsNothing');