function RouteCachingNonPathLanguageNegotiationTest::testAliases

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/FunctionalTests/Routing/RouteCachingNonPathLanguageNegotiationTest.php \Drupal\FunctionalTests\Routing\RouteCachingNonPathLanguageNegotiationTest::testAliases()
  2. 10 core/tests/Drupal/FunctionalTests/Routing/RouteCachingNonPathLanguageNegotiationTest.php \Drupal\FunctionalTests\Routing\RouteCachingNonPathLanguageNegotiationTest::testAliases()
  3. 11.x core/tests/Drupal/FunctionalTests/Routing/RouteCachingNonPathLanguageNegotiationTest.php \Drupal\FunctionalTests\Routing\RouteCachingNonPathLanguageNegotiationTest::testAliases()

Tests aliases when the negotiated language is not in the path.

File

core/tests/Drupal/FunctionalTests/Routing/RouteCachingNonPathLanguageNegotiationTest.php, line 82

Class

RouteCachingNonPathLanguageNegotiationTest
Tests the route cache when the language is not in the path.

Namespace

Drupal\FunctionalTests\Routing

Code

public function testAliases() {
    // Switch to French and try to access the now inaccessible block.
    $this->drupalGet('');
    // Create an alias for user/UID just for en, make sure that this is a 404
    // on the french page exist in english, no matter which language is
    // checked first. Create the alias after visiting frontpage to make sure
    // there is no existing cache entry for this that affects the tests.
    $this->createPathAlias('/user/' . $this->adminUser
        ->id(), '/user-page', 'en');
    $this->clickLink('French');
    $this->drupalGet('user-page');
    $this->assertSession()
        ->statusCodeEquals(404);
    // Switch to english, make sure it works now.
    $this->clickLink('English');
    $this->drupalGet('user-page');
    $this->assertSession()
        ->statusCodeEquals(200);
    // Clear cache and repeat the check, this time with english first.
    $this->resetAll();
    $this->drupalGet('user-page');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->clickLink('French');
    $this->drupalGet('user-page');
    $this->assertSession()
        ->statusCodeEquals(404);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.