You are here

protected function ResourceResponseValidatorTest::createRequest in JSON:API 8

Same name and namespace in other branches
  1. 8.2 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.

3 calls to ResourceResponseValidatorTest::createRequest()
ResourceResponseValidatorTest::testDoValidateResponse in tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php
@covers ::doValidateResponse
ResourceResponseValidatorTest::testValidateResponseSchemata in tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php
@covers ::onResponse
ResourceResponseValidatorTest::validateResponseProvider in tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php
Provides test cases for testValidateResponse.

File

tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php, line 289

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;
}