/** * Tests the getPath() method * * @return void * * @since 3.4 * @covers JComponentRouterView::getPath */ public function testGetPath() { // This test requires an application registered to JFactory $this->saveFactoryState(); JFactory::$application = $this->object->app; $views = $this->getComContentViews(); $this->object->set('name', 'unittest'); foreach ($views as $view) { $this->object->registerView($view); } // No view, so we don't have a path to return. $query = array('task' => 'edit'); $this->assertEquals(array(), $this->object->getPath($query)); // View without any parents and children $query = array('view' => 'form'); $this->assertEquals(array('form' => true), $this->object->getPath($query)); // View without any parents, but with children $query = array('view' => 'categories'); $this->assertEquals(array('categories' => true), $this->object->getPath($query)); // View with parent and children $query = array('view' => 'category', 'id' => '9'); $this->assertEquals(array('category' => array('9:uncategorised'), 'categories' => true), $this->object->getPath($query)); //View with parent, no children $query = array('view' => 'article', 'id' => '42:question-for-everything', 'catid' => '9'); $this->assertEquals(array('article' => array('42:question-for-everything'), 'category' => array('9:uncategorised'), 'categories' => true), $this->object->getPath($query)); //View with parent, no children and nested view $query = array('view' => 'article', 'id' => '42:question-for-everything', 'catid' => '20'); $this->assertEquals(array('article' => array('42:question-for-everything'), 'category' => array('20:extensions', '19:joomla', '14:sample-data-articles'), 'categories' => true), $this->object->getPath($query)); $this->restoreFactoryState(); }
/** * Tests the getPath() method * * @return void * * @dataProvider casesGetPath * @since 3.5 * @covers JComponentRouterView::getPath */ public function testGetPath($input, $result) { // This test requires an application registered to JFactory $this->saveFactoryState(); JFactory::$application = $this->object->app; $views = $this->getComContentViews(); $this->object->set('name', 'unittest'); foreach ($views as $view) { $this->object->registerView($view); } $this->assertEquals($result, $this->object->getPath($input)); $this->restoreFactoryState(); }