function FileSystemTest::testInvalidUTF8

Tests that invalid UTF-8 results in an exception.

@legacy-covers ::createFilename

File

core/tests/Drupal/Tests/Core/File/FileSystemTest.php, line 169

Class

FileSystemTest
Tests Drupal\Core\File\FileSystem.

Namespace

Drupal\Tests\Core\File

Code

public function testInvalidUTF8() : void {
  vfsStream::setup('dir');
  // cspell:disable-next-line
  $filename = "a\xffsdf\x80€" . '.txt';
  $this->expectException(FileException::class);
  $this->expectExceptionMessage("Invalid filename '{$filename}'");
  $this->fileSystem
    ->createFilename($filename, 'vfs://dir');
}

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