function FilterNumericTest::providerTestFilterNumericBetween

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Kernel/Handler/FilterNumericTest.php \Drupal\Tests\views\Kernel\Handler\FilterNumericTest::providerTestFilterNumericBetween()
  2. 10 core/modules/views/tests/src/Kernel/Handler/FilterNumericTest.php \Drupal\Tests\views\Kernel\Handler\FilterNumericTest::providerTestFilterNumericBetween()
  3. 11.x core/modules/views/tests/src/Kernel/Handler/FilterNumericTest.php \Drupal\Tests\views\Kernel\Handler\FilterNumericTest::providerTestFilterNumericBetween()

Provides data for self::testFilterNumericBetween().

Return value

array An array of arrays, each containing the parameters for self::testFilterNumericBetween().

File

core/modules/views/tests/src/Kernel/Handler/FilterNumericTest.php, line 133

Class

FilterNumericTest
Tests the numeric filter handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function providerTestFilterNumericBetween() {
    $all_result = [
        [
            'name' => 'John',
            'age' => 25,
        ],
        [
            'name' => 'George',
            'age' => 27,
        ],
        [
            'name' => 'Ringo',
            'age' => 28,
        ],
        [
            'name' => 'Paul',
            'age' => 26,
        ],
        [
            'name' => 'Meredith',
            'age' => 30,
        ],
    ];
    return [
        // Each test case is operator, min, max, expected result.
'Test between' => [
            'between',
            26,
            29,
            [
                [
                    'name' => 'George',
                    'age' => 27,
                ],
                [
                    'name' => 'Ringo',
                    'age' => 28,
                ],
                [
                    'name' => 'Paul',
                    'age' => 26,
                ],
            ],
        ],
        'Test between with just min' => [
            'between',
            28,
            '',
            [
                [
                    'name' => 'Ringo',
                    'age' => 28,
                ],
                [
                    'name' => 'Meredith',
                    'age' => 30,
                ],
            ],
        ],
        'Test between with just max' => [
            'between',
            '',
            26,
            [
                [
                    'name' => 'John',
                    'age' => 25,
                ],
                [
                    'name' => 'Paul',
                    'age' => 26,
                ],
            ],
        ],
        'Test between with empty min and max' => [
            'between',
            '',
            '',
            $all_result,
        ],
        'Test not between' => [
            'not between',
            26,
            29,
            [
                [
                    'name' => 'John',
                    'age' => 25,
                ],
                [
                    'name' => 'Meredith',
                    'age' => 30,
                ],
            ],
        ],
        'Test not between with just min' => [
            'not between',
            28,
            '',
            [
                [
                    'name' => 'John',
                    'age' => 25,
                ],
                [
                    'name' => 'George',
                    'age' => 27,
                ],
                [
                    'name' => 'Paul',
                    'age' => 26,
                ],
            ],
        ],
        'Test not between with just max' => [
            'not between',
            '',
            26,
            [
                [
                    'name' => 'George',
                    'age' => 27,
                ],
                [
                    'name' => 'Ringo',
                    'age' => 28,
                ],
                [
                    'name' => 'Meredith',
                    'age' => 30,
                ],
            ],
        ],
        'Test not between with empty min and max' => [
            'not between',
            '',
            '',
            $all_result,
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.