jsonapi.info.yml | 1 - jsonapi.module | 16 ------ src/Access/TemporaryQueryGuard.php | 13 ----- .../tests/Traits/EntityReferenceTestTrait.php | 67 ---------------------- src/JsonapiServiceProvider.php | 12 ---- tests/src/Functional/BlockContentTest.php | 7 +-- tests/src/Functional/BlockTest.php | 2 +- tests/src/Functional/CommentTest.php | 19 +----- tests/src/Functional/ConfigTestTest.php | 2 +- tests/src/Functional/EntityTestMapFieldTest.php | 3 - tests/src/Functional/EntityViewDisplayTest.php | 9 +-- tests/src/Functional/FileTest.php | 3 +- tests/src/Functional/ImageStyleTest.php | 6 +- tests/src/Functional/InternalEntitiesTest.php | 2 +- tests/src/Functional/JsonApiFunctionalTestBase.php | 2 +- tests/src/Functional/MediaTest.php | 23 +------- tests/src/Functional/MenuLinkContentTest.php | 2 +- tests/src/Functional/ResourceTestBase.php | 7 --- tests/src/Functional/ShortcutSetTest.php | 2 +- tests/src/Functional/TermTest.php | 44 +++----------- tests/src/Functional/UserTest.php | 4 +- tests/src/Functional/VocabularyTest.php | 6 +- .../JsonApiDocumentTopLevelNormalizerTest.php | 4 +- 23 files changed, 31 insertions(+), 225 deletions(-) diff --git a/jsonapi.info.yml b/jsonapi.info.yml index f2135bc..9e77ac2 100644 --- a/jsonapi.info.yml +++ b/jsonapi.info.yml @@ -4,7 +4,6 @@ description: Provides a JSON:API standards-compliant API for accessing and manip core: 8.x package: Web services dependencies: - - drupal:system (>=8.5.4) - drupal:serialization test_dependencies: - schemata:schemata_json_schema diff --git a/jsonapi.module b/jsonapi.module index a092541..f1256bf 100644 --- a/jsonapi.module +++ b/jsonapi.module @@ -99,22 +99,6 @@ function jsonapi_help($route_name, RouteMatchInterface $route_match) { } /** - * Implements hook_entity_bundle_field_info(). - */ -function jsonapi_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) { - $fields = []; - - if (floatval(\Drupal::VERSION) < 8.6 && $entity_type->id() == 'taxonomy_term') { - // Only terms in the same bundle can be a parent. - $fields['parent'] = clone $base_field_definitions['parent']; - $fields['parent']->setSetting('handler_settings', ['target_bundles' => [$bundle]]); - return $fields; - } - - return $fields; -} - -/** * Implements hook_entity_bundle_create(). */ function jsonapi_entity_bundle_create() { diff --git a/src/Access/TemporaryQueryGuard.php b/src/Access/TemporaryQueryGuard.php index 618e48e..8150350 100644 --- a/src/Access/TemporaryQueryGuard.php +++ b/src/Access/TemporaryQueryGuard.php @@ -374,15 +374,6 @@ class TemporaryQueryGuard { $cacheability->addCacheTags($entity_type->getListCacheTags()); } } - // @todo Remove when Drupal 8.5 support is dropped (terms are publishable in >=8.6). - if (floatval(\Drupal::VERSION) < 8.6 && $entity_type->id() === 'taxonomy_term') { - $access_result = $access_results[JSONAPI_FILTER_AMONG_PUBLISHED]; - $cacheability->addCacheableDependency($access_result); - if ($access_result->isAllowed()) { - $conditions[] = new EntityCondition('tid', 0, '>'); - $cacheability->addCacheTags($entity_type->getListCacheTags()); - } - } // The "enabled" subset. // @todo Remove ternary when the 'status' key is added to the User entity type. @@ -399,10 +390,6 @@ class TemporaryQueryGuard { // The "owner" subset. // @todo Remove ternary when the 'uid' key is added to the User entity type. $owner_field_name = $entity_type->id() === 'user' ? 'uid' : $entity_type->getKey('owner'); - // @todo Remove when Drupal 8.5 and 8.6 support is dropped. - if (floatval(\Drupal::VERSION) < 8.7) { - $owner_field_name = $entity_type->id() === 'user' ? $owner_field_name : $entity_type->getKey('uid'); - } if ($owner_field_name) { $access_result = $access_results[JSONAPI_FILTER_AMONG_OWN]; $cacheability->addCacheableDependency($access_result); diff --git a/src/BackwardCompatibility/tests/Traits/EntityReferenceTestTrait.php b/src/BackwardCompatibility/tests/Traits/EntityReferenceTestTrait.php deleted file mode 100644 index 2c8a5e3..0000000 --- a/src/BackwardCompatibility/tests/Traits/EntityReferenceTestTrait.php +++ /dev/null @@ -1,67 +0,0 @@ -=8.6 - */ -trait EntityReferenceTestTrait { - - /** - * Creates an entity reference field storage on the specified bundle. - * - * @param string $entity_type - * The type of entity the field will be attached to. - * @param string $bundle - * The bundle name of the entity the field will be attached to. - * @param string $field_name - * The name of the field; if it already exists, a new instance of the - * existing field will be created. - * @param string $field_label - * The label of the field. - * @param string $target_entity_type - * The type of the referenced entity. - * @param string $selection_handler - * The selection handler used by this field. - * @param array $selection_handler_settings - * An array of settings supported by the selection handler specified above. - * (e.g. 'target_bundles', 'sort', 'auto_create', etc). - * @param int $cardinality - * The cardinality of the field. - * - * @see \Drupal\Core\Entity\Plugin\EntityReferenceSelection\SelectionBase::buildConfigurationForm() - */ - protected function createEntityReferenceField($entity_type, $bundle, $field_name, $field_label, $target_entity_type, $selection_handler = 'default', array $selection_handler_settings = [], $cardinality = 1) { - // Look for or add the specified field to the requested entity bundle. - if (!FieldStorageConfig::loadByName($entity_type, $field_name)) { - FieldStorageConfig::create([ - 'field_name' => $field_name, - 'type' => 'entity_reference', - 'entity_type' => $entity_type, - 'cardinality' => $cardinality, - 'settings' => [ - 'target_type' => $target_entity_type, - ], - ])->save(); - } - if (!FieldConfig::loadByName($entity_type, $bundle, $field_name)) { - FieldConfig::create([ - 'field_name' => $field_name, - 'entity_type' => $entity_type, - 'bundle' => $bundle, - 'label' => $field_label, - 'settings' => [ - 'handler' => $selection_handler, - 'handler_settings' => $selection_handler_settings, - ], - ])->save(); - } - } - -} diff --git a/src/JsonapiServiceProvider.php b/src/JsonapiServiceProvider.php index d04181e..c2cf9b3 100644 --- a/src/JsonapiServiceProvider.php +++ b/src/JsonapiServiceProvider.php @@ -8,7 +8,6 @@ use Drupal\Core\DependencyInjection\ServiceProviderInterface; use Drupal\jsonapi\DependencyInjection\Compiler\RegisterSerializationClassesCompilerPass; use Drupal\jsonapi\DependencyInjection\Compiler\RemoveJsonapiFormatCompilerPass; use Symfony\Component\DependencyInjection\Compiler\PassConfig; -use Symfony\Component\DependencyInjection\Reference; /** * Adds 'api_json' as known format and prevents its use in the REST module. @@ -21,17 +20,6 @@ class JsonapiServiceProvider implements ServiceModifierInterface, ServiceProvide * {@inheritdoc} */ public function alter(ContainerBuilder $container) { - // @todo Remove when we stop supporting Drupal 8.5. - if (floatval(\Drupal::VERSION) < 8.6) { - // Swap the cache service back. - $definition = $container->getDefinition('jsonapi.resource_type.repository'); - $definition->setArgument(3, new Reference('cache.static')); - $container->setDefinition('jsonapi.resource_type.repository', $definition); - - // Drop the new service definition. - $container->removeDefinition('cache.jsonapi_resource_types'); - } - if ($container->has('http_middleware.negotiation') && is_a($container->getDefinition('http_middleware.negotiation') ->getClass(), '\Drupal\Core\StackMiddleware\NegotiationMiddleware', TRUE) ) { diff --git a/tests/src/Functional/BlockContentTest.php b/tests/src/Functional/BlockContentTest.php index 9cd9ff0..3168383 100644 --- a/tests/src/Functional/BlockContentTest.php +++ b/tests/src/Functional/BlockContentTest.php @@ -86,7 +86,7 @@ class BlockContentTest extends ResourceTestBase { */ protected function getExpectedDocument() { $self_url = Url::fromUri('base:/jsonapi/block_content/basic/' . $this->entity->uuid())->setAbsolute()->toString(TRUE)->getGeneratedUrl(); - $expected_document = [ + return [ 'jsonapi' => [ 'meta' => [ 'links' => [ @@ -121,6 +121,7 @@ class BlockContentTest extends ResourceTestBase { 'default_langcode' => TRUE, 'drupal_internal__id' => 1, 'drupal_internal__revision_id' => 1, + 'reusable' => TRUE, ], 'relationships' => [ 'block_content_type' => [ @@ -143,10 +144,6 @@ class BlockContentTest extends ResourceTestBase { ], ], ]; - if (floatval(\Drupal::VERSION) >= 8.6) { - $expected_document['data']['attributes']['reusable'] = TRUE; - } - return $expected_document; } /** diff --git a/tests/src/Functional/BlockTest.php b/tests/src/Functional/BlockTest.php index 9f26396..452b5ef 100644 --- a/tests/src/Functional/BlockTest.php +++ b/tests/src/Functional/BlockTest.php @@ -156,7 +156,7 @@ class BlockTest extends ResourceTestBase { protected function getExpectedUnauthorizedAccessMessage($method) { switch ($method) { case 'GET': - return floatval(\Drupal::VERSION >= 8.7) ? "The block visibility condition 'user_role' denied access." : ''; + return "The block visibility condition 'user_role' denied access."; default: return parent::getExpectedUnauthorizedAccessMessage($method); diff --git a/tests/src/Functional/CommentTest.php b/tests/src/Functional/CommentTest.php index 626237d..7b551e7 100644 --- a/tests/src/Functional/CommentTest.php +++ b/tests/src/Functional/CommentTest.php @@ -275,10 +275,7 @@ class CommentTest extends ResourceTestBase { return "The 'post comments' permission is required."; case 'PATCH': - // @todo Make this unconditional when JSON:API requires Drupal 8.6 or newer. - if (floatval(\Drupal::VERSION) >= 8.6) { - return "The 'edit own comments' permission is required, the user must be the comment author, and the comment must be published."; - } + return "The 'edit own comments' permission is required, the user must be the comment author, and the comment must be published."; default: return parent::getExpectedUnauthorizedAccessMessage($method); @@ -315,12 +312,7 @@ class CommentTest extends ResourceTestBase { // DX: 422 when missing 'entity_type' field. $request_options[RequestOptions::BODY] = Json::encode($remove_field($this->getPostDocument(), 'attributes', 'entity_type')); $response = $this->request('POST', $url, $request_options); - if (floatval(\Drupal::VERSION) >= 8.7) { - $this->assertResourceErrorResponse(422, 'entity_type: This value should not be null.', NULL, $response, '/data/attributes/entity_type'); - } - else { - $this->assertResourceErrorResponse(500, 'The "" entity type does not exist.', $url, $response, FALSE); - } + $this->assertResourceErrorResponse(422, 'entity_type: This value should not be null.', NULL, $response, '/data/attributes/entity_type'); // DX: 422 when missing 'entity_id' field. $request_options[RequestOptions::BODY] = Json::encode($remove_field($this->getPostDocument(), 'relationships', 'entity_id')); @@ -336,12 +328,7 @@ class CommentTest extends ResourceTestBase { // DX: 422 when missing 'field_name' field. $request_options[RequestOptions::BODY] = Json::encode($remove_field($this->getPostDocument(), 'attributes', 'field_name')); $response = $this->request('POST', $url, $request_options); - if (floatval(\Drupal::VERSION) >= 8.7) { - $this->assertResourceErrorResponse(422, 'field_name: This value should not be null.', NULL, $response, '/data/attributes/field_name'); - } - else { - $this->assertSame(500, $response->getStatusCode()); - } + $this->assertResourceErrorResponse(422, 'field_name: This value should not be null.', NULL, $response, '/data/attributes/field_name'); } /** diff --git a/tests/src/Functional/ConfigTestTest.php b/tests/src/Functional/ConfigTestTest.php index df8da49..e6d873d 100644 --- a/tests/src/Functional/ConfigTestTest.php +++ b/tests/src/Functional/ConfigTestTest.php @@ -47,7 +47,7 @@ class ConfigTestTest extends ResourceTestBase { protected function getExpectedUnauthorizedAccessMessage($method) { switch ($method) { case 'GET': - return floatval(\Drupal::VERSION >= 8.7) ? "The 'view config_test' permission is required." : ''; + return "The 'view config_test' permission is required."; default: return parent::getExpectedUnauthorizedAccessMessage($method); diff --git a/tests/src/Functional/EntityTestMapFieldTest.php b/tests/src/Functional/EntityTestMapFieldTest.php index 38326eb..b78f96c 100644 --- a/tests/src/Functional/EntityTestMapFieldTest.php +++ b/tests/src/Functional/EntityTestMapFieldTest.php @@ -10,9 +10,6 @@ use Drupal\user\Entity\User; * JSON:API integration test for the "EntityTestMapField" content entity type. * * @group jsonapi - * @requires function Drupal\entity_test\Entity\EntityTestMapField::baseFieldDefinitions - * - * @todo Remove the "@requires" annotation when JSON:API requires Drupal >=8.6 */ class EntityTestMapFieldTest extends ResourceTestBase { diff --git a/tests/src/Functional/EntityViewDisplayTest.php b/tests/src/Functional/EntityViewDisplayTest.php index cd5fa95..1b154cc 100644 --- a/tests/src/Functional/EntityViewDisplayTest.php +++ b/tests/src/Functional/EntityViewDisplayTest.php @@ -70,7 +70,7 @@ class EntityViewDisplayTest extends ResourceTestBase { */ protected function getExpectedDocument() { $self_url = Url::fromUri('base:/jsonapi/entity_view_display/entity_view_display/' . $this->entity->uuid())->setAbsolute()->toString(TRUE)->getGeneratedUrl(); - $document = [ + return [ 'jsonapi' => [ 'meta' => [ 'links' => [ @@ -94,6 +94,8 @@ class EntityViewDisplayTest extends ResourceTestBase { 'links' => [ 'region' => 'content', 'weight' => 100, + 'settings' => [], + 'third_party_settings' => [], ], ], 'dependencies' => [ @@ -113,11 +115,6 @@ class EntityViewDisplayTest extends ResourceTestBase { ], ], ]; - if (floatval(\Drupal::VERSION) >= 8.6) { - $document['data']['attributes']['content']['links']['settings'] = []; - $document['data']['attributes']['content']['links']['third_party_settings'] = []; - } - return $document; } /** diff --git a/tests/src/Functional/FileTest.php b/tests/src/Functional/FileTest.php index 342cf78..ff67417 100644 --- a/tests/src/Functional/FileTest.php +++ b/tests/src/Functional/FileTest.php @@ -203,8 +203,7 @@ class FileTest extends ResourceTestBase { if ($method === 'GET') { return "The 'access content' permission is required."; } - // @todo Make this unconditional when JSON:API requires Drupal 8.6 or newer. - if (floatval(\Drupal::VERSION) >= 8.6 && ($method === 'PATCH' || $method === 'DELETE')) { + if ($method === 'PATCH' || $method === 'DELETE') { return "Only the file owner can update or delete the file entity."; } return parent::getExpectedUnauthorizedAccessMessage($method); diff --git a/tests/src/Functional/ImageStyleTest.php b/tests/src/Functional/ImageStyleTest.php index f6d7a36..55193d8 100644 --- a/tests/src/Functional/ImageStyleTest.php +++ b/tests/src/Functional/ImageStyleTest.php @@ -79,7 +79,7 @@ class ImageStyleTest extends ResourceTestBase { */ protected function getExpectedDocument() { $self_url = Url::fromUri('base:/jsonapi/image_style/image_style/' . $this->entity->uuid())->setAbsolute()->toString(TRUE)->getGeneratedUrl(); - $doc = [ + return [ 'jsonapi' => [ 'meta' => [ 'links' => [ @@ -118,10 +118,6 @@ class ImageStyleTest extends ResourceTestBase { ], ], ]; - if (floatval(\Drupal::VERSION) < 8.6) { - unset($doc['data']['attributes']['effects'][$this->effectUuid]['data']['anchor']); - } - return $doc; } /** diff --git a/tests/src/Functional/InternalEntitiesTest.php b/tests/src/Functional/InternalEntitiesTest.php index 1a0a85b..e170222 100644 --- a/tests/src/Functional/InternalEntitiesTest.php +++ b/tests/src/Functional/InternalEntitiesTest.php @@ -7,8 +7,8 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\entity_test\Entity\EntityTestBundle; use Drupal\entity_test\Entity\EntityTestNoLabel; use Drupal\entity_test\Entity\EntityTestWithBundle; -use Drupal\jsonapi\BackwardCompatibility\tests\Traits\EntityReferenceTestTrait; use Drupal\Tests\BrowserTestBase; +use Drupal\Tests\field\Traits\EntityReferenceTestTrait; /** * Makes assertions about the JSON:API behavior for internal entities. diff --git a/tests/src/Functional/JsonApiFunctionalTestBase.php b/tests/src/Functional/JsonApiFunctionalTestBase.php index dbad32e..87ab13e 100644 --- a/tests/src/Functional/JsonApiFunctionalTestBase.php +++ b/tests/src/Functional/JsonApiFunctionalTestBase.php @@ -7,10 +7,10 @@ use Drupal\Core\Url; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; use Drupal\file\Entity\File; -use Drupal\jsonapi\BackwardCompatibility\tests\Traits\EntityReferenceTestTrait; use Drupal\taxonomy\Entity\Term; use Drupal\taxonomy\Entity\Vocabulary; use Drupal\Tests\BrowserTestBase; +use Drupal\Tests\field\Traits\EntityReferenceTestTrait; use Drupal\Tests\image\Kernel\ImageFieldCreationTrait; use Drupal\user\Entity\Role; use Drupal\user\RoleInterface; diff --git a/tests/src/Functional/MediaTest.php b/tests/src/Functional/MediaTest.php index 9bfb022..e812afe 100644 --- a/tests/src/Functional/MediaTest.php +++ b/tests/src/Functional/MediaTest.php @@ -137,7 +137,7 @@ class MediaTest extends ResourceTestBase { $thumbnail = File::load(3); $author = User::load($this->entity->getOwnerId()); $self_url = Url::fromUri('base:/jsonapi/media/camelids/' . $this->entity->uuid())->setAbsolute()->toString(TRUE)->getGeneratedUrl(); - $data = [ + return [ 'jsonapi' => [ 'meta' => [ 'links' => [ @@ -235,12 +235,6 @@ class MediaTest extends ResourceTestBase { ], ], ]; - // @todo Make this unconditional when JSON:API requires Drupal 8.6 or newer. - if (floatval(\Drupal::VERSION) < 8.6) { - $data['data']['relationships']['thumbnail']['data']['meta']['alt'] = 'Thumbnail'; - $data['data']['relationships']['thumbnail']['data']['meta']['title'] = 'Llama'; - } - return $data; } /** @@ -282,16 +276,10 @@ class MediaTest extends ResourceTestBase { return "The following permissions are required: 'administer media' OR 'create media' OR 'create camelids media'."; case 'PATCH': - // @todo Make this unconditional when JSON:API requires Drupal 8.6 or newer. - if (floatval(\Drupal::VERSION) >= 8.6) { - return "The following permissions are required: 'update any media' OR 'update own media' OR 'camelids: edit any media' OR 'camelids: edit own media'."; - } + return "The following permissions are required: 'update any media' OR 'update own media' OR 'camelids: edit any media' OR 'camelids: edit own media'."; case 'DELETE': - // @todo Make this unconditional when JSON:API requires Drupal 8.6 or newer. - if (floatval(\Drupal::VERSION) >= 8.6) { - return "The following permissions are required: 'delete any media' OR 'delete own media' OR 'camelids: delete any media' OR 'camelids: delete own media'."; - } + return "The following permissions are required: 'delete any media' OR 'delete own media' OR 'camelids: delete any media' OR 'camelids: delete own media'."; default: return ''; @@ -333,11 +321,6 @@ class MediaTest extends ResourceTestBase { 'height' => 180, 'title' => NULL, ]; - // @todo Make this unconditional when JSON:API requires Drupal 8.6 or newer. - if (floatval(\Drupal::VERSION) < 8.6) { - $data['meta']['alt'] = 'Thumbnail'; - $data['meta']['title'] = 'Llama'; - } return $data; case 'field_media_file': diff --git a/tests/src/Functional/MenuLinkContentTest.php b/tests/src/Functional/MenuLinkContentTest.php index c60d162..2e6b04c 100644 --- a/tests/src/Functional/MenuLinkContentTest.php +++ b/tests/src/Functional/MenuLinkContentTest.php @@ -139,7 +139,7 @@ class MenuLinkContentTest extends ResourceTestBase { protected function getExpectedUnauthorizedAccessMessage($method) { switch ($method) { case 'DELETE': - return floatval(\Drupal::VERSION >= 8.7) ? "The 'administer menu' permission is required." : ''; + return "The 'administer menu' permission is required."; default: return parent::getExpectedUnauthorizedAccessMessage($method); diff --git a/tests/src/Functional/ResourceTestBase.php b/tests/src/Functional/ResourceTestBase.php index dc137b5..befe6e2 100644 --- a/tests/src/Functional/ResourceTestBase.php +++ b/tests/src/Functional/ResourceTestBase.php @@ -1781,10 +1781,6 @@ abstract class ResourceTestBase extends BrowserTestBase { $detail = 'The current user is not allowed to view this relationship.'; if (!$entity->access('view') && $entity->access('view label') && $access instanceof AccessResultReasonInterface && empty($access->getReason())) { $access->setReason("The user only has authorization for the 'view label' operation."); - // @todo Remove when we stop supporting Drupal 8.5. - if (floatval(\Drupal::VERSION) < 8.6 && $relationship_field_name === 'roles' && static::$entityTypeId === 'user' && $access->getCacheContexts() === ['user.permissions']) { - $access = $access->setReason(''); - } } $via_link = Url::fromRoute( sprintf('jsonapi.%s.%s.related', $base_resource_identifier['type'], $relationship_field_name), @@ -2170,9 +2166,6 @@ abstract class ResourceTestBase extends BrowserTestBase { ], ], ]; - if (floatval(\Drupal::VERSION) < 8.6) { - $expected_document['errors'][0]['detail'] = "The current user is not allowed to PATCH the selected field ($id_field_name). The entity ID cannot be changed"; - } $this->assertResourceResponse(403, $expected_document, $response); /* $this->assertResourceErrorResponse(403, "The current user is not allowed to PATCH the selected field ($id_field_name). The entity ID cannot be changed", $response, "/data/attributes/$id_field_name"); */ diff --git a/tests/src/Functional/ShortcutSetTest.php b/tests/src/Functional/ShortcutSetTest.php index 2eea948..0ab41a3 100644 --- a/tests/src/Functional/ShortcutSetTest.php +++ b/tests/src/Functional/ShortcutSetTest.php @@ -60,7 +60,7 @@ class ShortcutSetTest extends ResourceTestBase { protected function getExpectedUnauthorizedAccessMessage($method) { switch ($method) { case 'GET': - return floatval(\Drupal::VERSION >= 8.7) ? "The 'access shortcuts' permission is required." : ''; + return "The 'access shortcuts' permission is required."; default: return parent::getExpectedUnauthorizedAccessMessage($method); diff --git a/tests/src/Functional/TermTest.php b/tests/src/Functional/TermTest.php index bffa1f6..cce7732 100644 --- a/tests/src/Functional/TermTest.php +++ b/tests/src/Functional/TermTest.php @@ -210,18 +210,7 @@ class TermTest extends ResourceTestBase { break; } - // @todo Remove this when JSON:API requires Drupal 8.6 or newer. - if (floatval(\Drupal::VERSION) < 8.6) { - $expected_parent_normalization = [ - 'data' => [], - 'links' => [ - 'related' => ['href' => $self_url . '/parent'], - 'self' => ['href' => $self_url . '/relationships/parent'], - ], - ]; - } - - $expected_document = [ + return [ 'jsonapi' => [ 'meta' => [ 'links' => [ @@ -256,6 +245,7 @@ class TermTest extends ResourceTestBase { ], 'weight' => 0, 'drupal_internal__tid' => 1, + 'status' => TRUE, ], 'relationships' => [ 'parent' => $expected_parent_normalization, @@ -272,12 +262,6 @@ class TermTest extends ResourceTestBase { ], ], ]; - - if (floatval(\Drupal::VERSION) >= 8.6) { - $expected_document['data']['attributes']['status'] = TRUE; - } - - return $expected_document; } /** @@ -285,7 +269,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' && floatval(\Drupal::VERSION) >= 8.6) { + if ($relationship_field_name === 'parent') { $data = [ 0 => [ 'id' => 'virtual', @@ -311,7 +295,7 @@ class TermTest extends ResourceTestBase { */ 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) { + if ($responses['parent']->getStatusCode() === 404) { $responses['parent'] = new ResourceResponse([ 'data' => [], 'jsonapi' => [ @@ -356,9 +340,7 @@ class TermTest extends ResourceTestBase { protected function getExpectedUnauthorizedAccessMessage($method) { switch ($method) { case 'GET': - return floatval(\Drupal::VERSION) >= 8.6 - ? "The 'access content' permission is required and the taxonomy term must be published." - : "The 'access content' permission is required."; + return "The 'access content' permission is required and the taxonomy term must be published."; case 'POST': return "The following permissions are required: 'create terms in camelids' OR 'administer taxonomy'."; @@ -379,9 +361,7 @@ class TermTest extends ResourceTestBase { */ protected function getExpectedUnauthorizedAccessCacheability() { $cacheability = parent::getExpectedUnauthorizedAccessCacheability(); - if (floatval(\Drupal::VERSION) >= 8.6) { - $cacheability->addCacheableDependency($this->entity); - } + $cacheability->addCacheableDependency($this->entity); return $cacheability; } @@ -452,11 +432,6 @@ class TermTest extends ResourceTestBase { * @dataProvider providerTestGetIndividualTermWithParent */ public function testGetIndividualTermWithParent(array $parent_term_ids) { - if (floatval(\Drupal::VERSION) < 8.6) { - $this->markTestSkipped('The "parent" field on terms is only available for normalization in Drupal 8.6 and later.'); - return; - } - // Create all possible parent terms. Term::create(['vid' => Vocabulary::load('camelids')->id()]) ->setName('Lamoids') @@ -503,12 +478,7 @@ class TermTest extends ResourceTestBase { * {@inheritdoc} */ public function testCollectionFilterAccess() { - if (floatval(\Drupal::VERSION) >= 8.6) { - $this->doTestCollectionFilterAccessForPublishableEntities('name', 'access content', 'administer taxonomy'); - } - else { - $this->doTestCollectionFilterAccessBasedOnPermissions('name', 'access content'); - } + $this->doTestCollectionFilterAccessBasedOnPermissions('name', 'access content'); } } diff --git a/tests/src/Functional/UserTest.php b/tests/src/Functional/UserTest.php index a7f2529..926c314 100644 --- a/tests/src/Functional/UserTest.php +++ b/tests/src/Functional/UserTest.php @@ -172,10 +172,10 @@ class UserTest extends ResourceTestBase { return "The 'access user profiles' permission is required and the user must be active."; case 'PATCH': - return floatval(\Drupal::VERSION >= 8.7) ? "Users can only update their own account, unless they have the 'administer users' permission." : ''; + return "Users can only update their own account, unless they have the 'administer users' permission."; case 'DELETE': - return floatval(\Drupal::VERSION >= 8.7) ? "The 'cancel account' permission is required." : ''; + return "The 'cancel account' permission is required."; default: return parent::getExpectedUnauthorizedAccessMessage($method); diff --git a/tests/src/Functional/VocabularyTest.php b/tests/src/Functional/VocabularyTest.php index 4ce1fe3..61ecdc8 100644 --- a/tests/src/Functional/VocabularyTest.php +++ b/tests/src/Functional/VocabularyTest.php @@ -59,7 +59,7 @@ class VocabularyTest extends ResourceTestBase { */ protected function getExpectedDocument() { $self_url = Url::fromUri('base:/jsonapi/taxonomy_vocabulary/taxonomy_vocabulary/' . $this->entity->uuid())->setAbsolute()->toString(TRUE)->getGeneratedUrl(); - $expected_document = [ + return [ 'jsonapi' => [ 'meta' => [ 'links' => [ @@ -88,10 +88,6 @@ class VocabularyTest extends ResourceTestBase { ], ], ]; - if (floatval(\Drupal::VERSION) < 8.7) { - $expected_document['data']['attributes']['hierarchy'] = 0; - } - return $expected_document; } /** diff --git a/tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php b/tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php index ff368a3..aa6d3f1 100644 --- a/tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php +++ b/tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php @@ -291,7 +291,7 @@ class JsonApiDocumentTopLevelNormalizerTest extends JsonapiKernelTestBase { $this->assertSame($this->term1->uuid(), $normalized['included'][1]['id']); $this->assertSame('taxonomy_term--tags', $normalized['included'][1]['type']); $this->assertSame($this->term1->label(), $normalized['included'][1]['attributes']['name']); - $this->assertCount(floatval(\Drupal::VERSION) >= 8.6 ? 8 : 7, $normalized['included'][1]['attributes']); + $this->assertCount(8, $normalized['included'][1]['attributes']); $this->assertTrue(!isset($normalized['included'][1]['attributes']['created'])); // Make sure that the cache tags for the includes and the requested entities // are bubbling as expected. @@ -381,7 +381,7 @@ class JsonApiDocumentTopLevelNormalizerTest extends JsonapiKernelTestBase { $this->assertTrue(empty($normalized['meta']['omitted'])); $this->assertEquals($this->user->uuid(), $normalized['included'][0]['id']); $this->assertCount(1, $normalized['included'][0]['attributes']); - $this->assertCount(floatval(\Drupal::VERSION) >= 8.6 ? 8 : 7, $normalized['included'][1]['attributes']); + $this->assertCount(8, $normalized['included'][1]['attributes']); // Make sure that the cache tags for the includes and the requested entities // are bubbling as expected. $this->assertArraySubset(