You are here

public function XMLSitemapUnitTest::testGetChangefreq in XML sitemap 7.2

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

Tests for xmlsitemap_get_changefreq().

File

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

Class

XMLSitemapUnitTest
XML Sitemap UnitTest.

Code

public function testGetChangefreq() {

  // The test values.
  $values = array(
    0,
    mt_rand(1, XMLSITEMAP_FREQUENCY_ALWAYS),
    mt_rand(XMLSITEMAP_FREQUENCY_ALWAYS + 1, XMLSITEMAP_FREQUENCY_HOURLY),
    mt_rand(XMLSITEMAP_FREQUENCY_HOURLY + 1, XMLSITEMAP_FREQUENCY_DAILY),
    mt_rand(XMLSITEMAP_FREQUENCY_DAILY + 1, XMLSITEMAP_FREQUENCY_WEEKLY),
    mt_rand(XMLSITEMAP_FREQUENCY_WEEKLY + 1, XMLSITEMAP_FREQUENCY_MONTHLY),
    mt_rand(XMLSITEMAP_FREQUENCY_MONTHLY + 1, XMLSITEMAP_FREQUENCY_YEARLY),
    mt_rand(XMLSITEMAP_FREQUENCY_YEARLY + 1, mt_getrandmax()),
  );

  // The expected values.
  $expected = array(
    FALSE,
    'always',
    'hourly',
    'daily',
    'weekly',
    'monthly',
    'yearly',
    'never',
  );
  foreach ($values as $i => $value) {
    $actual = xmlsitemap_get_changefreq($value);
    $this
      ->assertIdentical($actual, $expected[$i]);
  }
}