You are here

public function XMLSitemapNodeFunctionalTest::testTypeSettings in XML sitemap 7.2

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

Test the content type settings.

File

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

Class

XMLSitemapNodeFunctionalTest
Node Functional Test.

Code

public function testTypeSettings() {
  $this
    ->drupalLogin($this->admin_user);
  $node_old = $this
    ->drupalCreateNode();
  $this
    ->cronRun();
  $this
    ->assertSitemapLinkValues('node', $node_old->nid, array(
    'status' => 1,
    'priority' => 0.5,
  ));
  $edit = array(
    'xmlsitemap[status]' => 0,
    'xmlsitemap[priority]' => '0.0',
  );
  $this
    ->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type'));
  $this
    ->assertText('The content type Basic page has been updated.');
  $node = $this
    ->drupalCreateNode();
  $this
    ->cronRun();
  $this
    ->assertSitemapLinkValues('node', $node->nid, array(
    'status' => 0,
    'priority' => 0.0,
  ));
  $this
    ->assertSitemapLinkValues('node', $node_old->nid, array(
    'status' => 0,
    'priority' => 0.0,
  ));
  $edit = array(
    'type' => 'page2',
    'xmlsitemap[status]' => 1,
    'xmlsitemap[priority]' => '0.5',
  );
  $this
    ->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type'));
  $this
    ->assertText('Changed the content type of 2 posts from page to page2.');
  $this
    ->assertText('The content type Basic page has been updated.');
  $this
    ->cronRun();
  $this
    ->assertSitemapLinkValues('node', $node->nid, array(
    'subtype' => 'page2',
    'status' => 1,
    'priority' => 0.5,
  ));
  $this
    ->assertSitemapLinkValues('node', $node_old->nid, array(
    'subtype' => 'page2',
    'status' => 1,
    'priority' => 0.5,
  ));
  $this
    ->assertEqual(count(xmlsitemap_link_load_multiple(array(
    'type' => 'node',
    'subtype' => 'page',
  ))), 0);
  $this
    ->assertEqual(count(xmlsitemap_link_load_multiple(array(
    'type' => 'node',
    'subtype' => 'page2',
  ))), 2);
  $this
    ->drupalPost('admin/structure/types/manage/page2/delete', array(), t('Delete'));
  $this
    ->assertText('The content type Basic page has been deleted.');
  $this
    ->assertFalse(xmlsitemap_link_load_multiple(array(
    'type' => 'node',
    'subtype' => 'page2',
  )), 'Nodes with deleted node type removed from {xmlsitemap}.');
}