/** * Constructor. * * @param \Cake\Controller\Controller $Controller */ public function __construct(Controller $Controller = null) { if ($Controller) { $this->_Controller = $Controller; $this->_eventManager = $Controller->getEventManager(); } else { $this->_eventManager = new EventManager(); } }
/** * test that beforeRedirect callback returning false in controller * * @return void */ public function testRedirectBeforeRedirectListenerReturnFalse() { $Response = $this->getMock('Cake\\Network\\Response', array('stop', 'header')); $Controller = new Controller(null, $Response); $Controller->getEventManager()->attach(function ($event, $response, $url, $status) { return false; }, 'Controller.beforeRedirect'); $Controller->response->expects($this->never())->method('stop'); $Controller->response->expects($this->never())->method('header'); $Controller->response->expects($this->never())->method('statusCode'); $result = $Controller->redirect('http://cakephp.org'); $this->assertNull($result); }