1 file.test FileNameMungingTest::testMungeIgnoreAllowed()

Allowed extensions are ignored by file_munge_filename().

File

core/modules/simpletest/tests/file.test, line 2726
This provides SimpleTests for the core file handling functionality. These include FileValidateTest and FileSaveTest.

Class

FileNameMungingTest
Tests for file_munge_filename() and file_unmunge_filename().

Code

function testMungeIgnoreAllowed() {
  // Declare our extension as allowed. The declared extensions should be case
  // insensitive so test using one with a different case.
  $munged_name = file_munge_filename($this->name_with_uc_ext, $this->bad_extension);
  $this->assertIdentical($munged_name, $this->name_with_uc_ext, format_string('The new filename (%munged) matches the original (%original) once the extension has been allowed.', array('%munged' => $munged_name, '%original' => $this->name_with_uc_ext)));
  // The allowed extensions should also be normalized.
  $munged_name = file_munge_filename($this->name, strtoupper($this->bad_extension));
  $this->assertIdentical($munged_name, $this->name, format_string('The new filename (%munged) matches the original (%original) also when the allowed extension is in uppercase.', array('%munged' => $munged_name, '%original' => $this->name)));
}