You are here

public function XmlsitemapViewsFieldsTest::testNodeSettings in XML sitemap 7.2

Test that views can show XML sitemap settings on nodes.

File

tests/xmlsitemap_views_fields.test, line 39
Functional tests for providing xmlsitemap fields to views.

Class

XmlsitemapViewsFieldsTest
@file Functional tests for providing xmlsitemap fields to views.

Code

public function testNodeSettings() {

  // Create a node.
  $node = $this
    ->drupalCreateNode();

  // Create view with xmlsitemap fields.
  $view = $this
    ->nodeView();
  $view
    ->save();

  // Load view, check that xmlsitemap fields are not overridden.
  $this
    ->drupalGet('xmlsitemap-node-fields');
  $this
    ->assertRaw('<span class="xmlsitemap-priority">0.5</span>');
  $this
    ->assertRaw('<span class="xmlsitemap-priority-override">No</span>');
  $this
    ->assertRaw('<span class="xmlsitemap-inclusion">No</span>');
  $this
    ->assertRaw('<span class="xmlsitemap-inclusion-override">No</span>');

  // Override xmlsitemap fields for node.
  $node->xmlsitemap['priority'] = 0.6;
  $node->xmlsitemap['priority_override'] = 1;
  $node->xmlsitemap['status'] = 1;
  $node->xmlsitemap['status_override'] = 1;
  node_save($node);

  // Re-load view, check that xmlsitemap fields are overridden.
  $this
    ->drupalGet('xmlsitemap-node-fields');
  $this
    ->assertRaw('<span class="xmlsitemap-priority">0.6</span>');
  $this
    ->assertRaw('<span class="xmlsitemap-priority-override">Yes</span>');
  $this
    ->assertRaw('<span class="xmlsitemap-inclusion">Yes</span>');
  $this
    ->assertRaw('<span class="xmlsitemap-inclusion-override">Yes</span>');
}