mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Expanding test coverage.
This commit is contained in:
parent
060360c787
commit
59dac2255e
1 changed files with 38 additions and 4 deletions
|
@ -500,13 +500,13 @@ class AuthTest extends CakeTestCase {
|
|||
$this->getMock('BaseAuthorize', array('authorize'), array(), 'AuthMockTwoAuthorize', false);
|
||||
$this->getMock('BaseAuthorize', array('authorize'), array(), 'AuthMockThreeAuthorize', false);
|
||||
|
||||
$this->Controller->Auth->authorize = array(
|
||||
$this->Auth->authorize = array(
|
||||
'AuthMockOne',
|
||||
'AuthMockTwo',
|
||||
'AuthMockThree'
|
||||
);
|
||||
$mocks = $this->Controller->Auth->constructAuthorize();
|
||||
$request = $this->Controller->request;
|
||||
$mocks = $this->Auth->constructAuthorize();
|
||||
$request = $this->Auth->request;
|
||||
|
||||
$this->assertEquals(3, count($mocks));
|
||||
$mocks[0]->expects($this->once())
|
||||
|
@ -522,7 +522,29 @@ class AuthTest extends CakeTestCase {
|
|||
$mocks[2]->expects($this->never())
|
||||
->method('authorize');
|
||||
|
||||
$this->assertTrue($this->Controller->Auth->isAuthorized(array('User'), $request));
|
||||
$this->assertTrue($this->Auth->isAuthorized(array('User'), $request));
|
||||
}
|
||||
|
||||
/**
|
||||
* test that isAuthorized will use the session user if none is given.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testIsAuthorizedUsingUserInSession() {
|
||||
$this->getMock('BaseAuthorize', array('authorize'), array(), 'AuthMockFourAuthorize', false);
|
||||
$this->Auth->authorize = array('AuthMockFour');
|
||||
|
||||
$user = array('user' => 'mark');
|
||||
$this->Auth->Session->write('Auth.User', $user);
|
||||
$mocks = $this->Auth->constructAuthorize();
|
||||
$request = $this->Controller->request;
|
||||
|
||||
$mocks[0]->expects($this->once())
|
||||
->method('authorize')
|
||||
->with($user, $request)
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$this->assertTrue($this->Auth->isAuthorized(null, $request));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1120,4 +1142,16 @@ class AuthTest extends CakeTestCase {
|
|||
$this->assertEquals('/users/home', $result);
|
||||
$this->assertFalse($this->Auth->Session->check('Auth.redirect'));
|
||||
}
|
||||
|
||||
/**
|
||||
* test password hashing
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testPassword() {
|
||||
$result = $this->Auth->password('password');
|
||||
$expected = Security::hash('password', null, true);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue