views_natural_sort.test 1.63 KB
Newer Older
1 2
<?php

3
class ViewsNaturalSortDaysOfTheWeekTest extends DrupalWebTestCase {
4 5 6

  public static function getInfo() {
    return array(
7 8 9
      'name' => 'Views Natural Sort Days of the Week',
      'description' => 'Tests Days of the Week Sorting',
      'group' => 'Views Natural Sort',
10 11 12
    );
  }

13 14 15 16 17
  function testDefaultDayReplace() {
    variable_set('views_natural_sort_days_of_the_week_enabled', TRUE);
    foreach(views_natural_sort_days_of_the_week_get_default_days() as $replaced => $day) {
      $this->assertEqual(views_natural_sort_days_of_the_week_sort_days($day), $replaced);
    }
18 19
  }

20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
  function testFirstDayMonday() {
    variable_set('views_natural_sort_days_of_the_week_enabled', TRUE);
    $variable_original = variable_get("views_natural_sort_days_of_the_week_first_day_en", "Sunday");
    variable_set("views_natural_sort_days_of_the_week_first_day_en", "Monday");
    db_set_active("default");
    $expected = array(
      "Monday",
      "Tuesday",
      "Wednesday",
      "Thursday",
      "Friday",
      "Saturday",
      "Sunday",
    );
    foreach($expected as $replaced => $day) {
      $this->assertEqual(views_natural_sort_days_of_the_week_sort_days($day), $replaced);
    }
    variable_set("views_natural_sort_days_of_the_week_first_day_en", $variable_original);
  }
  function testAbbreviations() {
    variable_set('views_natural_sort_days_of_the_week_enabled', TRUE);
    $expected = array(
      "Sun",
      "Mon.",
      "Tues",
      "Wed",
      "Thur",
      "Fri.",
      "Sat",
    );
    foreach($expected as $replaced => $day) {
      $this->assertEqual(views_natural_sort_days_of_the_week_sort_days($day), $replaced);
    }
53 54
  }
}