Move assorted tests from integration to unit [MAILPOET-2009]

This commit is contained in:
wxa
2019-04-25 11:11:41 +03:00
committed by M. Shull
parent 994fae79d2
commit 2fd244528d
14 changed files with 59 additions and 33 deletions

View File

@@ -0,0 +1,45 @@
<?php
namespace MailPoet\Test\API\JSON;
use Codeception\Stub;
use MailPoet\API\JSON\ErrorResponse;
use MailPoet\WP\Functions as WPFunctions;
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',
'another valid error'
);
$error_response = new ErrorResponse($errors);
expect($error_response->getData())->equals(
array(
'errors' => array(
array(
'error' => 0,
'message' => 'valid error'
),
array(
'error' => 1,
'message' => 'An unknown error occurred.'
),
array(
'error' => 2,
'message' => 'another valid error'
)
)
)
);
}
function _after() {
WPFunctions::set(new WPFunctions);
}
}