You are here

public function RedirectUILanguageTest::testEditRedirectLanguage in Redirect 8

Test editing the redirect language.

File

tests/src/Functional/RedirectUILanguageTest.php, line 98

Class

RedirectUILanguageTest
UI tests for redirect module with language and content translation modules.

Namespace

Drupal\Tests\redirect\Functional

Code

public function testEditRedirectLanguage() {
  $this
    ->drupalLogin($this->adminUser);

  // Add a redirect for english.
  $this
    ->drupalPostForm('admin/config/search/redirect/add', [
    'redirect_source[0][path]' => 'langpath',
    'redirect_redirect[0][uri]' => '/user',
    'language[0][value]' => 'en',
  ], t('Save'));

  // Check redirect for english.
  $this
    ->assertRedirect('langpath', '/user', 301);

  // Check that redirect for Germany is not working.
  $this
    ->assertRedirect('de/langpath', NULL, 404);

  // Edit the redirect and change the language.
  $this
    ->drupalGet('admin/config/search/redirect');
  $this
    ->clickLink('Edit');
  $this
    ->drupalPostForm(NULL, [
    'language[0][value]' => 'de',
  ], t('Save'));

  // Check redirect for english is NOT working now.
  $this
    ->assertRedirect('langpath', NULL, 404);

  // Check that redirect for Germany is now working.
  $this
    ->assertRedirect('de/langpath', '/de/user', 301);
}