/** * @expectedException Exception * @expectedExceptionMessage dummy error */ public function test_getUser_ThrowsException_WhenLdapClientThrows() { $mockLdapClient = $this->makeMockLdapClient(); $this->makeMockLdapClientThrowOnBind($mockLdapClient); $this->ldapUsers->setLdapClientClass($mockLdapClient); $this->ldapUsers->getUser(self::TEST_USER); }
/** * Synchronizes a single user in LDAP. This method can be used by superusers to synchronize * a user before (s)he logs in. * * @param string $login The login of the user. * @throws Exception if the user cannot be found or a problem occurs during synchronization. */ public function synchronizeUser($login) { Piwik::checkUserHasSuperUserAccess(); $ldapUser = $this->ldapUsers->getUser($login); if (empty($ldapUser)) { throw new Exception(Piwik::translate('LoginLdap_UserNotFound', $login)); } $this->userSynchronizer->synchronizeLdapUser($login, $ldapUser); $this->userSynchronizer->synchronizePiwikAccessFromLdap($login, $ldapUser); }