public function XmlSitemapNodeFunctionalTest::testTagsField in XML sitemap 8
Same name and namespace in other branches
- 2.x tests/src/Functional/XmlSitemapNodeFunctionalTest.php \Drupal\Tests\xmlsitemap\Functional\XmlSitemapNodeFunctionalTest::testTagsField()
Test Tags Field.
File
- tests/
src/ Functional/ XmlSitemapNodeFunctionalTest.php, line 127
Class
- XmlSitemapNodeFunctionalTest
- Tests the generation of node links.
Namespace
Drupal\Tests\xmlsitemap\FunctionalCode
public function testTagsField() {
$this
->drupalLogin($this->admin_user);
$this
->drupalGet('node/add/page');
$title_key = 'title[0][value]';
$body_key = 'body[0][value]';
// Fill in node creation form and preview node.
$edit = [];
$edit[$title_key] = $this
->randomMachineName(8);
$edit[$body_key] = $this
->randomMachineName(16);
$edit['tags[target_id]'] = 'tag1, tag2, tag3';
$edit['status[value]'] = TRUE;
$this
->drupalPostForm('node/add/page', $edit, t('Save'));
$tags = Term::loadMultiple();
foreach ($tags as $tag) {
$this
->assertSitemapLinkValues('taxonomy_term', $tag
->id(), [
'status' => 0,
'priority' => 0.5,
'changefreq' => 0,
]);
$tag
->delete();
}
xmlsitemap_link_bundle_settings_save('taxonomy_term', 'tags', [
'status' => 1,
'priority' => 0.2,
'changefreq' => XMLSITEMAP_FREQUENCY_HOURLY,
]);
$this
->drupalPostForm('node/add/page', $edit, t('Save'));
$tags = Term::loadMultiple();
foreach ($tags as $tag) {
$this
->assertSitemapLinkValues('taxonomy_term', $tag
->id(), [
'status' => 1,
'priority' => 0.2,
'changefreq' => XMLSITEMAP_FREQUENCY_HOURLY,
]);
$tag
->delete();
}
}