You are here

public function XMLSitemapUnitTest::testUpdateLinks in XML sitemap 7.2

Same name and namespace in other branches
  1. 6.2 xmlsitemap.test \XMLSitemapUnitTest::testUpdateLinks()

Tests for xmlsitemap_link_update_multiple().

File

./xmlsitemap.test, line 722
Unit tests for the xmlsitemap.

Class

XMLSitemapUnitTest
XML Sitemap UnitTest.

Code

public function testUpdateLinks() {

  // Add our testing data.
  $links = array();
  $links[1] = $this
    ->addSitemapLink(array(
    'subtype' => 'group1',
  ));
  $links[2] = $this
    ->addSitemapLink(array(
    'subtype' => 'group1',
  ));
  $links[3] = $this
    ->addSitemapLink(array(
    'subtype' => 'group2',
  ));
  variable_set('xmlsitemap_regenerate_needed', FALSE);

  // Id | type    | subtype | language | access | status | priority
  // 1  | testing | group1  | ''       | 1      | 1      | 0.5
  // 2  | testing | group1  | ''       | 1      | 1      | 0.5
  // 3  | testing | group2  | ''       | 1      | 1      | 0.5.
  $updated = xmlsitemap_link_update_multiple(array(
    'status' => 0,
  ), array(
    'type' => 'testing',
    'subtype' => 'group1',
    'status_override' => 0,
  ));
  $this
    ->assertEqual($updated, 2);
  $this
    ->assertFlag('regenerate_needed', TRUE);

  // Id | type    | subtype | language | status | priority
  // 1  | testing | group1  | ''       | 0      | 0.5
  // 2  | testing | group1  | ''       | 0      | 0.5
  // 3  | testing | group2  | ''       | 1      | 0.5.
  $updated = xmlsitemap_link_update_multiple(array(
    'priority' => 0.0,
  ), array(
    'type' => 'testing',
    'subtype' => 'group1',
    'priority_override' => 0,
  ));
  $this
    ->assertEqual($updated, 2);
  $this
    ->assertFlag('regenerate_needed', FALSE);

  // Id | type    | subtype | language | status | priority
  // 1  | testing | group1  | ''       | 0      | 0.0
  // 2  | testing | group1  | ''       | 0      | 0.0
  // 3  | testing | group2  | ''       | 1      | 0.5.
  $updated = xmlsitemap_link_update_multiple(array(
    'subtype' => 'group2',
  ), array(
    'type' => 'testing',
    'subtype' => 'group1',
  ));
  $this
    ->assertEqual($updated, 2);
  $this
    ->assertFlag('regenerate_needed', FALSE);

  // Id | type    | subtype | language | status | priority
  // 1  | testing | group2  | ''       | 0      | 0.0
  // 2  | testing | group2  | ''       | 0      | 0.0
  // 3  | testing | group2  | ''       | 1      | 0.5.
  $updated = xmlsitemap_link_update_multiple(array(
    'status' => 1,
  ), array(
    'type' => 'testing',
    'subtype' => 'group2',
    'status_override' => 0,
    'status' => 0,
  ));
  $this
    ->assertEqual($updated, 2);
  $this
    ->assertFlag('regenerate_needed', TRUE);

  // Id | type    | subtype | language | status | priority
  // 1  | testing | group2  | ''       | 1      | 0.0
  // 2  | testing | group2  | ''       | 1      | 0.0
  // 3  | testing | group2  | ''       | 1      | 0.5.
}