diff --git a/core/modules/book/src/Tests/BookTest.php b/core/modules/book/src/Tests/BookTest.php index 8c80fbb..15de3ca 100644 --- a/core/modules/book/src/Tests/BookTest.php +++ b/core/modules/book/src/Tests/BookTest.php @@ -480,6 +480,21 @@ public function testGetTableOfContents() { $this->assertNoOption('edit-book-pid', $nodes[11]->id()); // Node 9 should be available as an option. $this->assertOption('edit-book-pid', $nodes[9]->id()); + + // Get a shallow set of options. + /** @var \Drupal\book\BookManagerInterface $manager */ + $manager = $this->container->get('book.manager'); + $options = $manager->getTableOfContents($book->id(), 3); + $expected_nids = array($book->id(), $nodes[0]->id(), $nodes[1]->id(), $nodes[2]->id(), $nodes[3]->id(), $nodes[6]->id(), $nodes[4]->id()); + $this->assertEqual(count($options), count($expected_nids)); + $diff = array_diff($expected_nids, array_keys($options)); + $this->assertTrue(empty($diff), 'Found all expected option keys'); + // Exclude Node 3. + $options = $manager->getTableOfContents($book->id(), 3, array($nodes[3]->id())); + $expected_nids = array($book->id(), $nodes[0]->id(), $nodes[1]->id(), $nodes[2]->id(), $nodes[4]->id()); + $this->assertEqual(count($options), count($expected_nids)); + $diff = array_diff($expected_nids, array_keys($options)); + $this->assertTrue(empty($diff), 'Found all expected option keys after excluding Node 3'); } /**