public function testGetDisplayName() { $access = $this->getAccessMock(); $this->prepareAccessForGetDisplayName($access); $backend = new UserLDAP($access); $this->prepareMockForUserExists($access); //with displayName $result = $backend->getDisplayName('gunslinger'); $this->assertEquals('Roland Deschain', $result); //empty displayname retrieved $result = $backend->getDisplayName('newyorker'); $this->assertEquals(null, $result); }
public function testCountUsersFailing() { $access = $this->getAccessMock(); $access->expects($this->once())->method('countUsers')->will($this->returnValue(false)); $backend = new UserLDAP($access, $this->getMock('\\OCP\\IConfig')); $result = $backend->countUsers(); $this->assertFalse($result); }
public function testCountUsersFailing() { $access = $this->getAccessMock(); $access->connection->expects($this->once()) ->method('__get') ->will($this->returnCallback(function($name) { if($name === 'ldapLoginFilter') { return 'invalidFilter'; } return null; })); $access->expects($this->once()) ->method('countUsers') ->will($this->returnCallback(function($filter, $a, $b, $c) { if($filter !== 'uid=*') { return false; } return 5; })); $backend = new UserLDAP($access); $result = $backend->countUsers(); $this->assertFalse($result); }