function BookMultilingualTest::assertNodeLinkIsCorrectlyTranslated

Same name in other branches
  1. 9 core/modules/book/tests/src/Kernel/BookMultilingualTest.php \Drupal\Tests\book\Kernel\BookMultilingualTest::assertNodeLinkIsCorrectlyTranslated()
  2. 10 core/modules/book/tests/src/Kernel/BookMultilingualTest.php \Drupal\Tests\book\Kernel\BookMultilingualTest::assertNodeLinkIsCorrectlyTranslated()

Asserts a node link is correctly translated.

@internal

Parameters

int $nid: The node id.

string $title: The expected title.

\Drupal\Core\Url $url: The URL being tested.

string $langcode: The language code.

2 calls to BookMultilingualTest::assertNodeLinkIsCorrectlyTranslated()
BookMultilingualTest::assertBookItemIsCorrectlyTranslated in core/modules/book/tests/src/Kernel/BookMultilingualTest.php
Asserts a book item is correctly translated.
BookMultilingualTest::testMultilingualBookBreadcrumbBuilder in core/modules/book/tests/src/Kernel/BookMultilingualTest.php
Tests various book breadcrumb builder methods return correct translations.

File

core/modules/book/tests/src/Kernel/BookMultilingualTest.php, line 316

Class

BookMultilingualTest
Tests multilingual books.

Namespace

Drupal\Tests\book\Kernel

Code

protected function assertNodeLinkIsCorrectlyTranslated(int $nid, string $title, Url $url, string $langcode) : void {
    $node = Node::load($nid);
    $this->assertSame($node->getTranslation($langcode)
        ->label(), $title);
    $rendered_link = (string) Link::fromTextAndUrl($title, $url)->toString();
    $this->assertStringContainsString("http://{$langcode}.book.test.domain/node/{$nid}", $rendered_link);
}

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