12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- declare(strict_types=1);
- namespace PhpCsFixer\Tests\Fixer\Basic;
- use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
- final class EncodingFixerTest extends AbstractFixerTestCase
- {
-
- public function testFix(string $expected, ?string $input = null, ?\SplFileInfo $file = null): void
- {
- $this->doTest($expected, $input, $file);
- }
-
- public static function provideFixCases(): iterable
- {
- yield self::prepareTestCase('test-utf8.case1.php', 'test-utf8.case1-bom.php');
- yield self::prepareTestCase('test-utf8.case2.php', 'test-utf8.case2-bom.php');
- yield ['<?php '];
- }
-
- private static function prepareTestCase(string $expectedFilename, ?string $inputFilename = null): array
- {
- $expectedFile = new \SplFileInfo(__DIR__.'/../../Fixtures/FixerTest/encoding/'.$expectedFilename);
- $inputFile = null !== $inputFilename ? new \SplFileInfo(__DIR__.'/../../Fixtures/FixerTest/encoding/'.$inputFilename) : null;
- return [
- file_get_contents($expectedFile->getRealPath()),
- null !== $inputFile ? file_get_contents($inputFile->getRealPath()) : null,
- $inputFile ?? $expectedFile,
- ];
- }
- }
|