Skip to content
Snippets Groups Projects
Commit b0d1b255 authored by Arthur Schiwon's avatar Arthur Schiwon
Browse files

adjust Access test

parent 6d64d7ec
Branches
No related tags found
No related merge requests found
...@@ -30,30 +30,39 @@ class Test_Access extends \PHPUnit_Framework_TestCase { ...@@ -30,30 +30,39 @@ class Test_Access extends \PHPUnit_Framework_TestCase {
private function getConnecterAndLdapMock() { private function getConnecterAndLdapMock() {
static $conMethods; static $conMethods;
static $accMethods; static $accMethods;
static $umMethods;
if(is_null($conMethods) || is_null($accMethods)) { if(is_null($conMethods) || is_null($accMethods)) {
$conMethods = get_class_methods('\OCA\user_ldap\lib\Connection'); $conMethods = get_class_methods('\OCA\user_ldap\lib\Connection');
$accMethods = get_class_methods('\OCA\user_ldap\lib\Access'); $accMethods = get_class_methods('\OCA\user_ldap\lib\Access');
$umMethods = get_class_methods('\OCA\user_ldap\lib\user\Manager');
} }
$lw = $this->getMock('\OCA\user_ldap\lib\ILDAPWrapper'); $lw = $this->getMock('\OCA\user_ldap\lib\ILDAPWrapper');
$connector = $this->getMock('\OCA\user_ldap\lib\Connection', $connector = $this->getMock('\OCA\user_ldap\lib\Connection',
$conMethods, $conMethods,
array($lw, null, null)); array($lw, null, null));
$um = $this->getMock('\OCA\user_ldap\lib\user\Manager',
$umMethods, array(
$this->getMock('\OCP\IConfig'),
$this->getMock('\OCA\user_ldap\lib\FilesystemHelper'),
$this->getMock('\OCA\user_ldap\lib\LogWrapper'),
$this->getMock('\OCP\IAvatarManager'),
$this->getMock('\OCP\Image')));
return array($lw, $connector); return array($lw, $connector, $um);
} }
public function testEscapeFilterPartValidChars() { public function testEscapeFilterPartValidChars() {
list($lw, $con) = $this->getConnecterAndLdapMock(); list($lw, $con, $um) = $this->getConnecterAndLdapMock();
$access = new Access($con, $lw); $access = new Access($con, $lw, $um);
$input = 'okay'; $input = 'okay';
$this->assertTrue($input === $access->escapeFilterPart($input)); $this->assertTrue($input === $access->escapeFilterPart($input));
} }
public function testEscapeFilterPartEscapeWildcard() { public function testEscapeFilterPartEscapeWildcard() {
list($lw, $con) = $this->getConnecterAndLdapMock(); list($lw, $con, $um) = $this->getConnecterAndLdapMock();
$access = new Access($con, $lw); $access = new Access($con, $lw, $um);
$input = '*'; $input = '*';
$expected = '\\\\*'; $expected = '\\\\*';
...@@ -61,8 +70,8 @@ class Test_Access extends \PHPUnit_Framework_TestCase { ...@@ -61,8 +70,8 @@ class Test_Access extends \PHPUnit_Framework_TestCase {
} }
public function testEscapeFilterPartEscapeWildcard2() { public function testEscapeFilterPartEscapeWildcard2() {
list($lw, $con) = $this->getConnecterAndLdapMock(); list($lw, $con, $um) = $this->getConnecterAndLdapMock();
$access = new Access($con, $lw); $access = new Access($con, $lw, $um);
$input = 'foo*bar'; $input = 'foo*bar';
$expected = 'foo\\\\*bar'; $expected = 'foo\\\\*bar';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment