Uses CronHelper's method to return cron ping URL in beacon
This commit is contained in:
@ -1,10 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace MailPoet\Helpscout;
|
namespace MailPoet\Helpscout;
|
||||||
|
|
||||||
use MailPoet\Cron\CronHelper;
|
use MailPoet\Cron\CronHelper;
|
||||||
use MailPoet\Models\Subscriber;
|
|
||||||
use MailPoet\Models\Setting;
|
use MailPoet\Models\Setting;
|
||||||
|
use MailPoet\Models\Subscriber;
|
||||||
use MailPoet\Router\Endpoints\CronDaemon;
|
use MailPoet\Router\Endpoints\CronDaemon;
|
||||||
use MailPoet\Router\Router;
|
|
||||||
use MailPoet\Services\Bridge;
|
use MailPoet\Services\Bridge;
|
||||||
|
|
||||||
if(!defined('ABSPATH')) exit;
|
if(!defined('ABSPATH')) exit;
|
||||||
@ -16,11 +17,6 @@ class Beacon {
|
|||||||
$mta = Setting::getValue('mta');
|
$mta = Setting::getValue('mta');
|
||||||
$current_theme = wp_get_theme();
|
$current_theme = wp_get_theme();
|
||||||
$current_user = wp_get_current_user();
|
$current_user = wp_get_current_user();
|
||||||
$cron_ping_url = Router::buildRequest(
|
|
||||||
CronDaemon::ENDPOINT,
|
|
||||||
CronDaemon::ACTION_PING
|
|
||||||
);
|
|
||||||
$cron_ping_url = str_replace(home_url(), CronHelper::getSiteUrl(), $cron_ping_url);
|
|
||||||
$premium_key = Setting::getValue(Bridge::PREMIUM_KEY_SETTING_NAME) ?: Setting::getValue(Bridge::API_KEY_SETTING_NAME);
|
$premium_key = Setting::getValue(Bridge::PREMIUM_KEY_SETTING_NAME) ?: Setting::getValue(Bridge::API_KEY_SETTING_NAME);
|
||||||
return array(
|
return array(
|
||||||
'name' => $current_user->display_name,
|
'name' => $current_user->display_name,
|
||||||
@ -51,7 +47,9 @@ class Beacon {
|
|||||||
$mta['frequency']['interval']
|
$mta['frequency']['interval']
|
||||||
),
|
),
|
||||||
'Task Scheduler method' => Setting::getValue('cron_trigger.method'),
|
'Task Scheduler method' => Setting::getValue('cron_trigger.method'),
|
||||||
'Cron ping URL' => $cron_ping_url,
|
'Cron ping URL' => CronHelper::getCronUrl(
|
||||||
|
CronDaemon::ACTION_PING
|
||||||
|
),
|
||||||
'Default FROM address' => Setting::getValue('sender.address'),
|
'Default FROM address' => Setting::getValue('sender.address'),
|
||||||
'Default Reply-To address' => Setting::getValue('reply_to.address'),
|
'Default Reply-To address' => Setting::getValue('reply_to.address'),
|
||||||
'Bounce Email Address' => Setting::getValue('bounce.address'),
|
'Bounce Email Address' => Setting::getValue('bounce.address'),
|
||||||
|
@ -5,6 +5,7 @@ use MailPoet\Helpscout\Beacon;
|
|||||||
use MailPoet\Models\Setting;
|
use MailPoet\Models\Setting;
|
||||||
use MailPoet\Models\Subscriber;
|
use MailPoet\Models\Subscriber;
|
||||||
use MailPoet\Services\Bridge;
|
use MailPoet\Services\Bridge;
|
||||||
|
use MailPoet\WP\Hooks;
|
||||||
|
|
||||||
class BeaconTest extends \MailPoetTest {
|
class BeaconTest extends \MailPoetTest {
|
||||||
function _before() {
|
function _before() {
|
||||||
@ -122,8 +123,16 @@ class BeaconTest extends \MailPoetTest {
|
|||||||
expect($this->beacon_data['Server OS'])->equals(utf8_encode(php_uname()));
|
expect($this->beacon_data['Server OS'])->equals(utf8_encode(php_uname()));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testItReturnsCronPingResponse() {
|
function testItReturnsCronPingUrl() {
|
||||||
expect($this->beacon_data['Cron ping URL'])->contains('&action=ping');
|
expect($this->beacon_data['Cron ping URL'])->contains('&action=ping');
|
||||||
|
// cron ping URL should react to custom filters
|
||||||
|
$filter = function($url) {
|
||||||
|
return str_replace(home_url(), 'http://custom_url/', $url);
|
||||||
|
};
|
||||||
|
Hooks::addFilter('mailpoet_cron_request_url', $filter);
|
||||||
|
$beacon_data = Beacon::getData();
|
||||||
|
expect($beacon_data['Cron ping URL'])->regExp('!^http:\/\/custom_url\/!');
|
||||||
|
Hooks::removeFilter('mailpoet_cron_request_url', $filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testItReturnsPremiumVersion() {
|
function testItReturnsPremiumVersion() {
|
||||||
|
Reference in New Issue
Block a user