Adds method to ping Bridge
This commit is contained in:
@ -26,6 +26,8 @@ class Bridge {
|
|||||||
const CHECK_ERROR_UNAVAILABLE = 503;
|
const CHECK_ERROR_UNAVAILABLE = 503;
|
||||||
const CHECK_ERROR_UNKNOWN = 'unknown';
|
const CHECK_ERROR_UNKNOWN = 'unknown';
|
||||||
|
|
||||||
|
const BRIDGE_URL = 'https://bridge.mailpoet.com';
|
||||||
|
|
||||||
public $api;
|
public $api;
|
||||||
|
|
||||||
static function isMPSendingServiceEnabled() {
|
static function isMPSendingServiceEnabled() {
|
||||||
@ -48,6 +50,15 @@ class Bridge {
|
|||||||
return !empty($key);
|
return !empty($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function pingBridge() {
|
||||||
|
$params = array(
|
||||||
|
'blocking' => true,
|
||||||
|
'timeout' => 10
|
||||||
|
);
|
||||||
|
$result = wp_remote_get(self::BRIDGE_URL, $params);
|
||||||
|
return wp_remote_retrieve_response_code($result) === 200;
|
||||||
|
}
|
||||||
|
|
||||||
function initApi($api_key) {
|
function initApi($api_key) {
|
||||||
if($this->api) {
|
if($this->api) {
|
||||||
$this->api->setKey($api_key);
|
$this->api->setKey($api_key);
|
||||||
|
@ -247,6 +247,11 @@ class BridgeTest extends \MailPoetTest {
|
|||||||
$bridge->onSettingsSave($settings);
|
$bridge->onSettingsSave($settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testItPingsBridge() {
|
||||||
|
if(getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') return;
|
||||||
|
expect(Bridge::pingBridge())->true();
|
||||||
|
}
|
||||||
|
|
||||||
private function setMailPoetSendingMethod() {
|
private function setMailPoetSendingMethod() {
|
||||||
Setting::setValue(
|
Setting::setValue(
|
||||||
Mailer::MAILER_CONFIG_SETTING_NAME,
|
Mailer::MAILER_CONFIG_SETTING_NAME,
|
||||||
|
Reference in New Issue
Block a user