test hooks also on login

This commit is contained in:
Arthur Schiwon 2014-05-23 00:59:26 +02:00
parent bf1f5f2af3
commit 60274d1729
1 changed files with 39 additions and 3 deletions

View File

@ -67,7 +67,17 @@ class Session extends \PHPUnit_Framework_TestCase {
},
'foo'));
$manager = $this->getMock('\OC\User\Manager');
$managerMethods = get_class_methods('\OC\User\Manager');
//keep following methods intact in order to ensure hooks are
//working
$doNotMock = array('__construct', 'emit', 'listen');
foreach($doNotMock as $methodName) {
$i = array_search($methodName, $managerMethods, true);
if($i !== false) {
unset($managerMethods[$i]);
}
}
$manager = $this->getMock('\OC\User\Manager', $managerMethods, array());
$backend = $this->getMock('OC_User_Dummy');
@ -78,6 +88,8 @@ class Session extends \PHPUnit_Framework_TestCase {
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('foo'));
$user->expects($this->once())
->method('updateLastLoginTimestamp');
$manager->expects($this->once())
->method('checkPassword')
@ -94,7 +106,17 @@ class Session extends \PHPUnit_Framework_TestCase {
$session->expects($this->never())
->method('set');
$manager = $this->getMock('\OC\User\Manager');
$managerMethods = get_class_methods('\OC\User\Manager');
//keep following methods intact in order to ensure hooks are
//working
$doNotMock = array('__construct', 'emit', 'listen');
foreach($doNotMock as $methodName) {
$i = array_search($methodName, $managerMethods, true);
if($i !== false) {
unset($managerMethods[$i]);
}
}
$manager = $this->getMock('\OC\User\Manager', $managerMethods, array());
$backend = $this->getMock('OC_User_Dummy');
@ -102,6 +124,8 @@ class Session extends \PHPUnit_Framework_TestCase {
$user->expects($this->once())
->method('isEnabled')
->will($this->returnValue(false));
$user->expects($this->never())
->method('updateLastLoginTimestamp');
$manager->expects($this->once())
->method('checkPassword')
@ -117,13 +141,25 @@ class Session extends \PHPUnit_Framework_TestCase {
$session->expects($this->never())
->method('set');
$manager = $this->getMock('\OC\User\Manager');
$managerMethods = get_class_methods('\OC\User\Manager');
//keep following methods intact in order to ensure hooks are
//working
$doNotMock = array('__construct', 'emit', 'listen');
foreach($doNotMock as $methodName) {
$i = array_search($methodName, $managerMethods, true);
if($i !== false) {
unset($managerMethods[$i]);
}
}
$manager = $this->getMock('\OC\User\Manager', $managerMethods, array());
$backend = $this->getMock('OC_User_Dummy');
$user = $this->getMock('\OC\User\User', array(), array('foo', $backend));
$user->expects($this->never())
->method('isEnabled');
$user->expects($this->never())
->method('updateLastLoginTimestamp');
$manager->expects($this->once())
->method('checkPassword')