Move assorted tests from integration to unit [MAILPOET-2009]
This commit is contained in:
@ -3,8 +3,6 @@
|
||||
namespace MailPoet\API\JSON;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class ErrorResponse extends Response {
|
||||
public $errors;
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
namespace MailPoet\API\JSON;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
abstract class Response {
|
||||
const STATUS_OK = 200;
|
||||
const STATUS_BAD_REQUEST = 400;
|
||||
|
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
namespace MailPoet\Form\Block;
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
|
@ -4,8 +4,6 @@ namespace MailPoet\Newsletter\Editor;
|
||||
use MailPoet\WooCommerce\Helper as WooCommerceHelper;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class PostContentManager {
|
||||
const WP_POST_CLASS = 'mailpoet_wp_post';
|
||||
|
||||
|
@ -5,8 +5,6 @@ use MailPoet\WooCommerce\Helper as WooCommerceHelper;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
use MailPoet\Config\Env;
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class PostTransformer {
|
||||
|
||||
private $args;
|
||||
|
@ -5,8 +5,6 @@ use pQuery;
|
||||
use pQuery\DomNode;
|
||||
use MailPoet\Util\DOM as DOMUtil;
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class StructureTransformer {
|
||||
|
||||
function transform($content, $image_full_width) {
|
||||
|
@ -3,8 +3,6 @@ namespace MailPoet\Util;
|
||||
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class Security {
|
||||
const HASH_LENGTH = 12;
|
||||
|
||||
|
@ -2,10 +2,17 @@
|
||||
|
||||
namespace MailPoet\Test\API\JSON;
|
||||
|
||||
use Codeception\Stub;
|
||||
use MailPoet\API\JSON\ErrorResponse;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class ErrorResponseTest extends \MailPoetTest {
|
||||
class ErrorResponseTest extends \MailPoetUnitTest {
|
||||
function testItSanitizesSqlErrorsWhenReturningResponse() {
|
||||
WPFunctions::set(Stub::make(new WPFunctions, [
|
||||
'__' => function ($value) {
|
||||
return $value;
|
||||
}
|
||||
]));
|
||||
$errors = array(
|
||||
'valid error',
|
||||
'SQLSTATE[22001]: Some SQL error',
|
||||
@ -31,4 +38,8 @@ class ErrorResponseTest extends \MailPoetTest {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function _after() {
|
||||
WPFunctions::set(new WPFunctions);
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ namespace MailPoet\Test\Form\Block;
|
||||
|
||||
use MailPoet\Form\Block\Date;
|
||||
|
||||
class DateTest extends \MailPoetTest {
|
||||
class DateTest extends \MailPoetUnitTest {
|
||||
function testItCanConvertDateMonthYearFormatToDatetime() {
|
||||
$date = array(
|
||||
'MM/DD/YYYY' => '05/10/2016',
|
@ -3,7 +3,7 @@ namespace MailPoet\Test\Newsletter\Editor;
|
||||
|
||||
use MailPoet\Newsletter\Editor\StructureTransformer;
|
||||
|
||||
class StructureTransformerTest extends \MailPoetTest {
|
||||
class StructureTransformerTest extends \MailPoetUnitTest {
|
||||
|
||||
function _before() {
|
||||
parent::_before();
|
@ -1,9 +1,11 @@
|
||||
<?php
|
||||
namespace MailPoet\Test\Subscribers\ImportExport\Import;
|
||||
|
||||
use Codeception\Stub;
|
||||
use MailPoet\Subscribers\ImportExport\Import\MailChimp;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class MailChimpTest extends \MailPoetTest {
|
||||
class MailChimpTest extends \MailPoetUnitTest {
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->api_key = getenv('WP_TEST_IMPORT_MAILCHIMP_API');
|
||||
@ -11,6 +13,14 @@ class MailChimpTest extends \MailPoetTest {
|
||||
$this->lists = explode(",", getenv('WP_TEST_IMPORT_MAILCHIMP_LISTS'));
|
||||
}
|
||||
|
||||
function _before() {
|
||||
WPFunctions::set(Stub::make(new WPFunctions, [
|
||||
'__' => function ($value) {
|
||||
return $value;
|
||||
}
|
||||
]));
|
||||
}
|
||||
|
||||
function testItCanGetAPIKey() {
|
||||
$valid_api_key_format = '12345678901234567890123456789012-ab1';
|
||||
// key must consist of two parts separated by hyphen
|
||||
@ -108,4 +118,8 @@ class MailChimpTest extends \MailPoetTest {
|
||||
->contains('The information received from MailChimp is too large for processing');
|
||||
}
|
||||
}
|
||||
|
||||
function _after() {
|
||||
WPFunctions::set(new WPFunctions);
|
||||
}
|
||||
}
|
@ -3,15 +3,7 @@ namespace MailPoet\Test\Util;
|
||||
|
||||
use MailPoet\Util\Security;
|
||||
|
||||
class SecurityTest extends \MailPoetTest {
|
||||
|
||||
function testItCanGenerateWPNonce() {
|
||||
$wp_nonce = Security::generateToken();
|
||||
// expect length of nonce to be exactly 10
|
||||
expect(strlen($wp_nonce))->equals(10);
|
||||
// expect only alphanumerical characters
|
||||
expect(ctype_alnum($wp_nonce))->true();
|
||||
}
|
||||
class SecurityTest extends \MailPoetUnitTest {
|
||||
|
||||
function testItCanGenerateARandomString() {
|
||||
// it has a default length of 5
|
@ -5,7 +5,7 @@ use Codeception\Stub;
|
||||
use MailPoet\WP\DateTime as WPDateTime;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class DateTimeTest extends \MailPoetTest {
|
||||
class DateTimeTest extends \MailPoetUnitTest {
|
||||
|
||||
function testGetTimeFormat() {
|
||||
$date_time = new WPDateTime(Stub::make(new WPFunctions(), [
|
||||
@ -40,17 +40,29 @@ class DateTimeTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
function testGetCurrentDate() {
|
||||
$date_time = new WPDateTime();
|
||||
$date_time = new WPDateTime(Stub::make(new WPFunctions(), [
|
||||
'currentTime' => function($format) {
|
||||
return date($format);
|
||||
}
|
||||
]));
|
||||
expect($date_time->getCurrentDate("Y-m"))->equals(date("Y-m"));
|
||||
}
|
||||
|
||||
function testGetCurrentTime() {
|
||||
$date_time = new WPDateTime();
|
||||
$date_time = new WPDateTime(Stub::make(new WPFunctions(), [
|
||||
'currentTime' => function($format) {
|
||||
return date($format);
|
||||
}
|
||||
]));
|
||||
expect($date_time->getCurrentTime("i:s"))->regExp('/\d\d:\d\d/');
|
||||
}
|
||||
|
||||
function testFormatTime() {
|
||||
$date_time = new WPDateTime();
|
||||
$date_time = new WPDateTime(Stub::make(new WPFunctions(), [
|
||||
'getOption' => function($key) {
|
||||
return 'H:i';
|
||||
}
|
||||
]));
|
||||
$timestamp = 1234567;
|
||||
$format = "H:i:s";
|
||||
expect($date_time->formatTime($timestamp))->equals(date($date_time->getTimeFormat(), $timestamp));
|
||||
@ -58,7 +70,11 @@ class DateTimeTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
function testFormatDate() {
|
||||
$date_time = new WPDateTime();
|
||||
$date_time = new WPDateTime(Stub::make(new WPFunctions(), [
|
||||
'getOption' => function($key) {
|
||||
return 'm-d';
|
||||
}
|
||||
]));
|
||||
$timestamp = 1234567;
|
||||
$format = "Y-m-d";
|
||||
expect($date_time->formatDate($timestamp))->equals(date($date_time->getDateFormat(), $timestamp));
|
||||
@ -66,7 +82,11 @@ class DateTimeTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
function testTimeInterval() {
|
||||
$date_time = new WPDateTime();
|
||||
$date_time = new WPDateTime(Stub::make(new WPFunctions(), [
|
||||
'getOption' => function($key) {
|
||||
return 'H:i';
|
||||
}
|
||||
]));
|
||||
$one_hour_interval = array_keys($date_time->getTimeInterval(
|
||||
'00:00:00',
|
||||
'+1 hour',
|
@ -54,4 +54,7 @@ class PostsTest extends \MailPoetUnitTest {
|
||||
expect($result['arguments'][1])->equals(array_diff_key($args, array('taxonomy' => '')));
|
||||
}
|
||||
|
||||
function _after() {
|
||||
WPFunctions::set(new WPFunctions);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user