function NodeTranslationUITest::testUrlPrefixOnLanguageNeutralContent

Same name in other branches
  1. 11.x core/modules/node/tests/src/Functional/NodeTranslationUITest.php \Drupal\Tests\node\Functional\NodeTranslationUITest::testUrlPrefixOnLanguageNeutralContent()

Test that when content is language neutral, it uses interface language.

When language neutral content is displayed on interface language, it should consider the interface language for creating the content link.

File

core/modules/node/tests/src/Functional/NodeTranslationUITest.php, line 602

Class

NodeTranslationUITest
Tests the Node Translation UI.

Namespace

Drupal\Tests\node\Functional

Code

public function testUrlPrefixOnLanguageNeutralContent() : void {
    $this->drupalLogin($this->administrator);
    $neutral_langcodes = [
        LanguageInterface::LANGCODE_NOT_SPECIFIED,
    ];
    foreach ($neutral_langcodes as $langcode) {
        $article = $this->drupalCreateNode([
            'type' => 'article',
            'langcode' => $langcode,
        ]);
        $this->drupalGet("{$this->langcodes[1]}/admin/content");
        $this->assertSession()
            ->linkByHrefExists("{$this->langcodes[1]}/node/{$article->id()}");
        $this->drupalGet("{$this->langcodes[2]}/admin/content");
        $this->assertSession()
            ->linkByHrefExists("{$this->langcodes[2]}/node/{$article->id()}");
    }
}

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