protected function BookMultilingualTest::assertNodeLinkIsCorrectlyTranslated in Drupal 9
Same name and namespace in other branches
- 10 core/modules/book/tests/src/Kernel/BookMultilingualTest.php \Drupal\Tests\book\Kernel\BookMultilingualTest::assertNodeLinkIsCorrectlyTranslated()
Asserts a node link is correctly translated.
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 309
Class
- BookMultilingualTest
- Tests multilingual books.
Namespace
Drupal\Tests\book\KernelCode
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);
}