You are here

protected function ResourceResponseValidatorTest::createResponse 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::createResponse()

Helper method to create a resource response from arbitrary JSON.

Parameters

string|null $json: The JSON with which to create a mock response.

Return value

\Drupal\rest\ResourceResponse The mock response object.

3 calls to ResourceResponseValidatorTest::createResponse()
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 305

Class

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

Namespace

Drupal\Tests\jsonapi\Unit\EventSubscriber

Code

protected function createResponse($json = NULL) {
  $response = new ResourceResponse();
  if ($json) {
    $response
      ->setContent($json);
  }
  return $response;
}