function ViewsHandlerSortDateTest::expectedResultSet

1 call to ViewsHandlerSortDateTest::expectedResultSet()
ViewsHandlerSortDateTest::testDateOrdering in tests/handlers/views_handler_sort_date.test
Tests numeric ordering of the result set.

File

tests/handlers/views_handler_sort_date.test, line 27

Class

ViewsHandlerSortDateTest
Tests for core views_handler_sort_date 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;
}