public function BookTest::testBook in Tome 8
@covers \Drupal\tome_sync\EventSubscriber\BookEventSubscriber::exportBookOutlines @covers \Drupal\tome_sync\EventSubscriber\BookEventSubscriber::importBookOutlines
File
- modules/
tome_sync/ tests/ src/ Functional/ BookTest.php, line 75
Class
- BookTest
- Tests that book support works.
Namespace
Drupal\Tests\tome_sync\FunctionalCode
public function testBook() {
// Create a book.
$nodes = $this
->createBook();
$book = $this->book;
// Assert that the exported JSON is not empty.
$index_file = Settings::get('tome_book_outline_directory') . '/book_outlines.json';
$this
->assertFileExists($index_file);
$outlines = json_decode(file_get_contents($index_file), TRUE);
$this
->assertNotEmpty($outlines);
// Delete the book outline from the database.
\Drupal::database()
->truncate('book')
->execute();
// Trigger an import.
\Drupal::service('tome_sync.book_event_subscriber')
->importBookOutlines();
// Test the book.
$this
->drupalLogin($this->webUser);
$this
->checkBookNode($book, [
$nodes[0],
$nodes[3],
$nodes[4],
], FALSE, FALSE, $nodes[0], []);
$this
->checkBookNode($nodes[0], [
$nodes[1],
$nodes[2],
], $book, $book, $nodes[1], [
$book,
]);
$this
->checkBookNode($nodes[1], NULL, $nodes[0], $nodes[0], $nodes[2], [
$book,
$nodes[0],
]);
$this
->checkBookNode($nodes[2], NULL, $nodes[1], $nodes[0], $nodes[3], [
$book,
$nodes[0],
]);
$this
->checkBookNode($nodes[3], NULL, $nodes[2], $book, $nodes[4], [
$book,
]);
$this
->checkBookNode($nodes[4], NULL, $nodes[3], $book, FALSE, [
$book,
]);
}