Move plugin files to a subfolder
[MAILPOET-3988]
This commit is contained in:
45
mailpoet/tests/unit/API/JSON/ErrorResponseTest.php
Normal file
45
mailpoet/tests/unit/API/JSON/ErrorResponseTest.php
Normal 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 {
|
||||
public function testItSanitizesSqlErrorsWhenReturningResponse() {
|
||||
WPFunctions::set(Stub::make(new WPFunctions, [
|
||||
'__' => function ($value) {
|
||||
return $value;
|
||||
},
|
||||
]));
|
||||
$errors = [
|
||||
'valid error',
|
||||
'SQLSTATE[22001]: Some SQL error',
|
||||
'another valid error',
|
||||
];
|
||||
$errorResponse = new ErrorResponse($errors);
|
||||
expect($errorResponse->getData())->equals(
|
||||
[
|
||||
'errors' => [
|
||||
[
|
||||
'error' => 0,
|
||||
'message' => 'valid error',
|
||||
],
|
||||
[
|
||||
'error' => 1,
|
||||
'message' => 'An unknown error occurred.',
|
||||
],
|
||||
[
|
||||
'error' => 2,
|
||||
'message' => 'another valid error',
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function _after() {
|
||||
WPFunctions::set(new WPFunctions);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user