also test whether hooks work
This commit is contained in:
parent
c46fada6b3
commit
bf1f5f2af3
1 changed files with 39 additions and 5 deletions
|
@ -168,7 +168,17 @@ class Session extends \PHPUnit_Framework_TestCase {
|
||||||
},
|
},
|
||||||
'foo'));
|
'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');
|
$backend = $this->getMock('OC_User_Dummy');
|
||||||
|
|
||||||
|
@ -177,6 +187,8 @@ class Session extends \PHPUnit_Framework_TestCase {
|
||||||
$user->expects($this->any())
|
$user->expects($this->any())
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('foo'));
|
->will($this->returnValue('foo'));
|
||||||
|
$user->expects($this->once())
|
||||||
|
->method('updateLastLoginTimestamp');
|
||||||
|
|
||||||
$manager->expects($this->once())
|
$manager->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -206,7 +218,17 @@ class Session extends \PHPUnit_Framework_TestCase {
|
||||||
$session->expects($this->never())
|
$session->expects($this->never())
|
||||||
->method('set');
|
->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');
|
$backend = $this->getMock('OC_User_Dummy');
|
||||||
|
|
||||||
|
@ -215,6 +237,8 @@ class Session extends \PHPUnit_Framework_TestCase {
|
||||||
$user->expects($this->any())
|
$user->expects($this->any())
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('foo'));
|
->will($this->returnValue('foo'));
|
||||||
|
$user->expects($this->never())
|
||||||
|
->method('updateLastLoginTimestamp');
|
||||||
|
|
||||||
$manager->expects($this->once())
|
$manager->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -238,7 +262,17 @@ class Session extends \PHPUnit_Framework_TestCase {
|
||||||
$session->expects($this->never())
|
$session->expects($this->never())
|
||||||
->method('set');
|
->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');
|
$backend = $this->getMock('OC_User_Dummy');
|
||||||
|
|
||||||
|
@ -246,6 +280,8 @@ class Session extends \PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
$user->expects($this->never())
|
$user->expects($this->never())
|
||||||
->method('getUID');
|
->method('getUID');
|
||||||
|
$user->expects($this->never())
|
||||||
|
->method('updateLastLoginTimestamp');
|
||||||
|
|
||||||
$manager->expects($this->once())
|
$manager->expects($this->once())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
@ -262,7 +298,5 @@ class Session extends \PHPUnit_Framework_TestCase {
|
||||||
\OC_Preferences::deleteKey('foo', 'login_token', $token);
|
\OC_Preferences::deleteKey('foo', 'login_token', $token);
|
||||||
|
|
||||||
$this->assertSame($granted, false);
|
$this->assertSame($granted, false);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue