public function SitemapTaxonomyTest::testVocabularyCrud in Sitemap 8.2
Same name and namespace in other branches
- 2.0.x src/Tests/SitemapTaxonomyTest.php \Drupal\sitemap\Tests\SitemapTaxonomyTest::testVocabularyCrud()
Test seamless functionality when created and deleting vocabularies.
File
- src/
Tests/ SitemapTaxonomyTest.php, line 72
Class
- SitemapTaxonomyTest
- Tests the display of taxonomies based on sitemap settings.
Namespace
Drupal\sitemap\TestsCode
public function testVocabularyCrud() {
// Create an additional vocabulary.
$vocabularyToDelete = $this
->createVocabulary();
// Configure the sitemap to display both vocabularies.
$vid = $this->vocabulary
->id();
$vid_to_delete = $vocabularyToDelete
->id();
$edit = [
"plugins[vocabulary:{$vid}][enabled]" => TRUE,
"plugins[vocabulary:{$vid_to_delete}][enabled]" => TRUE,
];
$this
->saveSitemapForm($edit);
// Ensure that both vocabularies are displayed.
$this
->drupalGet('/sitemap');
$elements = $this
->cssSelect(".sitemap-plugin--vocabulary");
$this
->assertEquals(count($elements), 2, '2 vocabularies are included');
$elements = $this
->cssSelect(".sitemap-item--vocabulary-{$vid}");
$this
->assertEquals(count($elements), 1, "Vocabulary {$vid} is included.");
$elements = $this
->cssSelect(".sitemap-item--vocabulary-{$vid_to_delete}");
$this
->assertEquals(count($elements), 1, "Vocabulary {$vid_to_delete} is included.");
// Delete the vocabulary.
$vocabularyToDelete
->delete();
// @todo We shouldn't have to do this if vocab cache tags are in place...
drupal_flush_all_caches();
// Visit /sitemap.
$this
->drupalGet('/sitemap');
$elements = $this
->cssSelect(".sitemap-plugin--vocabulary");
$this
->assertEquals(count($elements), 1, '1 vocabulary is included');
$elements = $this
->cssSelect(".sitemap-item--vocabulary-{$vid}");
$this
->assertEquals(count($elements), 1, "Vocabulary {$vid} is included.");
$elements = $this
->cssSelect(".sitemap-item--vocabulary-{$vid_to_delete}");
$this
->assertEquals(count($elements), 0, "Vocabulary {$vid_to_delete} is included.");
// Visit the sitemap configuration page to ensure no errors there.
$this
->drupalGet('/admin/config/search/sitemap');
}