You are here

public function XmlSitemapUnitTest::testRecalculateChangefreq in XML sitemap 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/XmlSitemapUnitTest.php \Drupal\Tests\xmlsitemap\Functional\XmlSitemapUnitTest::testRecalculateChangefreq()

Test for xmlsitemap_recalculate_changefreq().

File

tests/src/Functional/XmlSitemapUnitTest.php, line 133

Class

XmlSitemapUnitTest
Unit tests for the XML sitemap module.

Namespace

Drupal\Tests\xmlsitemap\Functional

Code

public function testRecalculateChangefreq() {
  $request_time = $this->time
    ->getRequestTime();

  // The starting test value.
  $value = [
    'lastmod' => $request_time - 1000,
    'changefreq' => 0,
    'changecount' => 0,
  ];

  // Expected values.
  $expecteds = [
    [
      'lastmod' => $request_time,
      'changefreq' => 1000,
      'changecount' => 1,
    ],
    [
      'lastmod' => $request_time,
      'changefreq' => 500,
      'changecount' => 2,
    ],
    [
      'lastmod' => $request_time,
      'changefreq' => 333,
      'changecount' => 3,
    ],
  ];
  foreach ($expecteds as $expected) {
    xmlsitemap_recalculate_changefreq($value);
    $this
      ->assertEquals($expected, $value);
  }
}