mirror of
https://github.com/danog/endtoend-test-psl.git
synced 2024-12-11 16:49:40 +01:00
35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Psl\Tests\Html;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Psl\Html;
|
|
|
|
final class EncodeTest extends TestCase
|
|
{
|
|
/**
|
|
* @dataProvider provideData
|
|
*/
|
|
public function testEncode(string $expected, string $html, bool $double_encoding, ?string $encoding): void
|
|
{
|
|
static::assertSame($expected, Html\encode($html, $double_encoding, $encoding));
|
|
}
|
|
|
|
public function provideData(): iterable
|
|
{
|
|
yield ['hello', 'hello', true, 'UTF-8'];
|
|
yield ['héllo', 'héllo', true, 'UTF-8'];
|
|
yield ['<hello />', '<hello />', true, 'UTF-8'];
|
|
yield ['<p>Hello</p>', '<p>Hello</p>', true, 'UTF-8'];
|
|
yield ['<p>&lt; </p>', '<p>< </p>', true, 'UTF-8'];
|
|
|
|
yield ['hello', 'hello', false, 'UTF-8'];
|
|
yield ['héllo', 'héllo', false, 'UTF-8'];
|
|
yield ['<hello />', '<hello />', false, 'UTF-8'];
|
|
yield ['<p>Hello</p>', '<p>Hello</p>', false, 'UTF-8'];
|
|
yield ['<p>< </p>', '<p>< </p>', false, 'UTF-8'];
|
|
}
|
|
}
|