
Untitled
By: a guest on
Jun 30th, 2012 | syntax:
None | size: 0.76 KB | hits: 11 | expires: Never
cakephp controller testing - how to test actions which require authorization?
function testAdminIndex() {
$result = $this->testAction('/admin/users/index');
debug($result);
}
function testAdminEdit() {
$this->Posts->Session->write('Auth.User', array(
'id' => 1,
'username' => 'markstory',
));
$this->Posts->data = array(
'Post' => array(
'id' => 2,
'title' => 'Best article Evar!',
'body' => 'some text',
),
'Tag' => array(
'Tag' => array(1,2,3),
)
);
$this->Posts->params = Router::parse('/admin/posts/edit/2');
$this->Posts->beforeFilter();
$this->Posts->Component->startup($this->Posts);
$this->Posts->admin_edit();
}