setCurrentLanguage example


    }
    \Drupal::currentUser()->setAccount($this->createUser(['access content']));
  }

  /** * Tests various book manager methods return correct translations. * * @dataProvider langcodesProvider */
  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);
      
Home | Imprint | This part of the site doesn't use cookies.