2020-09-27 17:17:52 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Psl\Tests\Str;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use Psl\Str;
|
|
|
|
|
2020-10-04 21:24:36 +02:00
|
|
|
final class DetectEncodingTest extends TestCase
|
2020-09-27 17:17:52 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @dataProvider provideData
|
|
|
|
*/
|
2020-10-04 21:24:36 +02:00
|
|
|
public function testDetectEncoding(?string $expected, string $string): void
|
2020-09-27 17:17:52 +02:00
|
|
|
{
|
2020-10-15 10:18:03 +02:00
|
|
|
static::assertSame($expected, Str\detect_encoding($string));
|
2020-09-27 17:17:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function provideData(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
['ASCII', 'hello'],
|
|
|
|
['UTF-8', 'سيف'],
|
|
|
|
['UTF-8', '🐘'],
|
|
|
|
[null, Str\Byte\chr(128)]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|