diff --git a/tests/unit/suites/libraries/cms/component/router/rules/JComponentRouterRulesMenuTest.php b/tests/unit/suites/libraries/cms/component/router/rules/JComponentRouterRulesMenuTest.php index 08e1a00720b51..38668ade6ae4c 100644 --- a/tests/unit/suites/libraries/cms/component/router/rules/JComponentRouterRulesMenuTest.php +++ b/tests/unit/suites/libraries/cms/component/router/rules/JComponentRouterRulesMenuTest.php @@ -97,7 +97,8 @@ public function testConstruct() 'featured' => '47', 'categories' => array(14 => '48'), 'category' => array (20 => '49')) - ), $this->object->get('lookup')); + ), $this->object->get('lookup') + ); } /** @@ -110,7 +111,7 @@ public function testConstruct() public function casesPreprocess() { $cases = array(); - + // Check direct link to a simple view $cases[] = array(array('option' => 'com_content', 'view' => 'featured'), array('option' => 'com_content', 'view' => 'featured', 'Itemid' => '47')); @@ -225,8 +226,9 @@ public function testBuildLookup() 'featured' => '47', 'categories' => array(14 => '48'), 'category' => array (20 => '49')) - ), $this->object->get('lookup')); - + ), $this->object->get('lookup') + ); + $this->object->runBuildLookUp('en-GB'); $this->assertEquals(array( '*' => array( @@ -237,6 +239,7 @@ public function testBuildLookup() 'featured' => '51', 'categories' => array(14 => '50'), 'category' => array (20 => '49')) - ), $this->object->get('lookup')); + ), $this->object->get('lookup') + ); } } diff --git a/tests/unit/suites/libraries/cms/component/router/rules/stubs/JComponentRouterRulesMenuInspector.php b/tests/unit/suites/libraries/cms/component/router/rules/stubs/JComponentRouterRulesMenuInspector.php index 2f8cd9741da4d..a0ff58aae9a11 100644 --- a/tests/unit/suites/libraries/cms/component/router/rules/stubs/JComponentRouterRulesMenuInspector.php +++ b/tests/unit/suites/libraries/cms/component/router/rules/stubs/JComponentRouterRulesMenuInspector.php @@ -18,7 +18,7 @@ class JComponentRouterRulesMenuInspector extends JComponentRouterRulesMenu { /** * Gets an attribute of the object - * + * * @param string $key Attributename to return * * @return mixed Attributes of the object @@ -32,7 +32,7 @@ public function get($key) /** * Sets an attribute of the object - * + * * @param string $key Attributename to return * @param mixed $value Value to be set * @@ -44,7 +44,7 @@ public function set($key, $value) { $this->$key = $value; } - + public function runBuildLookup($language = '*') { return $this->buildLookup($language); diff --git a/tests/unit/suites/libraries/cms/component/router/rules/stubs/JComponentRouterRulesNomenuInspector.php b/tests/unit/suites/libraries/cms/component/router/rules/stubs/JComponentRouterRulesNomenuInspector.php index 7fc2031750d69..3f861df9443c7 100644 --- a/tests/unit/suites/libraries/cms/component/router/rules/stubs/JComponentRouterRulesNomenuInspector.php +++ b/tests/unit/suites/libraries/cms/component/router/rules/stubs/JComponentRouterRulesNomenuInspector.php @@ -18,7 +18,7 @@ class JComponentRouterRulesNomenuInspector extends JComponentRouterRulesNomenu { /** * Gets an attribute of the object - * + * * @param string $key Attributename to return * * @return mixed Attributes of the object @@ -32,7 +32,7 @@ public function get($key) /** * Sets an attribute of the object - * + * * @param string $key Attributename to return * @param mixed $value Value to be set * diff --git a/tests/unit/suites/libraries/cms/component/router/rules/stubs/MockJComponentRouterRulesMenuMenuObject.php b/tests/unit/suites/libraries/cms/component/router/rules/stubs/MockJComponentRouterRulesMenuMenuObject.php index 8029fe417442e..fe77e2bc9f864 100644 --- a/tests/unit/suites/libraries/cms/component/router/rules/stubs/MockJComponentRouterRulesMenuMenuObject.php +++ b/tests/unit/suites/libraries/cms/component/router/rules/stubs/MockJComponentRouterRulesMenuMenuObject.php @@ -18,104 +18,104 @@ class MockJComponentRouterRulesMenuMenuObject { /** * Menuitems - * + * * @var array */ protected $items = array(); /** * Active menuitem - * + * * @var integer */ public $active = 49; /** * Constructor for this object - * + * * @since 3.4 */ public function __construct() { $this->items[47] = (object) array( - 'id' => '47', - 'menutype' => 'testmenu', - 'title' => 'Content Home', - 'alias' => 'content-home', - 'route' => 'content-home', - 'link' => 'index.php?option=com_content&view=featured', - 'type' => 'component', - 'level' => '1', - 'language' => '*', + 'id' => '47', + 'menutype' => 'testmenu', + 'title' => 'Content Home', + 'alias' => 'content-home', + 'route' => 'content-home', + 'link' => 'index.php?option=com_content&view=featured', + 'type' => 'component', + 'level' => '1', + 'language' => '*', 'component_id' => '22', 'component' => 'com_content', - 'parent_id' => '0', + 'parent_id' => '0', 'query' => array('option' => 'com_content', 'view' => 'featured')); $this->items[48] = (object) array( - 'id' => '48', - 'menutype' => 'testmenu', - 'title' => 'Categories View', - 'alias' => 'categories', - 'route' => 'content-home/categories', - 'link' => 'index.php?option=com_content&view=categories&id=14', - 'type' => 'component', - 'level' => '2', - 'language' => '*', - 'component_id' => '22', + 'id' => '48', + 'menutype' => 'testmenu', + 'title' => 'Categories View', + 'alias' => 'categories', + 'route' => 'content-home/categories', + 'link' => 'index.php?option=com_content&view=categories&id=14', + 'type' => 'component', + 'level' => '2', + 'language' => '*', + 'component_id' => '22', 'component' => 'com_content', - 'parent_id' => '47', + 'parent_id' => '47', 'query' => array('option' => 'com_content', 'view' => 'categories', 'id' => '14')); $this->items[49] = (object) array( - 'id' => '49', - 'menutype' => 'testmenu', - 'title' => 'Category View', - 'alias' => 'category-view', - 'route' => 'category-view', - 'link' => 'index.php?option=com_content&view=category&id=20', - 'type' => 'component', - 'level' => '1', - 'language' => '*', - 'component_id' => '22', + 'id' => '49', + 'menutype' => 'testmenu', + 'title' => 'Category View', + 'alias' => 'category-view', + 'route' => 'category-view', + 'link' => 'index.php?option=com_content&view=category&id=20', + 'type' => 'component', + 'level' => '1', + 'language' => '*', + 'component_id' => '22', 'component' => 'com_content', - 'parent_id' => '47', + 'parent_id' => '47', 'query' => array('option' => 'com_content', 'view' => 'category', 'id' => '20')); $this->items[50] = (object) array( - 'id' => '50', - 'menutype' => 'testmenu', - 'title' => 'Categories View', - 'alias' => 'categories', - 'route' => 'content-home/categories', - 'link' => 'index.php?option=com_content&view=categories&id=14', - 'type' => 'component', - 'level' => '2', - 'language' => 'en-GB', - 'component_id' => '22', + 'id' => '50', + 'menutype' => 'testmenu', + 'title' => 'Categories View', + 'alias' => 'categories', + 'route' => 'content-home/categories', + 'link' => 'index.php?option=com_content&view=categories&id=14', + 'type' => 'component', + 'level' => '2', + 'language' => 'en-GB', + 'component_id' => '22', 'component' => 'com_content', - 'parent_id' => '47', + 'parent_id' => '47', 'query' => array('option' => 'com_content', 'view' => 'categories', 'id' => '14')); - + $this->items[51] = (object) array( - 'id' => '51', - 'menutype' => 'testmenu', - 'title' => 'Content Home', - 'alias' => 'content-home', - 'route' => 'content-home', - 'link' => 'index.php?option=com_content&view=featured', - 'type' => 'component', - 'level' => '1', - 'language' => 'en-GB', - 'component_id' => '22', + 'id' => '51', + 'menutype' => 'testmenu', + 'title' => 'Content Home', + 'alias' => 'content-home', + 'route' => 'content-home', + 'link' => 'index.php?option=com_content&view=featured', + 'type' => 'component', + 'level' => '1', + 'language' => 'en-GB', + 'component_id' => '22', 'component' => 'com_content', - 'parent_id' => '0', + 'parent_id' => '0', 'query' => array('option' => 'com_content', 'view' => 'featured')); } /** * Gets the menu item set that fits the search array - * + * * @param array $attributes Search criteria * @param array $values Search criteria * @@ -164,7 +164,7 @@ public function getItems($attributes, $values) /** * Return the currently active menuitem - * + * * @return object Menuitem * @since 3.4 */ @@ -175,9 +175,9 @@ public function getActive() /** * Return the default menuitem for the language - * + * * @param string $language Language for the default - * + * * @return object Menuitem * @since 3.4 */ @@ -187,7 +187,7 @@ public function getDefault($language = '*') { return $this->items[47]; } - + if ($language == 'en-GB') { return $this->items[51]; diff --git a/tests/unit/suites/libraries/cms/component/router/stubs/JComponentRouterBaseInspector.php b/tests/unit/suites/libraries/cms/component/router/stubs/JComponentRouterBaseInspector.php index 3d5cdfdc05ed0..19a9302aa8e89 100644 --- a/tests/unit/suites/libraries/cms/component/router/stubs/JComponentRouterBaseInspector.php +++ b/tests/unit/suites/libraries/cms/component/router/stubs/JComponentRouterBaseInspector.php @@ -18,7 +18,7 @@ class JComponentRouterBaseInspector extends JComponentRouterBase { /** * Runs the protected createURI() method - * + * * @param array $url valid inputs to the createURI() method * * @return object JUri object from the given parameters @@ -29,13 +29,13 @@ public function get($key) { return $this->$key; } - + public function build(&$query) { } - + public function parse(&$segments) { - + } } diff --git a/tests/unit/suites/libraries/cms/component/router/stubs/JComponentRouterViewInspector.php b/tests/unit/suites/libraries/cms/component/router/stubs/JComponentRouterViewInspector.php index 6d6d47c1ad3a8..b53c76cb198b4 100644 --- a/tests/unit/suites/libraries/cms/component/router/stubs/JComponentRouterViewInspector.php +++ b/tests/unit/suites/libraries/cms/component/router/stubs/JComponentRouterViewInspector.php @@ -18,7 +18,7 @@ class JComponentRouterViewInspector extends JComponentRouterView { /** * Gets an attribute of the object - * + * * @param string $key Attributename to return * * @return mixed Attributes of the object @@ -32,7 +32,7 @@ public function get($key) /** * Sets an attribute of the object - * + * * @param string $key Attributename to return * @param mixed $value Value to be set * @@ -46,14 +46,14 @@ public function set($key, $value) } /** - * Get content items of the type category - * - * @param int $id ID of the category to load - * - * @return array Categories path identified by $id - * - * @since 3.4 - */ + * Get content items of the type category + * + * @param int $id ID of the category to load + * + * @return array Categories path identified by $id + * + * @since 3.4 + */ public function getCategorySegment($id, $query) { $category = JCategories::getInstance($this->getName())->get($id); @@ -67,28 +67,28 @@ public function getCategorySegment($id, $query) } /** - * Get content items of the type categories - * - * @param int $id ID of the category to load - * - * @return array Categories path identified by $id - * - * @since 3.4 - */ + * Get content items of the type categories + * + * @param int $id ID of the category to load + * + * @return array Categories path identified by $id + * + * @since 3.4 + */ public function getCategoriesSegment($id, $query) { return $this->getCategorySegment($id, $query); } /** - * Get content items of the type article - * - * @param int $id ID of the article to load - * - * @return array article identified by $id - * - * @since 3.4 - */ + * Get content items of the type article + * + * @param int $id ID of the article to load + * + * @return array article identified by $id + * + * @since 3.4 + */ public function getArticleSegment($id, $query) { return array((int) $id => $id); diff --git a/tests/unit/suites/libraries/cms/component/router/stubs/componentrouter.php b/tests/unit/suites/libraries/cms/component/router/stubs/componentrouter.php index bd400e20653a8..17c37b829620e 100644 --- a/tests/unit/suites/libraries/cms/component/router/stubs/componentrouter.php +++ b/tests/unit/suites/libraries/cms/component/router/stubs/componentrouter.php @@ -17,6 +17,7 @@ function ComtestBuildRoute(&$query) { $return = array(); + foreach ($query as $key => $var) { $return[] = $key . '-' . $var; @@ -35,6 +36,7 @@ function ComtestBuildRoute(&$query) function ComtestParseRoute(&$segments) { $return = array(); + foreach ($segments as $segment) { list($key, $var) = explode(':', $segment, 2); diff --git a/tests/unit/suites/libraries/cms/component/router/stubs/componentrouterrule.php b/tests/unit/suites/libraries/cms/component/router/stubs/componentrouterrule.php index 4a18e4c45612c..3698b175702c9 100644 --- a/tests/unit/suites/libraries/cms/component/router/stubs/componentrouterrule.php +++ b/tests/unit/suites/libraries/cms/component/router/stubs/componentrouterrule.php @@ -17,49 +17,49 @@ class TestComponentRouterRule implements JComponentRouterRulesInterface { /** - * Router this rule belongs to - * - * @var JComponentRouterView - * @since 3.4 - */ + * Router this rule belongs to + * + * @var JComponentRouterView + * @since 3.4 + */ protected $router; /** - * Class constructor. - * - * @param JComponentRouterView $router Router this rule belongs to - * - * @since 3.4 - */ + * Class constructor. + * + * @param JComponentRouterView $router Router this rule belongs to + * + * @since 3.4 + */ public function __construct(JComponentRouterView $router) { $this->router = $router; } /** - * Finds the right Itemid for this query - * - * @param array &$query The query array to process - * - * @return void - * - * @since 3.4 - */ + * Finds the right Itemid for this query + * + * @param array &$query The query array to process + * + * @return void + * + * @since 3.4 + */ public function preprocess(&$query) { $query['testrule'] = 'yes'; } /** - * Parse method - * - * @param array &$segments The URL segments to parse - * @param array &$vars The vars that result from the segments - * - * @return void - * - * @since 3.4 - */ + * Parse method + * + * @param array &$segments The URL segments to parse + * @param array &$vars The vars that result from the segments + * + * @return void + * + * @since 3.4 + */ public function parse(&$segments, &$vars) { array_pop($segments); @@ -67,15 +67,15 @@ public function parse(&$segments, &$vars) } /** - * Build method - * - * @param array &$query The vars that should be converted - * @param array &$segments The URL segments to create - * - * @return void - * - * @since 3.4 - */ + * Build method + * + * @param array &$query The vars that should be converted + * @param array &$segments The URL segments to create + * + * @return void + * + * @since 3.4 + */ public function build(&$query, &$segments) { array_pop($query); diff --git a/tests/unit/suites/libraries/cms/router/JRouterSiteTest.php b/tests/unit/suites/libraries/cms/router/JRouterSiteTest.php index 71d1fea5087a1..f94dd5434236c 100644 --- a/tests/unit/suites/libraries/cms/router/JRouterSiteTest.php +++ b/tests/unit/suites/libraries/cms/router/JRouterSiteTest.php @@ -896,6 +896,7 @@ public function testParseSefRoute($url, $mode, $appConfig, $expectedParseVars, $ ->will($this->returnValue(true)); unset($appConfig['languagefilter']); } + $app->expects($this->any()) ->method('get') ->will($this->returnValueMap($appConfig)); diff --git a/tests/unit/suites/libraries/cms/router/JRouterTest.php b/tests/unit/suites/libraries/cms/router/JRouterTest.php index 9ab1e875567bf..e8193703aedf9 100644 --- a/tests/unit/suites/libraries/cms/router/JRouterTest.php +++ b/tests/unit/suites/libraries/cms/router/JRouterTest.php @@ -132,7 +132,8 @@ public function testLegacyApplicationRouterIsStillLoaded() 'id' => 3, 'name' => 'tester', 'path' => __DIR__ . '/data' - )); + ) + ); $this->assertInstanceOf('JRouter', JRouter::getInstance('tester')); } @@ -216,10 +217,12 @@ public function testBuildGivesTheSameResultAsTheJuriConstructor($mode) { $uri = new JUri('index.php?var1=value1'); $object = new JRouter; + if (!empty($mode)) { $object->setMode($mode); } + $result = $this->object->build('index.php?var1=value1'); $this->assertEquals($uri, $result); } @@ -391,6 +394,7 @@ function (JRouter $router, JUri $uri) public function testParseRulesCanReplacePresetVariables($preset, $rules, $stage, $expected) { $this->object->setVars($preset, false); + foreach ($rules as $rule) { $this->object->attachParseRule($rule, $stage); @@ -454,6 +458,7 @@ function (JRouter $router, JUri $uri) public function testParseRulesCanAddVariables($preset, $rules, $stage, $expected) { $this->object->setVars($preset, false); + foreach ($rules as $rule) { $this->object->attachParseRule($rule, $stage); @@ -529,6 +534,7 @@ function (JRouter $router, JUri $uri) public function testFirstParseRuleTakesPrecedence($preset, $rules, $stage, $expected) { $this->object->setVars($preset, false); + foreach ($rules as $rule) { $this->object->attachParseRule($rule, $stage);