You are here

protected function BookMultilingualTest::assertNodeLinkIsCorrectlyTranslated in Drupal 10

Same name and namespace in other branches
  1. 9 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.

File

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

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 = Link::fromTextAndUrl($title, $url)
    ->toString();
  $this
    ->assertStringContainsString("http://{$langcode}.book.test.domain/node/{$nid}", $rendered_link);
}