You are here

public function FileFieldPathsTransliterationCase::testTransliteration in File (Field) Paths 7

Test Transliteration cleanup in File (Field) Paths.

File

tests/transliteration.test, line 52
Transliteration module tests for the File (Field) Paths module.

Class

FileFieldPathsTransliterationCase
Class FileFieldPathsTransliterationCase

Code

public function testTransliteration() {
  $langcode = LANGUAGE_NONE;

  // Create a File field.
  $field_name = drupal_strtolower($this
    ->randomName());
  $instance_settings['filefield_paths']['file_path']['value'] = 'node/[node:title]';
  $instance_settings['filefield_paths']['file_path']['options']['transliterate'] = TRUE;
  $instance_settings['filefield_paths']['file_name']['value'] = '[node:title].[file:ffp-extension-original]';
  $instance_settings['filefield_paths']['file_name']['options']['transliterate'] = TRUE;
  $this
    ->createFileField($field_name, $this->content_type, array(), $instance_settings);

  // Create a node with a test file.
  $test_file = $this
    ->getTestFile('text');
  $edit['title'] = 'тест';
  $edit['files[' . $field_name . '_' . $langcode . '_0]'] = drupal_realpath($test_file->uri);
  $this
    ->drupalPost("node/add/{$this->content_type}", $edit, t('Save'));

  // Get created Node ID.
  $matches = array();
  preg_match('/node\\/([0-9]+)/', $this
    ->getUrl(), $matches);
  $nid = $matches[1];

  // Ensure that file path/name have been processed correctly by
  // Transliteration.
  $node = node_load($nid);
  $this
    ->assertEqual($node->{$field_name}[$langcode][0]['uri'], "public://node/test/test.txt", t('File path/name has been processed correctly by Transliteration'));
}