mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Assert exception msg contains UTF-8
The different versions of PHP throw several various messages for UTF-8 sequences, so this just performs a basic regex check
This commit is contained in:
parent
a59a057133
commit
d94e05cf76
2 changed files with 2 additions and 6 deletions
|
@ -351,12 +351,8 @@ class JsonViewTest extends CakeTestCase {
|
|||
restore_error_handler();
|
||||
$this->fail('Failed asserting that exception of type "CakeException" is thrown.');
|
||||
} catch (CakeException $e) {
|
||||
$expected = array(
|
||||
'Failed to parse JSON',
|
||||
'Malformed UTF-8 characters, possibly incorrectly encoded'
|
||||
);
|
||||
$this->assertContains($e->getMessage(), $expected);
|
||||
restore_error_handler();
|
||||
$this->assertRegExp('/UTF-8/', $e->getMessage());
|
||||
return;
|
||||
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ class JsonView extends View {
|
|||
}
|
||||
|
||||
if (function_exists('json_last_error') && json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new CakeException(sprintf('JSON_ERROR: %s', json_last_error_msg()));
|
||||
throw new CakeException(json_last_error_msg());
|
||||
} elseif ($json === false) {
|
||||
throw new CakeException('Failed to parse JSON');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue