You are here

protected function JsonapiMenuItemsTest::getJsonApiMenuItemsResponse in JSON:API Menu Items 1.2.x

Get a JSON:API Menu Items resource response document.

Parameters

\Drupal\core\Url $url: The url for a JSON:API View.

Return value

array The response document and headers.

6 calls to JsonapiMenuItemsTest::getJsonApiMenuItemsResponse()
JsonapiMenuItemsTest::testJsonapiMenuItemsResource in tests/src/Functional/JsonapiMenuItemsTest.php
Tests the JSON:API Menu Items resource.
JsonapiMenuItemsTest::testParametersConditions in tests/src/Functional/JsonapiMenuItemsTest.php
Tests the JSON:API Menu Items resource with the 'conditions' filter.
JsonapiMenuItemsTest::testParametersMaxDepth in tests/src/Functional/JsonapiMenuItemsTest.php
Tests the JSON:API Menu Items resource with the 'max_depth' filter.
JsonapiMenuItemsTest::testParametersMinDepth in tests/src/Functional/JsonapiMenuItemsTest.php
Tests the JSON:API Menu Items resource with the 'min_depth' filter.
JsonapiMenuItemsTest::testParametersParent in tests/src/Functional/JsonapiMenuItemsTest.php
Tests the JSON:API Menu Items resource with the 'parent' filter.

... See full list

File

tests/src/Functional/JsonapiMenuItemsTest.php, line 299

Class

JsonapiMenuItemsTest
Tests JSON:API Menu Items functionality.

Namespace

Drupal\Tests\jsonapi_menu_items\Functional

Code

protected function getJsonApiMenuItemsResponse(Url $url) {
  $request_options = [];
  $request_options[RequestOptions::HEADERS]['Accept'] = 'application/vnd.api+json';
  $response = $this
    ->request('GET', $url, $request_options);
  $this
    ->assertSame(200, $response
    ->getStatusCode(), var_export(Json::decode((string) $response
    ->getBody()), TRUE));
  $response_document = Json::decode((string) $response
    ->getBody());
  $this
    ->assertIsArray($response_document['data']);
  $this
    ->assertArrayNotHasKey('errors', $response_document);
  return [
    $response_document,
    $response
      ->getHeaders(),
  ];
}