예제 #1
0
 public function testMethod_reset_resets_TargetRoute_too()
 {
     TargetRoute::setAction('testclass');
     $this->assertEqual('testclass', TargetRoute::getAction());
     $this->router->reset();
     // default module action is "list"
     // "list" was formerly "index" (Response Action for GET "/foos")
     $this->assertEqual('list', TargetRoute::getAction());
 }
예제 #2
0
 /**
  * @todo Implement testAddDynamicBreadcrumbs().
  */
 public function testAddDynamicBreadcrumbs()
 {
     /**
      * case A -  normal module - frontend access => module = news, action =  action_show
      *
      * expected path = Home >> News >> Show
      */
     // add Level 1 - Home
     $this->object->resetBreadcrumbs();
     $this->object->initialize();
     TargetRoute::reset();
     TargetRoute::setController('news');
     TargetRoute::setAction('action_show');
     // fetch with dynamical trail building
     $t_array = $this->object->getTrail(true);
     #var_dump($t_array);
     // Level 1 - expected Home
     $this->assertIdentical('Home', $t_array[0]['title']);
     $this->assertIdentical(WWW_ROOT, $t_array[0]['link']);
     // Level 2 - Modulename News
     $this->assertIdentical('News', $t_array[1]['title']);
     $this->assertIdentical(WWW_ROOT . 'index.php?mod=news', $t_array[1]['link']);
     // Level 3 - Action  Show
     $this->assertIdentical('Show', $t_array[2]['title']);
     $this->assertIdentical(WWW_ROOT . 'index.php?mod=news&action=show', $t_array[2]['link']);
     /**
      * case B -  normal module - backend access => module = news, sub = admin, action =  action_admin_show
      *
      * expected path = Controlcenter >> News Admin >> Show
      */
     // add Level 1 - Home
     $this->object->resetBreadcrumbs();
     $this->object->initialize('news', 'admin');
     TargetRoute::reset();
     TargetRoute::setController('news');
     TargetRoute::setSubController('admin');
     TargetRoute::setAction('action_show');
     // fetch with dynamical trail building
     $t_array = $this->object->getTrail(true);
     #var_dump($t_array);
     // Level 1 - expected
     $this->assertIdentical('Control Center', $t_array[0]['title']);
     $this->assertIdentical(WWW_ROOT . 'index.php?mod=controlcenter', $t_array[0]['link']);
     // Level 2 - Modulename News
     $this->assertIdentical('News Admin', $t_array[1]['title']);
     $this->assertIdentical(WWW_ROOT . 'index.php?mod=news&sub=admin', $t_array[1]['link']);
     // Level 3 - Action  Show
     $this->assertIdentical('Show', $t_array[2]['title']);
     $this->assertIdentical(WWW_ROOT . 'index.php?mod=news&sub=admin&action=show', $t_array[2]['link']);
     /**
      * case c -  Control Center => module = controlcenter, action = show
      *
      * expected path = Controlcenter
      */
     // add Level 1 - Home
     $this->object->resetBreadcrumbs();
     $this->object->initialize('controlcenter');
     TargetRoute::reset();
     TargetRoute::setController('news');
     TargetRoute::setSubController(null);
     TargetRoute::setAction('show');
     // fetch with dynamical trail building
     $t_array = $this->object->getTrail(true);
     #var_dump($t_array);
     // Level 1 - expected
     $this->assertIdentical('Control Center', $t_array[0]['title']);
     $this->assertIdentical(WWW_ROOT . 'index.php?mod=controlcenter', $t_array[0]['link']);
     // Level 2 - Modulename News
     $this->assertIdentical('News', $t_array[1]['title']);
     $this->assertIdentical(WWW_ROOT . 'index.php?mod=news', $t_array[1]['link']);
     // Level 3 - Action  Show
     $this->assertIdentical('Show', $t_array[2]['title']);
     $this->assertIdentical(WWW_ROOT . 'index.php?mod=news&action=show', $t_array[2]['link']);
 }
예제 #3
0
파일: Router.php 프로젝트: ksst/kf
 public static function dispatchTo404()
 {
     TargetRoute::setController('error');
     TargetRoute::setAction('routenotfound');
 }