function FileEncodingConstraintValidatorTest::providerTestFileValidateEncodings

Data provider for ::testFileEncoding.

Return value

array[][] The test cases.

File

core/modules/file/tests/src/Kernel/Plugin/Validation/Constraint/FileEncodingConstraintValidatorTest.php, line 59

Class

FileEncodingConstraintValidatorTest
Tests the FileEncodingConstraintValidator.

Namespace

Drupal\Tests\file\Kernel\Plugin\Validation\Constraint

Code

public static function providerTestFileValidateEncodings() : array {
    $utf8_encoded_txt_file_properties = [
        'filename' => 'druplicon.txt',
        'uri' => 'public://druplicon.txt',
        'status' => 0,
        'encoding' => 'UTF-8',
    ];
    $windows1252_encoded_txt_file = [
        'filename' => 'druplicon-win.txt',
        'uri' => 'public://druplicon-win.txt',
        'status' => 1,
        'encoding' => 'windows-1252',
    ];
    return [
        'UTF-8 encoded file validated with "UTF-8" encoding' => [
            'file_properties' => $utf8_encoded_txt_file_properties,
            'encodings' => [
                'UTF-8',
            ],
            'expected_errors' => [],
        ],
        'Windows-1252 encoded file validated with "UTF-8" encoding' => [
            'file_properties' => $windows1252_encoded_txt_file,
            'encodings' => [
                'UTF-8',
            ],
            'expected_errors' => [
                'The file is encoded with ASCII. It must be encoded with UTF-8',
            ],
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.