You are here

public function XmlSitemapNodeFunctionalTest::testTypeSettings in XML sitemap 2.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/XmlSitemapNodeFunctionalTest.php \Drupal\Tests\xmlsitemap\Functional\XmlSitemapNodeFunctionalTest::testTypeSettings()

Test the content type settings.

File

tests/src/Functional/XmlSitemapNodeFunctionalTest.php, line 247

Class

XmlSitemapNodeFunctionalTest
Tests the generation of node links.

Namespace

Drupal\Tests\xmlsitemap\Functional

Code

public function testTypeSettings() {
  $this
    ->drupalLogin($this->admin_user);
  $node_old = $this
    ->drupalCreateNode();
  $this
    ->assertSitemapLinkValues('node', $node_old
    ->id(), [
    'status' => 1,
    'priority' => 0.6,
    'changefreq' => XMLSITEMAP_FREQUENCY_WEEKLY,
  ]);
  $edit = [
    'xmlsitemap[status]' => 0,
    'xmlsitemap[priority]' => '0.0',
  ];
  $this
    ->drupalPostForm('admin/config/search/xmlsitemap/settings/node/page', $edit, t('Save configuration'));
  $this
    ->assertSession()
    ->pageTextContains('The configuration options have been saved.');
  $node = $this
    ->drupalCreateNode();
  $this
    ->assertSitemapLinkValues('node', $node
    ->id(), [
    'status' => 0,
    'priority' => 0.0,
  ]);
  $this
    ->assertSitemapLinkValues('node', $node_old
    ->id(), [
    'status' => 0,
    'priority' => 0.0,
  ]);

  // Delete all pages in order to allow content type deletion.
  $node
    ->delete();
  $node_old
    ->delete();
  $this
    ->drupalPostForm('admin/structure/types/manage/page/delete', [], t('Delete'));
  $this
    ->assertSession()
    ->pageTextContains('The content type Basic page has been deleted.');
  $this
    ->assertEmpty($this->linkStorage
    ->loadMultiple([
    'type' => 'node',
    'subtype' => 'page',
  ]), 'Nodes with deleted node type removed from {xmlsitemap}.');
}