Remove AspectMock from CronHelperTest [MAILPOET-2464]

This commit is contained in:
wxa
2019-10-29 13:02:52 +03:00
committed by Jack Kitterhing
parent 2ed473f3a0
commit 8f4321487b
2 changed files with 19 additions and 13 deletions

View File

@@ -94,13 +94,17 @@ class CronHelper {
return Security::generateRandomString();
}
static function pingDaemon() {
static function pingDaemon($wp = null) {
if (is_null($wp)) {
$wp = new WPFunctions();
}
$url = self::getCronUrl(
CronDaemonEndpoint::ACTION_PING_RESPONSE
CronDaemonEndpoint::ACTION_PING_RESPONSE,
false,
$wp
);
$result = self::queryCronUrl($url);
if (is_wp_error($result)) return $result->get_error_message();
$wp = new WPFunctions();
$response = $wp->wpRemoteRetrieveBody($result);
$response = substr(trim($response), -strlen(DaemonHttpRunner::PING_SUCCESS_RESPONSE)) === DaemonHttpRunner::PING_SUCCESS_RESPONSE ?
DaemonHttpRunner::PING_SUCCESS_RESPONSE :
@@ -112,7 +116,10 @@ class CronHelper {
return $response === DaemonHttpRunner::PING_SUCCESS_RESPONSE;
}
static function accessDaemon($token) {
static function accessDaemon($token, $wp = null) {
if (is_null($wp)) {
$wp = new WPFunctions();
}
$data = ['token' => $token];
$url = self::getCronUrl(
CronDaemonEndpoint::ACTION_RUN,
@@ -124,8 +131,7 @@ class CronHelper {
}
$daemon['run_accessed_at'] = time();
self::saveDaemon($daemon);
$result = self::queryCronUrl($url);
$wp = new WPFunctions();
$result = self::queryCronUrl($url, $wp);
return $wp->wpRemoteRetrieveBody($result);
}