You are here

protected function SortDateTest::expectedResultSet in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/Handler/SortDateTest.php \Drupal\views\Tests\Handler\SortDateTest::expectedResultSet()
1 call to SortDateTest::expectedResultSet()
SortDateTest::testDateOrdering in core/modules/views/src/Tests/Handler/SortDateTest.php
Tests numeric ordering of the result set.

File

core/modules/views/src/Tests/Handler/SortDateTest.php, line 28
Contains \Drupal\views\Tests\Handler\SortDateTest.

Class

SortDateTest
Tests for core Drupal\views\Plugin\views\sort\Date handler.

Namespace

Drupal\views\Tests\Handler

Code

protected function expectedResultSet($granularity, $reverse = TRUE) {
  $expected = array();
  if (!$reverse) {
    switch ($granularity) {
      case 'second':
        $expected = array(
          array(
            'name' => 'John',
          ),
          array(
            'name' => 'Paul',
          ),
          array(
            'name' => 'Meredith',
          ),
          array(
            'name' => 'Ringo',
          ),
          array(
            'name' => 'George',
          ),
        );
        break;
      case 'minute':
        $expected = array(
          array(
            'name' => 'John',
          ),
          array(
            'name' => 'Paul',
          ),
          array(
            'name' => 'Ringo',
          ),
          array(
            'name' => 'Meredith',
          ),
          array(
            'name' => 'George',
          ),
        );
        break;
      case 'hour':
        $expected = array(
          array(
            'name' => 'John',
          ),
          array(
            'name' => 'Ringo',
          ),
          array(
            'name' => 'Paul',
          ),
          array(
            'name' => 'Meredith',
          ),
          array(
            'name' => 'George',
          ),
        );
        break;
      case 'day':
        $expected = array(
          array(
            'name' => 'John',
          ),
          array(
            'name' => 'Ringo',
          ),
          array(
            'name' => 'Paul',
          ),
          array(
            'name' => 'Meredith',
          ),
          array(
            'name' => 'George',
          ),
        );
        break;
      case 'month':
        $expected = array(
          array(
            'name' => 'John',
          ),
          array(
            'name' => 'George',
          ),
          array(
            'name' => 'Ringo',
          ),
          array(
            'name' => 'Paul',
          ),
          array(
            'name' => 'Meredith',
          ),
        );
        break;
      case 'year':
        $expected = array(
          array(
            'name' => 'John',
          ),
          array(
            'name' => 'George',
          ),
          array(
            'name' => 'Ringo',
          ),
          array(
            'name' => 'Paul',
          ),
          array(
            'name' => 'Meredith',
          ),
        );
        break;
    }
  }
  else {
    switch ($granularity) {
      case 'second':
        $expected = array(
          array(
            'name' => 'George',
          ),
          array(
            'name' => 'Ringo',
          ),
          array(
            'name' => 'Meredith',
          ),
          array(
            'name' => 'Paul',
          ),
          array(
            'name' => 'John',
          ),
        );
        break;
      case 'minute':
        $expected = array(
          array(
            'name' => 'George',
          ),
          array(
            'name' => 'Ringo',
          ),
          array(
            'name' => 'Meredith',
          ),
          array(
            'name' => 'Paul',
          ),
          array(
            'name' => 'John',
          ),
        );
        break;
      case 'hour':
        $expected = array(
          array(
            'name' => 'George',
          ),
          array(
            'name' => 'Ringo',
          ),
          array(
            'name' => 'Paul',
          ),
          array(
            'name' => 'Meredith',
          ),
          array(
            'name' => 'John',
          ),
        );
        break;
      case 'day':
        $expected = array(
          array(
            'name' => 'George',
          ),
          array(
            'name' => 'John',
          ),
          array(
            'name' => 'Ringo',
          ),
          array(
            'name' => 'Paul',
          ),
          array(
            'name' => 'Meredith',
          ),
        );
        break;
      case 'month':
        $expected = array(
          array(
            'name' => 'John',
          ),
          array(
            'name' => 'George',
          ),
          array(
            'name' => 'Ringo',
          ),
          array(
            'name' => 'Paul',
          ),
          array(
            'name' => 'Meredith',
          ),
        );
        break;
      case 'year':
        $expected = array(
          array(
            'name' => 'John',
          ),
          array(
            'name' => 'George',
          ),
          array(
            'name' => 'Ringo',
          ),
          array(
            'name' => 'Paul',
          ),
          array(
            'name' => 'Meredith',
          ),
        );
        break;
    }
  }
  return $expected;
}