add one simple cache test
This commit is contained in:
parent
4e8c7570d4
commit
e16122f2a1
|
@ -59,10 +59,7 @@ class Test_Group_Ldap extends \PHPUnit_Framework_TestCase {
|
||||||
private function enableGroups($access) {
|
private function enableGroups($access) {
|
||||||
$access->connection->expects($this->any())
|
$access->connection->expects($this->any())
|
||||||
->method('__get')
|
->method('__get')
|
||||||
->will($this->returnCallback(function($name) {
|
->will($this->returnCallback(function() {
|
||||||
// if($name === 'ldapLoginFilter') {
|
|
||||||
// return '%uid';
|
|
||||||
// }
|
|
||||||
return 1;
|
return 1;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -269,4 +266,32 @@ class Test_Group_Ldap extends \PHPUnit_Framework_TestCase {
|
||||||
$this->assertSame(false, $gid);
|
$this->assertSame(false, $gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tests whether Group Backend behaves correctly when cache with uid and gid
|
||||||
|
* is hit
|
||||||
|
*/
|
||||||
|
public function testInGroupHitsUidGidCache() {
|
||||||
|
$access = $this->getAccessMock();
|
||||||
|
$this->enableGroups($access);
|
||||||
|
|
||||||
|
$uid = 'someUser';
|
||||||
|
$gid = 'someGroup';
|
||||||
|
$cacheKey = 'inGroup'.$uid.':'.$gid;
|
||||||
|
$access->connection->expects($this->once())
|
||||||
|
->method('isCached')
|
||||||
|
->with($cacheKey)
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$access->connection->expects($this->once())
|
||||||
|
->method('getFromCache')
|
||||||
|
->with($cacheKey)
|
||||||
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$access->expects($this->never())
|
||||||
|
->method('username2dn');
|
||||||
|
|
||||||
|
$groupBackend = new GroupLDAP($access);
|
||||||
|
$groupBackend->inGroup($uid, $gid);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue