public function test_authenticate_AddsUsernameSuffix_IfOneIsConfigured()
 {
     $adminUserName = null;
     $userName = null;
     $filterUsed = null;
     $filterBind = null;
     $mockLdapClient = $this->makeMockLdapClient();
     $mockLdapClient->expects($this->any())->method('bind')->will($this->returnCallback(function ($bindResource) use(&$adminUserName, &$userName) {
         static $i = 0;
         if ($i == 0) {
             $adminUserName = $bindResource;
         } else {
             $userName = $bindResource;
         }
         ++$i;
         return true;
     }));
     $mockLdapClient->expects($this->any())->method('fetchAll')->will($this->returnCallback(function ($baseDn, $filter, $bind) use(&$filterUsed, &$filterBind) {
         $filterUsed = $filter;
         $filterBind = $bind;
         return array(array('uid' => LdapUsersTest::TEST_USER, 'dn' => 'thedn'));
     }));
     $this->ldapUsers->setLdapClientClass($mockLdapClient);
     $this->setSingleLdapServer();
     $this->ldapUsers->setAuthenticationUsernameSuffix('whoa');
     $this->ldapUsers->authenticate(self::TEST_USER, self::PASSWORD);
     $this->assertEquals(self::TEST_ADMIN_USER, $adminUserName);
     $this->assertEquals('thedn', $userName);
     $this->assertContains("uid=?", $filterUsed);
     $this->assertEquals(array(self::TEST_USER . 'whoa'), $filterBind);
 }
 protected function authenticateByLdap()
 {
     $this->checkLdapFunctionsAvailable();
     $ldapUser = $this->ldapUsers->authenticate($this->login, $this->password);
     if (!empty($ldapUser)) {
         $this->synchronizeLdapUser($ldapUser);
         return true;
     } else {
         return false;
     }
 }