function NameMungingTest::testMunging

Create a file and munge/unmunge the name.

File

drupal/core/modules/system/lib/Drupal/system/Tests/File/NameMungingTest.php, line 31
Definition of Drupal\system\Tests\File\NameMungingTest.

Class

NameMungingTest
Tests for file_munge_filename() and file_unmunge_filename().

Namespace

Drupal\system\Tests\File

Code

function testMunging() {

  // Disable insecure uploads.
  variable_set('allow_insecure_uploads', 0);
  $munged_name = file_munge_filename($this->name, '', TRUE);
  $messages = drupal_get_messages();
  $this
    ->assertTrue(in_array(t('For security reasons, your upload has been renamed to %filename.', array(
    '%filename' => $munged_name,
  )), $messages['status']), 'Alert properly set when a file is renamed.');
  $this
    ->assertNotEqual($munged_name, $this->name, format_string('The new filename (%munged) has been modified from the original (%original)', array(
    '%munged' => $munged_name,
    '%original' => $this->name,
  )));
}