You are here

function FileNameMungingTest::testMungeIgnoreWhitelisted in Drupal 7

White listed extensions are ignored by file_munge_filename().

File

modules/simpletest/tests/file.test, line 2784
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 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,
  )));
}