public function testSuccessfulLoadUserByUsername()
 {
     $ldap = $this->getMock('Symfony\\Component\\Ldap\\LdapClientInterface');
     $ldap->expects($this->once())->method('escape')->will($this->returnValue('foo'));
     $ldap->expects($this->once())->method('find')->will($this->returnValue(array(array('sAMAccountName' => 'foo', 'userpassword' => 'bar'), 'count' => 1)));
     $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com');
     $this->assertInstanceOf('Symfony\\Component\\Security\\Core\\User\\User', $provider->loadUserByUsername('foo'));
 }
Exemplo n.º 2
0
 public function testSuccessfulLoadUserByUsername()
 {
     $result = $this->getMock(CollectionInterface::class);
     $query = $this->getMock(QueryInterface::class);
     $query->expects($this->once())->method('execute')->will($this->returnValue($result));
     $ldap = $this->getMock(LdapInterface::class);
     $result->expects($this->once())->method('offsetGet')->with(0)->will($this->returnValue(new Entry('foo', array('sAMAccountName' => 'foo', 'userpassword' => 'bar'))));
     $result->expects($this->once())->method('count')->will($this->returnValue(1));
     $ldap->expects($this->once())->method('escape')->will($this->returnValue('foo'));
     $ldap->expects($this->once())->method('query')->will($this->returnValue($query));
     $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com');
     $this->assertInstanceOf('Symfony\\Component\\Security\\Core\\User\\User', $provider->loadUserByUsername('foo'));
 }