You are here

public function PathRedirectImportLanguageTest::testReadRedirectLanguageFile in Path redirect import 7

Performs the basic tests

File

tests/path_redirect_import.test, line 128
File that holds functional tests for Path Redirect Import module

Class

PathRedirectImportLanguageTest

Code

public function testReadRedirectLanguageFile() {

  // Check the most basic redirection case.
  $result = path_redirect_import_read_file(drupal_get_path('module', 'path_redirect_import') . '/tests/language_test.csv');
  $this
    ->assertEqual(end($result['message']), t('@count row(s) imported.', array(
    '@count' => 3,
  )));
  $this
    ->drupalGet('admin/config/search/redirect/list');
  $this
    ->assertRaw('<td><a href="/test1">test1</a></td><td><a href="/node/1">node/1</a></td><td>302</td><td>Spanish</td>', t('First line imported'));
  $this
    ->assertRaw('<td><a href="/test2?drupal=god">test2?drupal=god</a></td><td><a href="http://drupal.org">http://drupal.org</a></td><td>301</td><td>All</td>', t('Second line imported'));
  $this
    ->assertRaw('<td><a href="/test3?redirect=true">test3?redirect=true</a></td><td><a href="/">&lt;front&gt;</a></td><td>304</td><td>English</td>', t('Third line imported'));

  // Check default values overriden and default status_code.
  path_redirect_import_read_file(drupal_get_path('module', 'path_redirect_import') . '/tests/language_test_redirect.csv', array(
    'override' => TRUE,
    'status_code' => 302,
  ));
  $this
    ->drupalGet('admin/config/search/redirect/list');
  $this
    ->assertRaw('<td><a href="/test1">test1</a></td><td><a href="/node/1">node/1</a></td><td>301</td><td>Spanish</td>', t('First line overrode'));
  $this
    ->assertRaw('<td><a href="/test2?drupal=god">test2?drupal=god</a></td><td><a href="http://drupal.org">http://drupal.org</a></td><td>302</td><td>All</td>', t('Second line overrode'));
  $this
    ->assertRaw('<td><a href="/test3?redirect=true">test3?redirect=true</a></td><td><a href="/">&lt;front&gt;</a></td><td>300</td><td>English</td>', t('Third line overrode'));

  // Check status code values validation.
  path_redirect_import_read_file(drupal_get_path('module', 'path_redirect_import') . '/tests/language_test_language.csv', array(
    'override' => TRUE,
    'status_code' => 301,
  ));
  $this
    ->drupalGet('admin/config/search/redirect/list');
  $this
    ->assertRaw('<td><a href="/test1">test1</a></td><td><a href="/node/1">node/1</a></td><td>301</td><td>Spanish</td>', t('First line does not change due to language does not match'));
  $this
    ->assertRaw('<td><a href="/test1">test1</a></td><td><a href="/node/1">node/1</a></td><td>301</td><td>English</td>', t('Second line shows new redirecion from file'));
  $this
    ->assertRaw('<td><a href="/test2?drupal=god">test2?drupal=god</a></td><td><a href="http://drupal.org">http://drupal.org</a></td><td>302</td><td>All</td>', t('Third line does not change due to language does not match'));
  $this
    ->assertRaw('<td><a href="/test2?drupal=god">test2?drupal=god</a></td><td><a href="http://drupal.org">http://drupal.org</a></td><td>301</td><td>English</td>', t('Fourth line shows new redirecion from file'));
  $this
    ->assertRaw('<td><a href="/test3?redirect=true">test3?redirect=true</a></td><td><a href="/">&lt;front&gt;</a></td><td>300</td><td>English</td>', t('Fifth line does not change because of language code is not available'));
}