mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-29 16:06:17 +00:00
Adding a test for logging users in using request data.
This commit is contained in:
parent
7ea914938f
commit
e34fdde918
1 changed files with 23 additions and 0 deletions
|
@ -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');
|
||||
|
||||
|
@ -1487,6 +1488,28 @@ class AuthTest extends CakeTestCase {
|
|||
$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
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue