tests/src/Functional/TermTest.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/src/Functional/TermTest.php b/tests/src/Functional/TermTest.php index c50dddc..5c3e12d 100644 --- a/tests/src/Functional/TermTest.php +++ b/tests/src/Functional/TermTest.php @@ -7,6 +7,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Url; +use Drupal\jsonapi\ResourceResponse; use Drupal\taxonomy\Entity\Term; use Drupal\taxonomy\Entity\Vocabulary; use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait; @@ -270,7 +271,7 @@ class TermTest extends ResourceTestBase { */ protected function getExpectedGetRelationshipDocumentData($relationship_field_name, EntityInterface $entity = NULL) { $data = parent::getExpectedGetRelationshipDocumentData($relationship_field_name, $entity); - if ($relationship_field_name === 'parent') { + if ($relationship_field_name === 'parent' && floatval(\Drupal::VERSION) >= 8.6) { $data = [ 0 => [ 'id' => 'virtual', @@ -284,6 +285,28 @@ class TermTest extends ResourceTestBase { /** * {@inheritdoc} */ + 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; + } + + /** + * {@inheritdoc} + */ protected function getPostDocument() { return [ 'data' => [