Exemplo n.º 1
0
 /**
  * @covers FR3D\LdapBundle\Ldap\LdapManager::findUserBy
  */
 public function testFindUserBy()
 {
     $username = '******';
     $user = new TestUser();
     $user->setUsername($username);
     $entries = array('count' => 1, array('dn' => 'ou=group, dc=host, dc=foo', 'uid' => array('count' => 1, 0 => $username)));
     $this->connection->expects($this->once())->method('search')->with($this->equalTo('ou=Groups,dc=example,dc=com'), $this->equalTo('(&(attr0=value0)(uid=test_username))'), $this->equalTo(array('uid')))->will($this->returnValue($entries));
     $criteria = array('uid' => 'test_username');
     $resultUser = $this->ldapManager->findUserBy($criteria);
     $this->assertEquals($user->getUsername(), $resultUser->getUsername());
 }
Exemplo n.º 2
0
 public function testNoViolationsOnUniqueUserProperty()
 {
     $this->ldapManagerMock->expects($this->once())->method('findUserByUsername')->will($this->returnValue(null))->with($this->equalTo($this->user->getUsername()));
     $this->validatorContext->expects($this->never())->method('addViolation');
     $this->validator->validate($this->user, $this->constraint);
 }
Exemplo n.º 3
0
 public function testTrueOnUniqueUserProperty()
 {
     $this->ldapManagerMock->expects($this->once())->method('findUserByUsername')->will($this->returnValue(null))->with($this->equalTo($this->user->getUsername()));
     $this->assertTrue($this->validator->isValid($this->user, $this->constraint));
 }