You are here

function NameMungingTest::testMunging in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/File/NameMungingTest.php \Drupal\system\Tests\File\NameMungingTest::testMunging()

Create a file and munge/unmunge the name.

File

core/modules/system/src/Tests/File/NameMungingTest.php, line 42
Contains \Drupal\system\Tests\File\NameMungingTest.

Class

NameMungingTest
Tests filename munging and unmunging.

Namespace

Drupal\system\Tests\File

Code

function testMunging() {

  // Disable insecure uploads.
  $this
    ->config('system.file')
    ->set('allow_insecure_uploads', 0)
    ->save();
  $munged_name = file_munge_filename($this->name, '', TRUE);
  $messages = drupal_get_messages();
  $this
    ->assertTrue(in_array(strtr('For security reasons, your upload has been renamed to <em class="placeholder">%filename</em>.', 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,
  )));
}