function EntityConditionTest::validationProvider

Same name and namespace in other branches
  1. 8.9.x core/modules/jsonapi/tests/src/Unit/Query/EntityConditionTest.php \Drupal\Tests\jsonapi\Unit\Query\EntityConditionTest::validationProvider()
  2. 10 core/modules/jsonapi/tests/src/Unit/Query/EntityConditionTest.php \Drupal\Tests\jsonapi\Unit\Query\EntityConditionTest::validationProvider()
  3. 11.x 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 88

Class

EntityConditionTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21jsonapi%21src%21Query%21EntityCondition.php/class/EntityCondition/9" title="A condition object for the EntityQuery." class="local">\Drupal\jsonapi\Query\EntityCondition</a> @group jsonapi

Namespace

Drupal\Tests\jsonapi\Unit\Query

Code

public 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.