protected function TermTest::getExpectedRelatedResponses in JSON:API 8
Builds an array of expected related ResourceResponses, keyed by field name.
Parameters
array $relationship_field_names: The relationship field names for which to build expected ResourceResponses.
array $request_options: Request options to apply.
\Drupal\Core\Entity\EntityInterface|null $entity: (optional) The entity for which to get expected related resources.
Return value
mixed An array of expected ResourceResponses, keyed by thier relationship field name.
Overrides ResourceTestBase::getExpectedRelatedResponses
See also
\GuzzleHttp\ClientInterface::request()
File
- tests/
src/ Functional/ TermTest.php, line 321
Class
- TermTest
- JSON API integration test for the "Term" content entity type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected function getExpectedRelatedResponses(array $relationship_field_names, array $request_options, EntityInterface $entity = NULL) {
$responses = parent::getExpectedRelatedResponses($relationship_field_names, $request_options, $entity);
if ($responses['parent']
->getStatusCode() === 404 && floatval(\Drupal::VERSION) >= 8.6) {
$responses['parent'] = new ResourceResponse([
'data' => [],
'jsonapi' => [
'meta' => [
'links' => [
'self' => 'http://jsonapi.org/format/1.0/',
],
],
'version' => '1.0',
],
'links' => [
'self' => static::getRelatedLink(static::toResourceIdentifier($this->entity), 'parent'),
],
]);
}
return $responses;
}