mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-08-15 23:08:11 +02:00
MySQL gives useless error messages for invalid UTF8 characters and confuses users with an 'Invalid datetime format' message. Once storing imported data fails, the original data will now be scanned for invalid UTF-8 characters. If such are found, a dedicated exception with more details is thrown. Otherwise the original exception will be forwarded fixes #2143
46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\Icinga\Module\Director\IcingaConfig;
|
|
|
|
use Icinga\Module\Director\Data\RecursiveUtf8Validator;
|
|
use Icinga\Module\Director\Test\BaseTestCase;
|
|
|
|
class RecursiveUtf8ValidatorTest extends BaseTestCase
|
|
{
|
|
/**
|
|
* @expectedException \InvalidArgumentException
|
|
*/
|
|
public function testDetectInvalidUtf8Character()
|
|
{
|
|
RecursiveUtf8Validator::validateRows([
|
|
(object) [
|
|
'name' => 'test 1',
|
|
'value' => 'something',
|
|
],
|
|
(object) [
|
|
'name' => 'test 2',
|
|
'value' => "some\xa1\xa2thing",
|
|
],
|
|
]);
|
|
}
|
|
|
|
public function testAcceptValidUtf8Characters()
|
|
{
|
|
$this->assertTrue(RecursiveUtf8Validator::validateRows([
|
|
(object) [
|
|
'name' => 'test 1',
|
|
'value' => "Some 🍻",
|
|
],
|
|
(object) [
|
|
'name' => 'test 2',
|
|
'value' => [
|
|
(object) [
|
|
'its' => true,
|
|
['💩']
|
|
]
|
|
],
|
|
],
|
|
]));
|
|
}
|
|
}
|