SitemapTaxonomyTest.php in Sitemap 2.0.x
File
src/Tests/SitemapTaxonomyTest.php
View source
<?php
namespace Drupal\sitemap\Tests;
class SitemapTaxonomyTest extends SitemapTaxonomyTestBase {
use SitemapTestTrait;
public static $modules = [
'sitemap',
'node',
'taxonomy',
];
public function testVocabularyTitle() {
$vocab = $this->vocabulary;
$vid = $vocab
->id();
$this
->titleTest($vocab
->label(), 'vocabulary', $vid, TRUE);
}
public function testVocabularyDescription() {
$vid = $this->vocabulary
->id();
$this
->drupalGet('/sitemap');
$elements = $this
->cssSelect(".sitemap-plugin--vocabulary");
$this
->assertEqual(count($elements), 1, 'Vocabulary found.');
$this
->assertNoText($this->vocabulary
->getDescription());
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][show_description]" => TRUE,
]);
$this
->assertText($this->vocabulary
->getDescription());
$this
->createTerms($this->vocabulary);
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][term_count_threshold]" => -1,
]);
$this
->drupalGet('/sitemap');
$this
->assertText($this->vocabulary
->getDescription());
$this
->saveSitemapForm([
"plugins[vocabulary:{$vid}][settings][show_description]" => FALSE,
]);
$this
->drupalGet('/sitemap');
$this
->assertNoText($this->vocabulary
->getDescription());
}
public function testVocabularyCrud() {
$vocabularyToDelete = $this
->createVocabulary();
$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);
$this
->drupalGet('/sitemap');
$elements = $this
->cssSelect(".sitemap-plugin--vocabulary");
$this
->assertEqual(count($elements), 2, '2 vocabularies are included');
$elements = $this
->cssSelect(".sitemap-item--vocabulary-{$vid}");
$this
->assertEqual(count($elements), 1, "Vocabulary {$vid} is included.");
$elements = $this
->cssSelect(".sitemap-item--vocabulary-{$vid_to_delete}");
$this
->assertEqual(count($elements), 1, "Vocabulary {$vid_to_delete} is included.");
$vocabularyToDelete
->delete();
drupal_flush_all_caches();
$this
->drupalGet('/sitemap');
$elements = $this
->cssSelect(".sitemap-plugin--vocabulary");
$this
->assertEqual(count($elements), 1, '1 vocabulary is included');
$elements = $this
->cssSelect(".sitemap-item--vocabulary-{$vid}");
$this
->assertEqual(count($elements), 1, "Vocabulary {$vid} is included.");
$elements = $this
->cssSelect(".sitemap-item--vocabulary-{$vid_to_delete}");
$this
->assertEqual(count($elements), 0, "Vocabulary {$vid_to_delete} is included.");
$this
->drupalGet('/admin/config/search/sitemap');
}
}