I've stripped out the login for testing, so i'm getting this error with the
following:
public function login() {
$this->Session->setFlash('working');
}
app_controller.php
/**
* beforeFilter method
*
* @return void
*/
public function beforeFilter() {
//AuthComponent config
$this->Auth->loginAction = array('controller' => 'users', 'action'
=> 'login');
$this->Auth->authenticate = array('LDAP');
$this->Auth->autoRedirect = false;
$this->Auth->authorize = array('Actions' => array('actionPath' =>
'controllers/'), 'Controller');
}
/**
* isAuthorized method
*
* @param array $user
* @return void
*/
public function isAuthorized($user = null){
$controller = $this->request->params['controller'];
$action = $this->request->params['action'];
//Check the users permissions
$permissions = $this->Acl->check(array('model' => 'User', 'foreign_key'
=> $user['User']['id']), "controllers/{$controller}/{$action}");
//If user doesn't have permissions, redirect
if(!$permissions){
$this->Session->setFlash('You don\'t have permissions for this area',
'flashFailure');
$this->redirect(array('controller' => 'users', 'action' =>
'dashboard'));
}
}
On Monday, 16 April 2012 19:55:43 UTC+1, Rob wrote:
>
> Post the login method of your Users controller.
>
> On Saturday, April 14, 2012 6:37:30 AM UTC-4, rossjha wrote:
>>
>> Hi,
>>
>> I'm trying to create a user controller test case. I'm using Auth/ACL and
>> i'm having problems with mock objects. With the test below, i get the
>> following error:
>>
>> Expectation failed for method name is equal to <string:setFlash> when
>> invoked 1 time(s).
>> Method was expected to be called 1 times, actually called 0 times.
>>
>>
>> Any help would be appreciated.
>>
>> Ross
>>
>> public function setUp() {
>> parent::setUp();
>> $this->controller = $this->generate('Users', array(
>> 'components' => array(
>> 'Session',
>> 'Auth',
>> 'Acl'
>> )
>> )
>> );
>> }
>>
>> /**
>> * tearDown method
>> *
>> * @return void
>> */
>> public function tearDown() {
>> unset($this->controller);
>> parent::tearDown();
>> }
>> public function testSuccessfullLogin() {
>>
>> $this->controller->Session
>> ->expects($this->once())
>> ->method('setFlash')
>> ->with('working');
>>
>> $this->testAction('/login');
>> }
>>
>>
>>
On Monday, 16 April 2012 19:55:43 UTC+1, Rob wrote:
>
> Post the login method of your Users controller.
>
> On Saturday, April 14, 2012 6:37:30 AM UTC-4, rossjha wrote:
>>
>> Hi,
>>
>> I'm trying to create a user controller test case. I'm using Auth/ACL and
>> i'm having problems with mock objects. With the test below, i get the
>> following error:
>>
>> Expectation failed for method name is equal to <string:setFlash> when
>> invoked 1 time(s).
>> Method was expected to be called 1 times, actually called 0 times.
>>
>>
>> Any help would be appreciated.
>>
>> Ross
>>
>> public function setUp() {
>> parent::setUp();
>> $this->controller = $this->generate('Users', array(
>> 'components' => array(
>> 'Session',
>> 'Auth',
>> 'Acl'
>> )
>> )
>> );
>> }
>>
>> /**
>> * tearDown method
>> *
>> * @return void
>> */
>> public function tearDown() {
>> unset($this->controller);
>> parent::tearDown();
>> }
>> public function testSuccessfullLogin() {
>>
>> $this->controller->Session
>> ->expects($this->once())
>> ->method('setFlash')
>> ->with('working');
>>
>> $this->testAction('/login');
>> }
>>
>>
>>
--
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
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php