Esempio n. 1
0
 function test_should_rescue_app_exceptions_in_controller()
 {
     $controller = new RescueController();
     $controller->__construct($this->dispatcher);
     $this->dispatcher->setReturnValue('parse', array('foo', 'index'));
     $this->dispatcher->setReturnValue('load_controller', $controller);
     $exception = new Exception(__LINE__);
     $controller->throwOn('index_action', $exception);
     $controller->expectOnce('rescue', array($exception));
     $controller->setReturnValue('rescue', new Trails_Response());
     $this->dispatcher->dispatch('/foo/index');
 }
Esempio n. 2
0
 function test_should_instantiate_controller()
 {
     $controller = new RescueController();
     $controller->__construct($this->dispatcher);
     # Dispatching to FooController#index_action won't set a response thus
     # provoking an error. By calling #render_nothing before dispatching we can
     # preclude this.
     $controller->render_nothing();
     $this->dispatcher->expectOnce('load_controller', array('foo'));
     $this->dispatcher->setReturnValue('load_controller', $controller);
     $this->dispatcher->expectOnce('parse');
     $this->dispatcher->setReturnValue('parse', array('foo', ''));
     $result = $this->dispatcher->dispatch("/foo");
 }