From 888e7c25e3733b462c8b7b45773ebacc0acd9b80 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Thu, 9 Jan 2014 12:30:42 -0500 Subject: [PATCH] Added param default; removed unreachable code; expanded tests. --- module/VuFind/src/VuFind/Record/Router.php | 5 +-- .../src/VuFindTest/Record/RouterTest.php | 31 ++++++++++++++++++- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/module/VuFind/src/VuFind/Record/Router.php b/module/VuFind/src/VuFind/Record/Router.php index 4874c105b0a..1bab2da1f53 100644 --- a/module/VuFind/src/VuFind/Record/Router.php +++ b/module/VuFind/src/VuFind/Record/Router.php @@ -125,7 +125,7 @@ class Router * * @return array */ - public function getRouteDetails($driver, $routeSuffix, + public function getRouteDetails($driver, $routeSuffix = '', $extraParams = array() ) { // Extract source and ID from driver or string: @@ -146,9 +146,6 @@ class Router // Build URL parameters: $params = $extraParams; $params['id'] = $id; - if (!empty($action)) { - $params['action'] = $action; - } // Determine route based on naming convention (default VuFind route is // the exception to the rule): diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Record/RouterTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Record/RouterTest.php index b479f3453b3..066c6f2c8e4 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Record/RouterTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Record/RouterTest.php @@ -56,7 +56,36 @@ class RouterTest extends TestCase $router = $this->getRouter($driver); $this->assertEquals( array('params' => array('id' => 'test'), 'route' => 'record'), - $router->getRouteDetails($driver, '') + $router->getRouteDetails($driver) + ); + } + + /** + * Test routing with driver object. + * + * @return void + */ + public function testRoutingWithString() + { + $router = $this->getRouter(); + $this->assertEquals( + array('params' => array('id' => 'test'), 'route' => 'summonrecord'), + $router->getRouteDetails('Summon|test') + ); + } + + /** + * Test action routing with driver object. + * + * @return void + */ + public function testActionRoutingWithDriver() + { + $driver = $this->getDriver(); + $router = $this->getRouter($driver); + $this->assertEquals( + array('params' => array('id' => 'test'), 'route' => 'record-sms'), + $router->getActionRouteDetails($driver, 'SMS') ); } -- GitLab