mirror of
https://github.com/danog/endtoend-test-psl.git
synced 2024-12-11 16:49:40 +01:00
30 lines
583 B
PHP
30 lines
583 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Psl\Tests\Str;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Psl\Str;
|
|
|
|
final class DetectEncodingTest extends TestCase
|
|
{
|
|
/**
|
|
* @dataProvider provideData
|
|
*/
|
|
public function testDetectEncoding(?string $expected, string $string): void
|
|
{
|
|
static::assertSame($expected, Str\detect_encoding($string));
|
|
}
|
|
|
|
public function provideData(): array
|
|
{
|
|
return [
|
|
['ASCII', 'hello'],
|
|
['UTF-8', 'سيف'],
|
|
['UTF-8', '🐘'],
|
|
[null, Str\Byte\chr(128)]
|
|
];
|
|
}
|
|
}
|