icingaweb2-module-director/test/php/library/Director/Data/RecursiveUtf8ValidatorTest.php

48 lines
1.2 KiB
PHP
Raw Permalink Normal View History

<?php
// SPDX-FileCopyrightText: 2020 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-3.0-or-later
namespace Tests\Icinga\Module\Director\IcingaConfig;
use Icinga\Module\Director\Data\RecursiveUtf8Validator;
use Icinga\Module\Director\Test\BaseTestCase;
class RecursiveUtf8ValidatorTest extends BaseTestCase
{
public function testDetectInvalidUtf8Character()
{
$this->expectException(\InvalidArgumentException::class);
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,
['💩']
]
],
],
]));
}
}