XmlSitemapTaxonomyFunctionalTest.php in XML sitemap 2.x
File
tests/src/Functional/XmlSitemapTaxonomyFunctionalTest.php
View source
<?php
namespace Drupal\Tests\xmlsitemap\Functional;
use Drupal\Core\Language\LanguageInterface;
use Drupal\taxonomy\Entity\Vocabulary;
class XmlSitemapTaxonomyFunctionalTest extends XmlSitemapTestBase {
public static $modules = [
'taxonomy',
];
protected function setUp() {
parent::setUp();
$vocabulary = Vocabulary::create([
'name' => 'Tags',
'description' => $this
->randomMachineName(),
'vid' => 'tags',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'help' => '',
]);
$vocabulary
->save();
$this->admin_user = $this
->drupalCreateUser([
'administer taxonomy',
'administer xmlsitemap',
]);
}
public function testTaxonomySettings() {
$this
->drupalLogin($this->admin_user);
$settings = [
'status' => '1',
'priority' => '1.0',
];
xmlsitemap_link_bundle_settings_save('taxonomy_term', 'tags', $settings);
$this
->drupalGet('admin/structure/taxonomy/manage/tags/add');
$session = $this
->assertSession();
$session
->statusCodeEquals(200);
$session
->fieldExists('xmlsitemap[status]');
$session
->fieldExists('xmlsitemap[priority]');
$session
->fieldExists('xmlsitemap[changefreq]');
$term_name = $this
->randomMachineName();
$edit = [
'name[0][value]' => $term_name,
'xmlsitemap[status]' => 'default',
'xmlsitemap[priority]' => 'default',
];
$this
->drupalPostForm(NULL, $edit, t('Save'));
$term = taxonomy_term_load_multiple_by_name($term_name, 'tags')[1];
$link = $this->linkStorage
->load('taxonomy_term', $term
->id());
$this
->assertEquals(1, (int) $link['status']);
$this
->assertEquals(1, (int) $link['priority']);
}
}