You are here

public function XMLSitemapNodeFunctionalTest::testNodeSettings in XML sitemap 7.2

Same name and namespace in other branches
  1. 6.2 xmlsitemap_node/xmlsitemap_node.test \XMLSitemapNodeFunctionalTest::testNodeSettings()

Node Settings.

File

xmlsitemap_node/xmlsitemap_node.test, line 66
Unit tests for the xmlsitemap_node module.

Class

XMLSitemapNodeFunctionalTest
Node Functional Test.

Code

public function testNodeSettings() {
  $body_field = 'body[' . LANGUAGE_NONE . '][0][value]';
  $node = $this
    ->drupalCreateNode(array(
    'status' => FALSE,
    'uid' => $this->normal_user->uid,
  ));
  $this
    ->cronRun();
  $this
    ->assertSitemapLinkValues('node', $node->nid, array(
    'access' => 0,
    'status' => 1,
    'priority' => 0.5,
    'status_override' => 0,
    'priority_override' => 0,
  ));
  $this
    ->drupalLogin($this->normal_user);
  $this
    ->drupalGet('node/' . $node->nid . '/edit');
  $this
    ->assertNoField('xmlsitemap[status]');
  $this
    ->assertNoField('xmlsitemap[priority]');
  $edit = array(
    'title' => 'Test node title',
    $body_field => 'Test node body',
  );
  $this
    ->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
  $this
    ->assertText('Basic page Test node title has been updated.');
  $this
    ->cronRun();
  $this
    ->assertSitemapLinkValues('node', $node->nid, array(
    'access' => 0,
    'status' => 1,
    'priority' => 0.5,
    'status_override' => 0,
    'priority_override' => 0,
  ));
  $this
    ->drupalLogin($this->admin_user);
  $this
    ->drupalGet('node/' . $node->nid . '/edit');
  $this
    ->assertField('xmlsitemap[status]');
  $this
    ->assertField('xmlsitemap[priority]');
  $edit = array(
    'xmlsitemap[status]' => 0,
    'xmlsitemap[priority]' => 0.9,
    'status' => TRUE,
  );
  $this
    ->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
  $this
    ->assertText('Basic page Test node title has been updated.');
  $this
    ->cronRun();
  $this
    ->assertSitemapLinkValues('node', $node->nid, array(
    'access' => 1,
    'status' => 0,
    'priority' => 0.9,
    'status_override' => 1,
    'priority_override' => 1,
  ));
  $edit = array(
    'xmlsitemap[status]' => 'default',
    'xmlsitemap[priority]' => 'default',
    'status' => FALSE,
  );
  $this
    ->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
  $this
    ->assertText('Basic page Test node title has been updated.');
  $this
    ->cronRun();
  $this
    ->assertSitemapLinkValues('node', $node->nid, array(
    'access' => 0,
    'status' => 1,
    'priority' => 0.5,
    'status_override' => 0,
    'priority_override' => 0,
  ));
}