1 file.test FileNameMungingTest::testMungeIgnoreWhitelisted()

White listed extensions are ignored by file_munge_filename().


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


Tests for file_munge_filename() and file_unmunge_filename().


function testMungeIgnoreWhitelisted() {
  // Declare our extension as whitelisted. 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 whitelisted.', 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 whitelisted extension is in uppercase.', array('%munged' => $munged_name, '%original' => $this->name)));