public function SiteMapCategoriesTest::testCategoriesDepth in Site map 8
Tests categories depth.
File
- src/
Tests/ SiteMapCategoriesTest.php, line 81
Class
- SiteMapCategoriesTest
- Test case class for site map categories tests.
Namespace
Drupal\site_map\TestsCode
public function testCategoriesDepth() {
$terms = $this
->createTerms($this->vocabulary);
$tags = array();
// Get tags from terms.
foreach ($terms as $term) {
$tags[] = $term
->label();
}
// Assert that no tags are listed in the site map.
$this
->drupalGet('sitemap');
foreach ($tags as $tag) {
$this
->assertNoLink($tag);
}
// Create dummy node.
$title = $this
->randomString();
$edit = array(
'title[0][value]' => $title,
'menu[enabled]' => TRUE,
'menu[title]' => $title,
$this->field_tags_name => implode(',', $tags),
);
$this
->drupalPostForm('node/add/article', $edit, t('Save and publish'));
// Change vocabulary depth to -1.
$edit = array(
'vocabulary_depth' => -1,
);
$this
->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));
// Assert that all tags are listed in the site map.
$this
->drupalGet('sitemap');
foreach ($tags as $tag) {
$this
->assertLink($tag);
}
// Change vocabulary depth to 0.
$edit = array(
'vocabulary_depth' => 0,
);
$this
->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));
// Assert that no tags are listed in the site map.
$this
->drupalGet('sitemap');
foreach ($tags as $tag) {
$this
->assertNoLink($tag);
}
// Change vocabulary depth to 1.
$edit = array(
'vocabulary_depth' => 1,
);
$this
->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));
// Assert that only tag 1 is listed in the site map.
$this
->drupalGet('sitemap');
$this
->assertLink($tags[0]);
$this
->assertNoLink($tags[1]);
$this
->assertNoLink($tags[2]);
// Change vocabulary depth to 2.
$edit = array(
'vocabulary_depth' => 2,
);
$this
->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));
// Assert that tag 1 and tag 2 are listed in the site map.
$this
->drupalGet('sitemap');
$this
->assertLink($tags[0]);
$this
->assertLink($tags[1]);
$this
->assertNoLink($tags[2]);
// Change vocabulary depth to 3.
$edit = array(
'vocabulary_depth' => 3,
);
$this
->drupalPostForm('admin/config/search/sitemap', $edit, t('Save configuration'));
// Assert that all tags are listed in the site map.
$this
->drupalGet('sitemap');
foreach ($tags as $tag) {
$this
->assertLink($tag);
}
}