function BookMultilingualTest::assertToCEntryIsCorrectlyTranslated

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

Asserts one entry in the table of contents is correct.

@internal

Parameters

array $toc: The entire table of contents array.

string $langcode: The language code for the requested translation.

int $nid: The node ID.

string $indent: The indentation before the actual table of contents label.

1 call to BookMultilingualTest::assertToCEntryIsCorrectlyTranslated()
BookMultilingualTest::testMultilingualBookManager in core/modules/book/tests/src/Kernel/BookMultilingualTest.php
Tests various book manager methods return correct translations.

File

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

Class

BookMultilingualTest
Tests multilingual books.

Namespace

Drupal\Tests\book\Kernel

Code

protected function assertToCEntryIsCorrectlyTranslated(array $toc, string $langcode, int $nid, string $indent) : void {
    $node = Node::load($nid);
    $node_label = $node->getTranslation($langcode)
        ->label();
    $this->assertSame($indent . ' ' . $node_label, $toc[$nid]);
}

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