public function testWarnAppendsStackTraceIfGivenAnError() { $message = 'an error occured'; $exception = new Exception('some error'); $this->logger->warn($message, $exception); $this->assertLogContainsStackTrace($exception); $this->assertLogContainsErrorMessage($exception, $message); }
/** * Check that threshold is upper then percentage of users that will be suspended * * @param int $nbr_users_to_suspend * @param int $nbr_all_users * * @return Boolean * */ public function checkThreshold($nbr_users_to_suspend, $nbr_all_users) { if ($nbr_users_to_suspend == 0 || $nbr_all_users == 0) { return true; } $percentage_users_to_suspend = $nbr_users_to_suspend / $nbr_all_users * 100; $threshold_users_suspension = $this->ldap->getLDAPParam('threshold_users_suspension'); $logger = new BackendLogger(); if ($percentage_users_to_suspend <= $threshold_users_suspension) { $logger->info("[LDAP] Percentage of suspended users is ( " . $percentage_users_to_suspend . "% ) and threshold is ( " . $threshold_users_suspension . "% )"); $logger->info("[LDAP] Number of suspended users is ( " . $nbr_users_to_suspend . " ) and number of active users is ( " . $nbr_all_users . " )"); return true; } else { $logger->warn("[LDAP] Users not suspended: the percentage of users to suspend is ( " . $percentage_users_to_suspend . "% ) higher then threshold ( " . $threshold_users_suspension . "% )"); $logger->warn("[LDAP] Number of users not suspended is ( " . $nbr_users_to_suspend . " ) and number of active users is ( " . $nbr_all_users . " )"); return false; } }