function ResourceResponseValidatorTest::createRequest

Same name in other branches
  1. 8.9.x core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php \Drupal\Tests\jsonapi\Unit\EventSubscriber\ResourceResponseValidatorTest::createRequest()
  2. 10 core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php \Drupal\Tests\jsonapi\Unit\EventSubscriber\ResourceResponseValidatorTest::createRequest()
  3. 11.x core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php \Drupal\Tests\jsonapi\Unit\EventSubscriber\ResourceResponseValidatorTest::createRequest()

Helper method to create a request object.

Parameters

string $route_name: The route name with which to construct a request.

\Drupal\jsonapi\ResourceType\ResourceType $resource_type: The resource type for the requested route.

Return value

\Symfony\Component\HttpFoundation\Request The mock request object.

2 calls to ResourceResponseValidatorTest::createRequest()
ResourceResponseValidatorTest::testDoValidateResponse in core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php
@covers ::doValidateResponse
ResourceResponseValidatorTest::validateResponseProvider in core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php
Provides test cases for testValidateResponse.

File

core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php, line 216

Class

ResourceResponseValidatorTest
@coversDefaultClass \Drupal\jsonapi\EventSubscriber\ResourceResponseValidator @group jsonapi

Namespace

Drupal\Tests\jsonapi\Unit\EventSubscriber

Code

protected function createRequest($route_name, ResourceType $resource_type) {
    $request = new Request();
    $request->attributes
        ->set(RouteObjectInterface::ROUTE_NAME, $route_name);
    $request->attributes
        ->set(Routes::RESOURCE_TYPE_KEY, $resource_type);
    return $request;
}

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