public function XmlSitemapNodeFunctionalTest::testNodeSettings in XML sitemap 2.x
Same name and namespace in other branches
- 8 tests/src/Functional/XmlSitemapNodeFunctionalTest.php \Drupal\Tests\xmlsitemap\Functional\XmlSitemapNodeFunctionalTest::testNodeSettings()
Test Node Settings.
File
- tests/
src/ Functional/ XmlSitemapNodeFunctionalTest.php, line 173
Class
- XmlSitemapNodeFunctionalTest
- Tests the generation of node links.
Namespace
Drupal\Tests\xmlsitemap\FunctionalCode
public function testNodeSettings() {
$node = $this
->drupalCreateNode([
'publish' => 0,
'uid' => $this->normal_user
->id(),
]);
$this
->assertSitemapLinkValues('node', $node
->id(), [
'access' => 1,
'status' => 1,
'priority' => 0.6,
'status_override' => 0,
'priority_override' => 0,
'changefreq' => XMLSITEMAP_FREQUENCY_WEEKLY,
]);
$this
->drupalLogin($this->normal_user);
$this
->drupalGet('node/' . $node
->id() . '/edit');
$this
->assertSession()
->fieldNotExists('xmlsitemap[status]');
$this
->assertSession()
->fieldNotExists('xmlsitemap[priority]');
$edit = [
'title[0][value]' => 'Test node title',
'body[0][value]' => 'Test node body',
];
$this
->drupalPostForm('node/' . $node
->id() . '/edit', $edit, t('Save'));
$this
->assertSession()
->pageTextContains('Basic page Test node title has been updated.');
$this
->assertSitemapLinkValues('node', $node
->id(), [
'access' => 1,
'status' => 1,
'priority' => 0.6,
'status_override' => 0,
'priority_override' => 0,
'changefreq' => XMLSITEMAP_FREQUENCY_WEEKLY,
]);
$this
->drupalLogin($this->admin_user);
// Test fields are visible on the node add form.
$this
->drupalGet('node/add/page');
$this
->assertSession()
->fieldExists('xmlsitemap[status]');
$this
->assertSession()
->fieldExists('xmlsitemap[priority]');
$this
->assertSession()
->fieldExists('xmlsitemap[changefreq]');
$this
->drupalGet('node/' . $node
->id() . '/edit');
$edit = [
'xmlsitemap[status]' => 1,
'xmlsitemap[priority]' => 0.9,
'xmlsitemap[changefreq]' => XMLSITEMAP_FREQUENCY_ALWAYS,
];
$this
->drupalPostForm('node/' . $node
->id() . '/edit', $edit, t('Save'));
$this
->assertSession()
->pageTextContains('Basic page Test node title has been updated.');
$this
->assertSitemapLinkValues('node', $node
->id(), [
'access' => 1,
'status' => 1,
'priority' => 0.9,
'status_override' => 1,
'priority_override' => 1,
'changefreq' => XMLSITEMAP_FREQUENCY_ALWAYS,
]);
$edit = [
'xmlsitemap[status]' => 'default',
'xmlsitemap[priority]' => 'default',
];
$this
->drupalPostForm('node/' . $node
->id() . '/edit', $edit, t('Save'));
$this
->assertSession()
->pageTextContains('Basic page Test node title has been updated.');
$this
->assertSitemapLinkValues('node', $node
->id(), [
'access' => 1,
'status' => 1,
'priority' => 0.6,
'status_override' => 0,
'priority_override' => 0,
]);
}