I write a test case for a controller but i need a user logged to do the test, i try something like:
public function testIndex()
{
// TEST USER NORMAL ----------------
$this->Auth->login(
array(
'user' => 'aaaaaaaaaa',
'client_id' => 12345678,
'_row_key' => serialize(UUID::import('0fbr75bgrjv7buyygu78h6gugbu35gbu9'))
)
);
$this->_testAction(
'/SermepaConfig/index',
array('return' => 'vars')
);
debug($this->vars);
$this->Auth->logout();
}
But $this->vars is empty:
########## DEBUG ##########
array(
'clients_list' => array(
(int) 0 => false
)
)
How can i test actions with several levels of access by user?
I can do something like assertEqual calling $this->MyController->function() but not run if the call to the action must be a post ajax data, like:
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
$this->_testAction(
'/SermepaConfig/get_filtered_list',
array(
'data' => array(
'SermepaConfig' => array(
'client_id' => 123456
)
),
'method' => 'post',
'return' => 'result'
)
);
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment