Files
piratepoet/tests/integration/API/JSON/v1/WoocommerceSettingsTest.php
Amine Ben hammou 86cffacdbe Add WooCommerceSettings endpoint
[MAILPOET-2278]
2019-10-18 09:41:34 +01:00

38 lines
1.1 KiB
PHP

<?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);
}
}