public function SitemapBookTest::testBooks in Sitemap 2.0.x
Same name and namespace in other branches
- 8.2 src/Tests/SitemapBookTest.php \Drupal\sitemap\Tests\SitemapBookTest::testBooks()
- 8 src/Tests/SitemapBookTest.php \Drupal\sitemap\Tests\SitemapBookTest::testBooks()
Tests books.
File
- src/
Tests/ SitemapBookTest.php, line 57
Class
- SitemapBookTest
- Test the display of books based on sitemap settings.
Namespace
Drupal\sitemap\TestsCode
public function testBooks() {
// Assert that books are not included in the sitemap by default.
$this
->drupalGet('/sitemap');
$elements = $this
->cssSelect(".sitemap-plugin--book");
$this
->assertEqual(count($elements), 0, 'Books are not included.');
// Configure sitemap to show the test book.
$bid = $this->book
->id();
$nodes = $this->nodes;
$edit = [
'plugins[book:' . $bid . '][enabled]' => TRUE,
];
$this
->saveSitemapForm($edit);
// Assert that all book links are displayed by default.
$this
->drupalGet('/sitemap');
$this
->assertLink($this->book
->getTitle());
foreach ($nodes as $node) {
$this
->assertLink($node
->getTitle());
}
// Configure sitemap to not expand books.
$edit = [
'plugins[book:' . $bid . '][settings][show_expanded]' => FALSE,
];
$this
->saveSitemapForm($edit);
// Assert that the top-level book link is displayed, but that the others are
// not.
$this
->drupalGet('/sitemap');
$this
->assertLink($this->book
->getTitle());
foreach ($nodes as $node) {
$this
->assertNoLink($node
->getTitle());
}
}