Exemple #1
0
 public function testUserExistsForNeverExisting()
 {
     $access = $this->getAccessMock();
     $backend = new UserLDAP($access, $this->getMock('\\OCP\\IConfig'));
     $this->prepareMockForUserExists($access);
     $access->expects($this->any())->method('readAttribute')->will($this->returnCallback(function ($dn) {
         if ($dn === 'dnOfRoland,dc=test') {
             return array();
         }
         return false;
     }));
     //test for never-existing user
     $result = $backend->userExists('mallory');
     $this->assertFalse($result);
 }
 public function testUserExists()
 {
     $access = $this->getAccessMock();
     $backend = new UserLDAP($access);
     $this->prepareMockForUserExists($access);
     $access->expects($this->any())->method('readAttribute')->will($this->returnCallback(function ($dn) {
         if ($dn === 'dnOfRoland') {
             return array();
         }
         return false;
     }));
     //test for existing user
     $result = $backend->userExists('gunslinger');
     $this->assertTrue($result);
     //test for deleted user
     $result = $backend->userExists('formerUser');
     $this->assertFalse($result);
     //test for never-existing user
     $result = $backend->userExists('mallory');
     $this->assertFalse($result);
 }