Skip to content

Commit

Permalink
Adding a test for logging users in using request data.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Feb 4, 2011
1 parent 7ea9149 commit e34fdde
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions cake/tests/cases/libs/controller/components/auth.test.php
Expand Up @@ -18,6 +18,7 @@
*/
App::import('Core', 'Controller');
App::import('Component', array('Auth', 'Acl'));
App::import('Component', 'auth/form_authenticate');
App::import('Model', 'DbAcl');
App::import('Core', 'Xml');

Expand Down Expand Up @@ -1487,6 +1488,28 @@ function testMapActionsDelegation() {
$this->Controller->Auth->mapActions(array('create' => array('my_action')));
}

/**
* test logging in with a request.
*
* @return void
*/
function testLoginWithRequestData() {
$this->getMock('FormAuthenticate', array(), array(), 'RequestLoginMockAuthenticate', false);
$request = new CakeRequest('users/login', false);
$user = array('username' => 'mark', 'role' => 'admin');

$this->Controller->Auth->request = $request;
$this->Controller->Auth->authenticate = array('RequestLoginMock');
$mock = $this->Controller->Auth->loadAuthenticateObjects();
$mock[0]->expects($this->once())
->method('authenticate')
->with($request)
->will($this->returnValue($user));

$this->assertTrue($this->Controller->Auth->login());
$this->assertEquals($user['username'], $this->Controller->Auth->user('username'));
}

/**
* test login() with user data
*
Expand Down

0 comments on commit e34fdde

Please sign in to comment.