You are here

public function BookTest::testSaveBookLink in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/book/tests/src/Functional/BookTest.php \Drupal\Tests\book\Functional\BookTest::testSaveBookLink()
  2. 9 core/modules/book/tests/src/Functional/BookTest.php \Drupal\Tests\book\Functional\BookTest::testSaveBookLink()

Tests that saveBookLink() returns something.

File

core/modules/book/tests/src/Functional/BookTest.php, line 529

Class

BookTest
Create a book, add pages, and test book interface.

Namespace

Drupal\Tests\book\Functional

Code

public function testSaveBookLink() {
  $book_manager = \Drupal::service('book.manager');

  // Mock a link for a new book.
  $link = [
    'nid' => 1,
    'has_children' => 0,
    'original_bid' => 0,
    'pid' => 0,
    'weight' => 0,
    'bid' => 0,
  ];
  $new = TRUE;

  // Save the link.
  $return = $book_manager
    ->saveBookLink($link, $new);

  // Add the link defaults to $link so we have something to compare to the return from saveBookLink().
  $link = $book_manager
    ->getLinkDefaults($link['nid']);

  // Test the return from saveBookLink.
  $this
    ->assertEquals($return, $link);
}