Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
	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);
	}