Пример #1
0
 /**
  * Search Component router constructor
  *
  * @param   JApplicationCms  $app   The application object
  * @param   JMenu            $menu  The menu object to work with
  */
 public function __construct($app = null, $menu = null)
 {
     $params = JComponentHelper::getParams('com_contact');
     $this->noIDs = (bool) $params->get('sef_ids');
     $categories = new JComponentRouterViewconfiguration('categories');
     $categories->setKey('id');
     $this->registerView($categories);
     $category = new JComponentRouterViewconfiguration('category');
     $category->setKey('id')->setParent($categories, 'catid')->setNestable();
     $this->registerView($category);
     $contact = new JComponentRouterViewconfiguration('contact');
     $contact->setKey('id')->setParent($category, 'catid');
     $this->registerView($contact);
     $this->registerView(new JComponentRouterViewconfiguration('featured'));
     parent::__construct($app, $menu);
     $this->attachRule(new JComponentRouterRulesMenu($this));
     $params = JComponentHelper::getParams('com_content');
     if ($params->get('sef_advanced', 0)) {
         $this->attachRule(new JComponentRouterRulesStandard($this));
         $this->attachRule(new JComponentRouterRulesNomenu($this));
     } else {
         JLoader::register('ContactRouterRulesLegacy', __DIR__ . '/helpers/legacyrouter.php');
         $this->attachRule(new ContactRouterRulesLegacy($this));
     }
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.5
  */
 protected function setUp()
 {
     parent::setUp();
     $app = $this->getMockCmsApp();
     JFactory::$application = $app;
     $router = new JComponentRouterViewInspector($app, $app->getMenu());
     $router->set('name', 'content');
     $categories = new JComponentRouterViewconfiguration('categories');
     $categories->setKey('id');
     $router->registerView($categories);
     $category = new JComponentRouterViewconfiguration('category');
     $category->setKey('id')->setParent($categories)->setNestable()->addLayout('blog');
     $router->registerView($category);
     $article = new JComponentRouterViewconfiguration('article');
     $article->setKey('id')->setParent($category, 'catid');
     $router->registerView($article);
     $archive = new JComponentRouterViewconfiguration('archive');
     $router->registerView($archive);
     $featured = new JComponentRouterViewconfiguration('featured');
     $router->registerView($featured);
     $form = new JComponentRouterViewconfiguration('form');
     $router->registerView($form);
     $router->menu = new MockJComponentRouterRulesMenuMenuObject();
     $this->object = new JComponentRouterRulesMenuInspector($router);
 }
 /**
  * As view testdata, use the view configuration of com_content
  *
  * @return array|JComponentRouterViewconfiguration
  */
 protected function getComContentViews()
 {
     $categories = new JComponentRouterViewconfiguration('categories');
     $category = new JComponentRouterViewconfiguration('category');
     $category->setKey('id')->setParent($categories)->setNestable()->addLayout('blog');
     $article = new JComponentRouterViewconfiguration('article');
     $article->setKey('id')->setParent($category, 'catid');
     $archive = new JComponentRouterViewconfiguration('archive');
     $featured = new JComponentRouterViewconfiguration('featured');
     $form = new JComponentRouterViewconfiguration('form');
     return array('categories' => $categories, 'category' => $category, 'article' => $article, 'archive' => $archive, 'featured' => $featured, 'form' => $form);
 }
 /**
  * Test JComponentRouterViewconfiguration::setViewKey
  *
  * @return  void
  *
  * @since   3.4
  * @covers  JComponentRouterViewconfiguration::setKey
  */
 public function testSetKey()
 {
     $this->assertFalse($this->object->key);
     $this->assertEquals($this->object, $this->object->setKey('id'));
     $this->assertEquals('id', $this->object->key);
 }