/** * Tests the parse() method * * @return void * * @since 3.4 */ public function testParse() { // Check if a false view is properly rejected $segments = array('falseview'); $vars = array('option' => 'com_content'); $this->object->parse($segments, $vars); $this->assertEquals(array('falseview'), $segments); $this->assertEquals(array('option' => 'com_content'), $vars); // Check if a single view is properly parsed $segments = array('featured'); $vars = array('option' => 'com_content'); $this->object->parse($segments, $vars); $this->assertEquals(array(), $segments); $this->assertEquals(array('option' => 'com_content', 'view' => 'featured'), $vars); // Check if a view with ID is properly parsed $segments = array('category', '23-the-question'); $vars = array('option' => 'com_content'); $this->object->parse($segments, $vars); $this->assertEquals(array(), $segments); $this->assertEquals(array('option' => 'com_content', 'view' => 'category', 'id' => '23:the-question'), $vars); // Check if a view that normally has an ID but which is missing is properly parsed $segments = array('category'); $vars = array('option' => 'com_content'); $this->object->parse($segments, $vars); $this->assertEquals(array(), $segments); $this->assertEquals(array('option' => 'com_content', 'view' => 'category'), $vars); // Test if the rule is properly skipped when a menu item is set $router = $this->object->get('router'); $router->menu->expects($this->any())->method('getActive')->will($this->returnValue(new stdClass())); $segments = array('article', '42:the-answer'); $vars = array('option' => 'com_content'); $this->object->parse($segments, $vars); $this->assertEquals(array('article', '42:the-answer'), $segments); $this->assertEquals(array('option' => 'com_content'), $vars); }
/** * Tests the buildLookup() method * * @return void * * @since 3.5 */ public function testBuildLookup() { $this->assertEquals(array('*' => array('featured' => '47', 'categories' => array(14 => '48'), 'category' => array(20 => '49'))), $this->object->get('lookup')); $this->object->runBuildLookUp('en-GB'); $this->assertEquals(array('*' => array('featured' => '47', 'categories' => array(14 => '48'), 'category' => array(20 => '49')), 'en-GB' => array('featured' => '51', 'categories' => array(14 => '50'), 'category' => array(20 => '49'))), $this->object->get('lookup')); }