You are here

public function NameMungingTest::testMungeUnsafe in Drupal 8

Same name and namespace in other branches
  1. 9 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 107

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);
}