assertBookItemIsCorrectlyTranslated example


  public function testMultilingualBookManager(string $langcode) {
    $this->setCurrentLanguage($langcode);
    /** @var \Drupal\book\BookManagerInterface $bm */
    $bm = $this->container->get('book.manager');
    $books = $bm->getAllBooks();
    $this->assertNotEmpty($books);
    foreach ($books as $book) {
      $bid = $book['bid'];
      $build = $bm->bookTreeOutput($bm->bookTreeAllData($bid));
      $items = $build['#items'];
      $this->assertBookItemIsCorrectlyTranslated($items[$bid]$langcode);
      $this->assertBookItemIsCorrectlyTranslated($items[$bid]['below'][$bid + 1]$langcode);
      $this->assertBookItemIsCorrectlyTranslated($items[$bid]['below'][$bid + 1]['below'][$bid + 3]$langcode);
      $this->assertBookItemIsCorrectlyTranslated($items[$bid]['below'][$bid + 1]['below'][$bid + 4]$langcode);
      $this->assertBookItemIsCorrectlyTranslated($items[$bid]['below'][$bid + 2]$langcode);
      $this->assertBookItemIsCorrectlyTranslated($items[$bid]['below'][$bid + 2]['below'][$bid + 5]$langcode);
      $this->assertBookItemIsCorrectlyTranslated($items[$bid]['below'][$bid + 2]['below'][$bid + 6]$langcode);
      $toc = $bm->getTableOfContents($bid, 4);
      // Root entry does not have an indent.       $this->assertToCEntryIsCorrectlyTranslated($toc$langcode$bid, '');
      // The direct children of the root have one indent.       $this->assertToCEntryIsCorrectlyTranslated($toc$langcode$bid + 1, '--');
      
Home | Imprint | This part of the site doesn't use cookies.