mtnorthrop , .
, testAction ('/action', array ('return' = > 'contents') null. :
:
CakePHP Unit Test
AppController:: beforeFilter(), , , :
// For Mock Objects and Debug >= 2 allow all (this is for PHPUnit Tests)
if(preg_match('/Mock_/',get_class($this)) && Configure::read('debug') >= 2){
$this->Auth->allow();
}
, : https://groups.google.com/forum/#!topic/cake-php/eWCO2bf5t98
Auth ControllerTestCase:
class MyControllerTest extends ControllerTestCase {
public function setUp() {
parent::setUp();
$this->controller = $this->generate('My',
array('components' => array(
'Auth' => array('isAuthorized')
))
);
$this->controller->Auth->expects($this->any())
->method('isAuthorized')
->will($this->returnValue(true));
}
}
( CakePhp 2.3.8)