Add WooCommerceSettings endpoint

[MAILPOET-2278]
This commit is contained in:
Amine Ben hammou
2019-10-17 05:48:57 +01:00
committed by Jack Kitterhing
parent af902e93f4
commit 86cffacdbe
3 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,37 @@
<?php
namespace MailPoet\Test\API\JSON\v1;
use MailPoet\API\JSON\Response as APIResponse;
use MailPoet\API\JSON\v1\WoocommerceSettings;
use MailPoet\WP\Functions as WPFunctions;
class WoocommerceSettingsTest extends \MailPoetTest {
/** @var WoocommerceSettings */
private $endpoint;
/** @var WPFunctions */
private $wp;
function _before() {
$this->wp = new WPFunctions();
$this->endpoint = new WoocommerceSettings($this->wp);
}
function testItCanSetSettings() {
$this->wp->updateOption('woocommerce_email_base_color', '#ffffff');
$response = $this->endpoint->set([
'woocommerce_email_base_color' => '#aaaaaa',
]);
expect($response->status)->equals(APIResponse::STATUS_OK);
expect($this->wp->getOption('woocommerce_email_base_color'))->equals('#aaaaaa');
}
function testItDoesNotSetUnallowedSettings() {
$response = $this->endpoint->set([
'mailpoet_some_none_exting_option' => 'some value',
]);
expect($response->status)->equals(APIResponse::STATUS_OK);
expect($this->wp->getOption('mailpoet_some_none_exting_option', null))->equals(null);
}
}