You are here

public function XmlSitemapUnitTest::testCalculateChangefreq in XML sitemap 2.x

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

Tests for xmlsitemap_calculate_changereq().

File

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

Class

XmlSitemapUnitTest
Unit tests for the XML sitemap module.

Namespace

Drupal\Tests\xmlsitemap\Functional

Code

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

  // The test values.
  $values = [
    [],
    [
      $request_time,
    ],
    [
      $request_time,
      $request_time - 200,
    ],
    [
      $request_time - 200,
      $request_time,
      $request_time - 600,
    ],
  ];

  // Expected values.
  $expected = [
    0,
    0,
    200,
    300,
  ];
  foreach ($values as $i => $value) {
    $actual = xmlsitemap_calculate_changefreq($value);
    $this
      ->assertEquals($expected[$i], $actual);
  }
}