function EntityUrlLanguageTest::testEntityUrlLanguage

Same name in other branches
  1. 9 core/modules/language/tests/src/Kernel/EntityUrlLanguageTest.php \Drupal\Tests\language\Kernel\EntityUrlLanguageTest::testEntityUrlLanguage()
  2. 8.9.x core/modules/language/tests/src/Kernel/EntityUrlLanguageTest.php \Drupal\Tests\language\Kernel\EntityUrlLanguageTest::testEntityUrlLanguage()
  3. 10 core/modules/language/tests/src/Kernel/EntityUrlLanguageTest.php \Drupal\Tests\language\Kernel\EntityUrlLanguageTest::testEntityUrlLanguage()

Ensures that entity URLs in a language have the right language prefix.

1 call to EntityUrlLanguageTest::testEntityUrlLanguage()
EntityUrlLanguageTest::testEntityUrlLanguageWithLanguageContentEnabled in core/modules/language/tests/src/Kernel/EntityUrlLanguageTest.php
Ensures correct entity URLs with the method language-content-entity enabled.

File

core/modules/language/tests/src/Kernel/EntityUrlLanguageTest.php, line 62

Class

EntityUrlLanguageTest
Tests the language of entity URLs. @group language

Namespace

Drupal\Tests\language\Kernel

Code

public function testEntityUrlLanguage() : void {
    $this->assertStringContainsString('/en/entity_test/' . $this->entity
        ->id(), $this->entity
        ->toUrl()
        ->toString());
    $this->assertStringContainsString('/es/entity_test/' . $this->entity
        ->id(), $this->entity
        ->getTranslation('es')
        ->toUrl()
        ->toString());
    $this->assertStringContainsString('/fr/entity_test/' . $this->entity
        ->id(), $this->entity
        ->getTranslation('fr')
        ->toUrl()
        ->toString());
}

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