function EntityConditionTest::validationProvider

Same name in other branches
  1. 9 core/modules/jsonapi/tests/src/Unit/Query/EntityConditionTest.php \Drupal\Tests\jsonapi\Unit\Query\EntityConditionTest::validationProvider()
  2. 8.9.x core/modules/jsonapi/tests/src/Unit/Query/EntityConditionTest.php \Drupal\Tests\jsonapi\Unit\Query\EntityConditionTest::validationProvider()
  3. 10 core/modules/jsonapi/tests/src/Unit/Query/EntityConditionTest.php \Drupal\Tests\jsonapi\Unit\Query\EntityConditionTest::validationProvider()

Data provider for testValidation.

File

core/modules/jsonapi/tests/src/Unit/Query/EntityConditionTest.php, line 90

Class

EntityConditionTest
@coversDefaultClass \Drupal\jsonapi\Query\EntityCondition @group jsonapi

Namespace

Drupal\Tests\jsonapi\Unit\Query

Code

public static function validationProvider() {
    return [
        [
            [
                'path' => 'some_field',
                'value' => 'some_value',
            ],
            NULL,
        ],
        [
            [
                'path' => 'some_field',
                'value' => 'some_value',
                'operator' => '=',
            ],
            NULL,
        ],
        [
            [
                'path' => 'some_field',
                'operator' => 'IS NULL',
            ],
            NULL,
        ],
        [
            [
                'path' => 'some_field',
                'operator' => 'IS NOT NULL',
            ],
            NULL,
        ],
        [
            [
                'path' => 'some_field',
                'operator' => 'IS',
                'value' => 'some_value',
            ],
            new BadRequestHttpException("The 'IS' operator is not allowed in a filter parameter."),
        ],
        [
            [
                'path' => 'some_field',
                'operator' => 'NOT_ALLOWED',
                'value' => 'some_value',
            ],
            new BadRequestHttpException("The 'NOT_ALLOWED' operator is not allowed in a filter parameter."),
        ],
        [
            [
                'path' => 'some_field',
                'operator' => 'IS NULL',
                'value' => 'should_not_be_here',
            ],
            new BadRequestHttpException("Filters using the 'IS NULL' operator should not provide a value."),
        ],
        [
            [
                'path' => 'some_field',
                'operator' => 'IS NOT NULL',
                'value' => 'should_not_be_here',
            ],
            new BadRequestHttpException("Filters using the 'IS NOT NULL' operator should not provide a value."),
        ],
        [
            [
                'path' => 'path_only',
            ],
            new BadRequestHttpException("Filter parameter is missing a '" . EntityCondition::VALUE_KEY . "' key."),
        ],
        [
            [
                'value' => 'value_only',
            ],
            new BadRequestHttpException("Filter parameter is missing a '" . EntityCondition::PATH_KEY . "' key."),
        ],
    ];
}

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