You are here

public function NameMungingTest::testMungeUnsafe in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/File/NameMungingTest.php \Drupal\KernelTests\Core\File\NameMungingTest::testMungeUnsafe()

Tests unsafe extensions are always munged by file_munge_filename().

File

core/tests/Drupal/KernelTests/Core/File/NameMungingTest.php, line 109

Class

NameMungingTest
Tests filename munging and unmunging.

Namespace

Drupal\KernelTests\Core\File

Code

public function testMungeUnsafe() {
  $prefix = $this
    ->randomMachineName();
  $name = "{$prefix}.php.txt";

  // Put the php extension in the allowed list, but since it is in the unsafe
  // extension list, it should still be munged.
  $munged_name = file_munge_filename($name, 'php txt');
  $this
    ->assertSame("{$prefix}.php_.txt", $munged_name);
}