You are here

public function DisableLanguageRedirectTest::testRedirects in Disable language 8

Test redirects.

File

tests/src/Functional/DisableLanguageRedirectTest.php, line 66

Class

DisableLanguageRedirectTest
@coversDefaultClass \Drupal\disable_language\EventSubscriber\DisabledLanguagesEventSubscriber @group disable_language

Namespace

Drupal\Tests\disable_language\Functional

Code

public function testRedirects() {
  $allowed_user = $this
    ->createUser([
    'view disabled languages',
  ]);
  $this
    ->drupalLogin($allowed_user);
  $this
    ->drupalGet('fr/node/' . $this->node
    ->id());
  $this
    ->assertSession()
    ->addressEquals('fr/node/' . $this->node
    ->id());
  $this
    ->drupalLogout();
  $this
    ->drupalGet('fr/node/' . $this->node
    ->id());
  $this
    ->assertSession()
    ->addressEquals('nl');
  \Drupal::configFactory()
    ->getEditable('disable_language.settings')
    ->set('redirect_override_routes', [
    'entity.node.canonical',
  ])
    ->save();
  drupal_flush_all_caches();
  $this
    ->drupalGet('fr/node/' . $this->node
    ->id());
  $this
    ->assertSession()
    ->addressEquals('nl/node/' . $this->node
    ->id());
  \Drupal::configFactory()
    ->getEditable('disable_language.settings')
    ->set('redirect_override_routes', [
    '',
  ])
    ->set('exclude_request_path', [
    'pages' => '/node/*',
  ])
    ->save();
  drupal_flush_all_caches();
  $this
    ->drupalGet('fr/node/' . $this->node
    ->id());
  $this
    ->assertSession()
    ->addressEquals('fr/node/' . $this->node
    ->id());
}