Files
piratepoet/tests/unit/API/JSON/ErrorResponseTest.php
Amine Ben hammou 43df66d162 Add public keyword to methods
[MAILPOET-2413]
2019-12-26 18:09:45 +03:00

45 lines
1.0 KiB
PHP

<?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',
];
$error_response = new ErrorResponse($errors);
expect($error_response->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);
}
}