From fa2ccb51c95264ce21eb204f5ce2d294985d83da Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 16 Oct 2017 23:46:17 -0400 Subject: [PATCH] Uses CronHelper's method to return cron ping URL in beacon --- lib/Helpscout/Beacon.php | 14 ++++++-------- tests/unit/Helpscout/BeaconTest.php | 11 ++++++++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/Helpscout/Beacon.php b/lib/Helpscout/Beacon.php index acb2c66f20..cc24712190 100644 --- a/lib/Helpscout/Beacon.php +++ b/lib/Helpscout/Beacon.php @@ -1,10 +1,11 @@ $current_user->display_name, @@ -51,7 +47,9 @@ class Beacon { $mta['frequency']['interval'] ), '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 Reply-To address' => Setting::getValue('reply_to.address'), 'Bounce Email Address' => Setting::getValue('bounce.address'), diff --git a/tests/unit/Helpscout/BeaconTest.php b/tests/unit/Helpscout/BeaconTest.php index 651578ffec..1903f81b9b 100644 --- a/tests/unit/Helpscout/BeaconTest.php +++ b/tests/unit/Helpscout/BeaconTest.php @@ -5,6 +5,7 @@ use MailPoet\Helpscout\Beacon; use MailPoet\Models\Setting; use MailPoet\Models\Subscriber; use MailPoet\Services\Bridge; +use MailPoet\WP\Hooks; class BeaconTest extends \MailPoetTest { function _before() { @@ -122,8 +123,16 @@ class BeaconTest extends \MailPoetTest { 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'); + // 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() {