From 8c2f0ded3aacc124b266e7938fe5b888916e4316 Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Tue, 4 Feb 2020 16:33:47 +0000 Subject: [PATCH] Issue #3034062 by Berdir, Wim Leers, sokru, Stefdewa, jibran: Remove hal.module BC layers --- .../Functional/Hal/FileHalJsonAnonTest.php | 36 ----------------- .../hal/config/install/hal.settings.yml | 8 ---- core/modules/hal/config/schema/hal.schema.yml | 3 -- core/modules/hal/hal.post_update.php | 16 ++++++++ core/modules/hal/hal.services.yml | 2 +- .../src/LinkManager/RelationLinkManager.php | 9 ----- .../RelationLinkManagerInterface.php | 4 +- .../hal/src/LinkManager/TypeLinkManager.php | 1 - .../src/Normalizer/FileEntityNormalizer.php | 19 --------- .../hal/src/Normalizer/NormalizerBase.php | 13 ------ .../tests/modules/hal_test/hal_test.module | 26 ------------ .../Comment/CommentHalJsonTestBase.php | 16 -------- .../Feed/FeedHalJsonTestBase.php | 16 -------- .../File/FileUploadHalJsonTestBase.php | 16 -------- .../Item/ItemHalJsonTestBase.php | 16 -------- .../Update/HalSettingsDeletionUpdateTest.php | 40 +++++++++++++++++++ .../tests/src/Kernel/HalLinkManagerTest.php | 36 ++--------------- .../Functional/Hal/MediaHalJsonAnonTest.php | 8 ---- 18 files changed, 62 insertions(+), 223 deletions(-) create mode 100644 core/modules/hal/hal.post_update.php delete mode 100644 core/modules/hal/tests/src/Functional/EntityResource/Comment/CommentHalJsonTestBase.php delete mode 100644 core/modules/hal/tests/src/Functional/EntityResource/Feed/FeedHalJsonTestBase.php delete mode 100644 core/modules/hal/tests/src/Functional/EntityResource/File/FileUploadHalJsonTestBase.php delete mode 100644 core/modules/hal/tests/src/Functional/EntityResource/Item/ItemHalJsonTestBase.php create mode 100644 core/modules/hal/tests/src/Functional/Update/HalSettingsDeletionUpdateTest.php diff --git a/core/modules/file/tests/src/Functional/Hal/FileHalJsonAnonTest.php b/core/modules/file/tests/src/Functional/Hal/FileHalJsonAnonTest.php index f90b57ecbe5b..bf24dadd9d2f 100644 --- a/core/modules/file/tests/src/Functional/Hal/FileHalJsonAnonTest.php +++ b/core/modules/file/tests/src/Functional/Hal/FileHalJsonAnonTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\file\Functional\Hal; -use Drupal\Core\Cache\Cache; use Drupal\Tests\file\Functional\Rest\FileResourceTestBase; use Drupal\Tests\hal\Functional\EntityResource\HalEntityNormalizationTrait; use Drupal\Tests\rest\Functional\AnonResourceTestTrait; @@ -44,7 +43,6 @@ protected function getExpectedNormalizedEntity() { $normalization = $this->applyHalFieldNormalization($default_normalization); $url = file_create_url($this->entity->getFileUri()); - // @see \Drupal\Tests\hal\Functional\EntityResource\File\FileHalJsonAnonTest::testGetBcUriField() if ($this->config('hal.settings')->get('bc_file_uri_as_url_normalizer')) { $normalization['uri'][0]['value'] = $url; } @@ -100,13 +98,6 @@ protected function getNormalizedPostEntity() { ]; } - /** - * {@inheritdoc} - */ - protected function getExpectedCacheTags() { - return Cache::mergeTags(parent::getExpectedCacheTags(), ['config:hal.settings']); - } - /** * {@inheritdoc} */ @@ -117,31 +108,4 @@ protected function getExpectedCacheContexts() { ]; } - /** - * @see hal_update_8501() - * - * @group legacy - * @expectedDeprecation Replacing the file uri with the URL is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use the provided url property instead and disable hal.settings:bc_file_uri_as_url_normalizer. See https://www.drupal.org/node/2925783 - */ - public function testGetBcUriField() { - $this->config('hal.settings')->set('bc_file_uri_as_url_normalizer', TRUE)->save(TRUE); - - $this->initAuthentication(); - $url = $this->getEntityResourceUrl(); - $url->setOption('query', ['_format' => static::$format]); - $request_options = $this->getAuthenticationRequestOptions('GET'); - $this->provisionEntityResource(); - $this->setUpAuthorization('GET'); - $response = $this->request('GET', $url, $request_options); - $expected = $this->getExpectedNormalizedEntity(); - static::recursiveKSort($expected); - $actual = $this->serializer->decode((string) $response->getBody(), static::$format); - static::recursiveKSort($actual); - $this->assertSame($expected, $actual); - - // Explicitly assert that $file->uri->value is an absolute file URL, unlike - // the default normalization. - $this->assertSame($this->baseUrl . '/' . $this->siteDirectory . '/files/drupal.txt', $actual['uri'][0]['value']); - } - } diff --git a/core/modules/hal/config/install/hal.settings.yml b/core/modules/hal/config/install/hal.settings.yml index c62cb6a04819..67107af00d34 100644 --- a/core/modules/hal/config/install/hal.settings.yml +++ b/core/modules/hal/config/install/hal.settings.yml @@ -1,11 +1,3 @@ # Set the domain for HAL type and relation links. # If left blank, the site's domain will be used. link_domain: ~ -# Before Drupal 8.5, the File entity 'uri' field value was overridden to return -# the absolute file URL instead of the actual (stream wrapper) URI. The default -# for new sites is now to return the actual URI as well as a root-relative file -# URL. Enable this setting to use the previous behavior. For existing sites, -# the previous behavior is kept by default. -# @see hal_update_8501() -# @see https://www.drupal.org/node/2925783 -bc_file_uri_as_url_normalizer: false diff --git a/core/modules/hal/config/schema/hal.schema.yml b/core/modules/hal/config/schema/hal.schema.yml index cad1bdb722b8..3192d6758052 100644 --- a/core/modules/hal/config/schema/hal.schema.yml +++ b/core/modules/hal/config/schema/hal.schema.yml @@ -6,6 +6,3 @@ hal.settings: link_domain: type: string label: 'Domain of the relation' - bc_file_uri_as_url_normalizer: - type: boolean - label: 'Whether to retain pre Drupal 8.5 behavior of normalizing the File entity "uri" field value to an absolute URL.' diff --git a/core/modules/hal/hal.post_update.php b/core/modules/hal/hal.post_update.php new file mode 100644 index 000000000000..0832512d5349 --- /dev/null +++ b/core/modules/hal/hal.post_update.php @@ -0,0 +1,16 @@ +<?php + +/** + * @file + * Post update functions for Hal. + */ + +/** + * Remove obsolete hal.settings configuration key. + */ +function hal_post_update_delete_settings() { + \Drupal::configFactory() + ->getEditable('hal.settings') + ->clear('bc_file_uri_as_url_normalizer') + ->save(); +} diff --git a/core/modules/hal/hal.services.yml b/core/modules/hal/hal.services.yml index 34aaf6581c0a..38ffb226127f 100644 --- a/core/modules/hal/hal.services.yml +++ b/core/modules/hal/hal.services.yml @@ -21,7 +21,7 @@ services: class: Drupal\hal\Normalizer\TimestampItemNormalizer tags: # Priority must be higher than serializer.normalizer.field_item.hal. - - { name: normalizer, priority: 20, bc: bc_timestamp_normalizer_unix, bc_config_name: 'serialization.settings' } + - { name: normalizer, priority: 20 } serializer.normalizer.entity.hal: class: Drupal\hal\Normalizer\ContentEntityNormalizer arguments: ['@hal.link_manager', '@entity_type.manager', '@module_handler', '@entity_type.repository', '@entity_field.manager'] diff --git a/core/modules/hal/src/LinkManager/RelationLinkManager.php b/core/modules/hal/src/LinkManager/RelationLinkManager.php index 97b78de504f7..e56b20de6fad 100644 --- a/core/modules/hal/src/LinkManager/RelationLinkManager.php +++ b/core/modules/hal/src/LinkManager/RelationLinkManager.php @@ -92,7 +92,6 @@ public function getRelationUri($entity_type, $bundle, $field_name, $context = [] // override the RelationLinkManager class/service to return the desired URL. $uri = $this->getLinkDomain($context) . "/rest/relation/$entity_type/$bundle/$field_name"; $this->moduleHandler->alter('hal_relation_uri', $uri, $context); - $this->moduleHandler->alterDeprecated('This hook is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. Implement hook_hal_relation_uri_alter() instead.', 'rest_relation_uri', $uri, $context); return $uri; } @@ -125,11 +124,7 @@ public function getRelationInternalIds($relation_uri, $context = []) { * - 'entity_type_id' * - 'bundle' * - 'field_name' - * - 'entity_type' (deprecated) * The values for 'entity_type_id', 'bundle' and 'field_name' are strings. - * The 'entity_type' key exists for backwards compatibility and its value is - * the full entity type object. The 'entity_type' key will be removed before - * Drupal 9.0. * * @see https://www.drupal.org/node/2877608 */ @@ -143,10 +138,6 @@ protected function getRelations($context = []) { $data = $cache->data; } - // @todo https://www.drupal.org/node/2716163 Remove this in Drupal 9.0. - foreach ($data as $relation_uri => $ids) { - $data[$relation_uri]['entity_type'] = $this->entityTypeManager->getDefinition($ids['entity_type_id']); - } return $data; } diff --git a/core/modules/hal/src/LinkManager/RelationLinkManagerInterface.php b/core/modules/hal/src/LinkManager/RelationLinkManagerInterface.php index 8ba8c949e816..7d84894326a3 100644 --- a/core/modules/hal/src/LinkManager/RelationLinkManagerInterface.php +++ b/core/modules/hal/src/LinkManager/RelationLinkManagerInterface.php @@ -32,9 +32,7 @@ public function getRelationUri($entity_type, $bundle, $field_name, $context = [] * Relation URI (or IANA link relation type) to transform into internal IDs. * * @return array - * Array with keys 'entity_type_id', 'bundle' and 'field_name'. For - * backwards compatibility, the entity_type key returns the full entity type - * object, this will be removed before Drupal 9.0. + * Array with keys 'entity_type_id', 'bundle' and 'field_name'. */ public function getRelationInternalIds($relation_uri); diff --git a/core/modules/hal/src/LinkManager/TypeLinkManager.php b/core/modules/hal/src/LinkManager/TypeLinkManager.php index 4cb4908acb27..4996f8099ac8 100644 --- a/core/modules/hal/src/LinkManager/TypeLinkManager.php +++ b/core/modules/hal/src/LinkManager/TypeLinkManager.php @@ -83,7 +83,6 @@ public function getTypeUri($entity_type, $bundle, $context = []) { // TypeLinkManager class/service to return the desired URL. $uri = $this->getLinkDomain($context) . "/rest/type/$entity_type/$bundle"; $this->moduleHandler->alter('hal_type_uri', $uri, $context); - $this->moduleHandler->alterDeprecated('This hook is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. Implement hook_hal_type_uri_alter() instead.', 'rest_type_uri', $uri, $context); return $uri; } diff --git a/core/modules/hal/src/Normalizer/FileEntityNormalizer.php b/core/modules/hal/src/Normalizer/FileEntityNormalizer.php index 94e1e0bc8130..249077085784 100644 --- a/core/modules/hal/src/Normalizer/FileEntityNormalizer.php +++ b/core/modules/hal/src/Normalizer/FileEntityNormalizer.php @@ -59,25 +59,6 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Lin $this->halSettings = $config_factory->get('hal.settings'); } - /** - * {@inheritdoc} - * - * @deprecated in drupal:8.5.0 and is removed from drupal:9.0.0. - */ - public function normalize($entity, $format = NULL, array $context = []) { - $data = parent::normalize($entity, $format, $context); - - $this->addCacheableDependency($context, $this->halSettings); - - if ($this->halSettings->get('bc_file_uri_as_url_normalizer')) { - // Replace the file url with a full url for the file. - $data['uri'][0]['value'] = $this->getEntityUri($entity); - @trigger_error("Replacing the file uri with the URL is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use the provided url property instead and disable hal.settings:bc_file_uri_as_url_normalizer. See https://www.drupal.org/node/2925783", E_USER_DEPRECATED); - } - - return $data; - } - /** * {@inheritdoc} */ diff --git a/core/modules/hal/src/Normalizer/NormalizerBase.php b/core/modules/hal/src/Normalizer/NormalizerBase.php index 8b18985b8b46..7449edfde4a9 100644 --- a/core/modules/hal/src/Normalizer/NormalizerBase.php +++ b/core/modules/hal/src/Normalizer/NormalizerBase.php @@ -15,17 +15,4 @@ abstract class NormalizerBase extends SerializationNormalizerBase implements Den */ protected $format = ['hal_json']; - /** - * {@inheritdoc} - */ - protected function checkFormat($format = NULL) { - if (isset($this->formats)) { - @trigger_error('::formats is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Use ::$format instead. See https://www.drupal.org/node/2868275', E_USER_DEPRECATED); - - $this->format = $this->formats; - } - - return parent::checkFormat($format); - } - } diff --git a/core/modules/hal/tests/modules/hal_test/hal_test.module b/core/modules/hal/tests/modules/hal_test/hal_test.module index 823634587158..da71ffbd947b 100644 --- a/core/modules/hal/tests/modules/hal_test/hal_test.module +++ b/core/modules/hal/tests/modules/hal_test/hal_test.module @@ -22,29 +22,3 @@ function hal_test_hal_relation_uri_alter(&$uri, $context = []) { $uri = 'hal_test_relation'; } } - -/** - * Implements hook_rest_type_uri_alter(). - * - * @deprecated Kept only for BC test coverage, see \Drupal\Tests\hal\Kernel\HalLinkManagerTest::testGetTypeUri(). - * - * @see https://www.drupal.org/node/2830467 - */ -function hal_test_rest_type_uri_alter(&$uri, $context = []) { - if (!empty($context['rest_test'])) { - $uri = 'rest_test_type'; - } -} - -/** - * Implements hook_rest_relation_uri_alter(). - * - * @deprecated Kept only for BC test coverage, see \Drupal\Tests\hal\Kernel\HalLinkManagerTest::testGetRelationUri(). - * - * @see https://www.drupal.org/node/2830467 - */ -function hal_test_rest_relation_uri_alter(&$uri, $context = []) { - if (!empty($context['rest_test'])) { - $uri = 'rest_test_relation'; - } -} diff --git a/core/modules/hal/tests/src/Functional/EntityResource/Comment/CommentHalJsonTestBase.php b/core/modules/hal/tests/src/Functional/EntityResource/Comment/CommentHalJsonTestBase.php deleted file mode 100644 index d647a8296103..000000000000 --- a/core/modules/hal/tests/src/Functional/EntityResource/Comment/CommentHalJsonTestBase.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php - -namespace Drupal\Tests\hal\Functional\EntityResource\Comment; - -@trigger_error('The ' . __NAMESPACE__ . '\CommentHalJsonTestBase is deprecated in Drupal 8.6.x and will be removed before Drupal 9.0.0. Instead, use Drupal\Tests\comment\Functional\Hal\CommentHalJsonTestBase. See https://www.drupal.org/node/2971931.', E_USER_DEPRECATED); - -use Drupal\Tests\comment\Functional\Hal\CommentHalJsonTestBase as CommentHalJsonTestBaseReal; - -/** - * @deprecated in drupal:8.6.0 and is removed from drupal:9.0.0. Use - * Drupal\Tests\comment\Functional\Hal\CommentHalJsonTestBase instead. - * - * @see https://www.drupal.org/node/2971931 - */ -abstract class CommentHalJsonTestBase extends CommentHalJsonTestBaseReal { -} diff --git a/core/modules/hal/tests/src/Functional/EntityResource/Feed/FeedHalJsonTestBase.php b/core/modules/hal/tests/src/Functional/EntityResource/Feed/FeedHalJsonTestBase.php deleted file mode 100644 index 0bf1173c9099..000000000000 --- a/core/modules/hal/tests/src/Functional/EntityResource/Feed/FeedHalJsonTestBase.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php - -namespace Drupal\Tests\hal\Functional\EntityResource\Feed; - -@trigger_error('The ' . __NAMESPACE__ . '\FeedHalJsonTestBase is deprecated in Drupal 8.6.x and will be removed before Drupal 9.0.0. Instead, use Drupal\Tests\aggregator\Functional\Hal\FeedHalJsonTestBase. See https://www.drupal.org/node/2971931.', E_USER_DEPRECATED); - -use Drupal\Tests\aggregator\Functional\Hal\FeedHalJsonTestBase as FeedHalJsonTestBaseReal; - -/** - * @deprecated in drupal:8.6.0 and is removed from drupal:9.0.0. Use - * Drupal\Tests\aggregator\Functional\Hal\FeedHalJsonTestBase instead. - * - * @see https://www.drupal.org/node/2971931 - */ -abstract class FeedHalJsonTestBase extends FeedHalJsonTestBaseReal { -} diff --git a/core/modules/hal/tests/src/Functional/EntityResource/File/FileUploadHalJsonTestBase.php b/core/modules/hal/tests/src/Functional/EntityResource/File/FileUploadHalJsonTestBase.php deleted file mode 100644 index 8d61811d7bec..000000000000 --- a/core/modules/hal/tests/src/Functional/EntityResource/File/FileUploadHalJsonTestBase.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php - -namespace Drupal\Tests\hal\Functional\EntityResource\File; - -@trigger_error('The ' . __NAMESPACE__ . '\FileUploadHalJsonTestBase is deprecated in Drupal 8.6.x and will be removed before Drupal 9.0.0. Instead, use Drupal\Tests\file\Functional\Hal\FileUploadHalJsonTestBase. See https://www.drupal.org/node/2971931.', E_USER_DEPRECATED); - -use Drupal\Tests\file\Functional\Hal\FileUploadHalJsonTestBase as FileUploadHalJsonTestBaseReal; - -/** - * @deprecated in drupal:8.6.0 and is removed from drupal:9.0.0. Use - * Drupal\Tests\file\Functional\Hal\FileUploadHalJsonTestBase instead. - * - * @see https://www.drupal.org/node/2971931 - */ -abstract class FileUploadHalJsonTestBase extends FileUploadHalJsonTestBaseReal { -} diff --git a/core/modules/hal/tests/src/Functional/EntityResource/Item/ItemHalJsonTestBase.php b/core/modules/hal/tests/src/Functional/EntityResource/Item/ItemHalJsonTestBase.php deleted file mode 100644 index f7f3548788a7..000000000000 --- a/core/modules/hal/tests/src/Functional/EntityResource/Item/ItemHalJsonTestBase.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php - -namespace Drupal\Tests\hal\Functional\EntityResource\Item; - -@trigger_error('The ' . __NAMESPACE__ . '\ItemHalJsonTestBase is deprecated in Drupal 8.6.x and will be removed before Drupal 9.0.0. Instead, use Drupal\Tests\aggregator\Functional\Hal\ItemHalJsonTestBase. See https://www.drupal.org/node/2971931.', E_USER_DEPRECATED); - -use Drupal\Tests\aggregator\Functional\Hal\ItemHalJsonTestBase as ItemHalJsonTestBaseReal; - -/** - * @deprecated in drupal:8.6.0 and is removed from drupal:9.0.0. Use - * Drupal\Tests\aggregator\Functional\Hal\ItemHalJsonTestBase instead. - * - * @see https://www.drupal.org/node/2971931 - */ -abstract class ItemHalJsonTestBase extends ItemHalJsonTestBaseReal { -} diff --git a/core/modules/hal/tests/src/Functional/Update/HalSettingsDeletionUpdateTest.php b/core/modules/hal/tests/src/Functional/Update/HalSettingsDeletionUpdateTest.php new file mode 100644 index 000000000000..61cef95d00c5 --- /dev/null +++ b/core/modules/hal/tests/src/Functional/Update/HalSettingsDeletionUpdateTest.php @@ -0,0 +1,40 @@ +<?php + +namespace Drupal\Tests\hal\Functional\Update; + +use Drupal\FunctionalTests\Update\UpdatePathTestBase; + +/** + * Ensures that update hook is run properly for deleting obsolete Hal settings. + * + * @group hal + * @group legacy + */ +class HalSettingsDeletionUpdateTest extends UpdatePathTestBase { + + /** + * {@inheritdoc} + */ + protected function setDatabaseDumpFiles() { + $this->databaseDumpFiles = [ + __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.8.0.filled.standard.php.gz', + ]; + } + + /** + * Ensures that update hook is run for "hal" module. + */ + public function testUpdate() { + + $hal_settings = $this->config('hal.settings'); + $this->assertFalse($hal_settings->isNew()); + $this->assertTrue($hal_settings->get('bc_file_uri_as_url_normalizer')); + + $this->runUpdates(); + + $hal_settings = \Drupal::configFactory()->get('hal.settings'); + $this->assertFalse($hal_settings->isNew()); + $this->assertNull($hal_settings->get('bc_file_uri_as_url_normalizer')); + } + +} diff --git a/core/modules/hal/tests/src/Kernel/HalLinkManagerTest.php b/core/modules/hal/tests/src/Kernel/HalLinkManagerTest.php index 05a6b39f1ee7..33366eca27c5 100644 --- a/core/modules/hal/tests/src/Kernel/HalLinkManagerTest.php +++ b/core/modules/hal/tests/src/Kernel/HalLinkManagerTest.php @@ -13,7 +13,6 @@ /** * @coversDefaultClass \Drupal\hal\LinkManager\LinkManager * @group hal - * @group legacy */ class HalLinkManagerTest extends KernelTestBase { @@ -50,7 +49,6 @@ protected function setUp() { /** * @covers ::getTypeUri * @dataProvider providerTestGetTypeUri - * @expectedDeprecation The deprecated alter hook hook_rest_type_uri_alter() is implemented in these functions: hal_test_rest_type_uri_alter. This hook is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. Implement hook_hal_type_uri_alter() instead. */ public function testGetTypeUri($link_domain, $entity_type, $bundle, array $context, $expected_return, array $expected_context) { $hal_settings = \Drupal::configFactory()->getEditable('hal.settings'); @@ -62,7 +60,7 @@ public function testGetTypeUri($link_domain, $entity_type, $bundle, array $conte $hal_settings->set('link_domain', $link_domain)->save(TRUE); } - /* @var \Drupal\rest\LinkManager\TypeLinkManagerInterface $type_manager */ + /* @var \Drupal\hal\LinkManager\TypeLinkManagerInterface $type_manager */ $type_manager = \Drupal::service('hal.link_manager.type'); $link = $type_manager->getTypeUri($entity_type, $bundle, $context); @@ -108,18 +106,6 @@ public function providerTestGetTypeUri() { // No cacheability metadata bubbled. 'expected context' => ['hal_test' => TRUE] + $serialization_context_collecting_cacheability, ], - // Test hook_rest_type_uri_alter() — for backwards compatibility. - 'site URL, with optional context, to test hook_rest_type_uri_alter()' => $base_test_case + [ - 'context' => ['rest_test' => TRUE], - 'expected return' => 'rest_test_type', - 'expected context' => ['rest_test' => TRUE], - ], - 'site URL, with optional context, to test hook_rest_type_uri_alter(), and collecting cacheability metadata' => $base_test_case + [ - 'context' => ['rest_test' => TRUE] + $serialization_context_collecting_cacheability, - 'expected return' => 'rest_test_type', - // No cacheability metadata bubbled. - 'expected context' => ['rest_test' => TRUE] + $serialization_context_collecting_cacheability, - ], 'configured URL' => [ 'link_domain' => 'http://llamas-rock.com/for-real/', 'entity_type' => 'node', @@ -144,7 +130,6 @@ public function providerTestGetTypeUri() { /** * @covers ::getRelationUri * @dataProvider providerTestGetRelationUri - * @expectedDeprecation The deprecated alter hook hook_rest_relation_uri_alter() is implemented in these functions: hal_test_rest_relation_uri_alter. This hook is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. Implement hook_hal_relation_uri_alter() instead. */ public function testGetRelationUri($link_domain, $entity_type, $bundle, $field_name, array $context, $expected_return, array $expected_context) { $hal_settings = \Drupal::configFactory()->getEditable('hal.settings'); @@ -156,7 +141,7 @@ public function testGetRelationUri($link_domain, $entity_type, $bundle, $field_n $hal_settings->set('link_domain', $link_domain)->save(TRUE); } - /* @var \Drupal\rest\LinkManager\RelationLinkManagerInterface $relation_manager */ + /* @var \Drupal\hal\LinkManager\RelationLinkManagerInterface $relation_manager */ $relation_manager = \Drupal::service('hal.link_manager.relation'); $link = $relation_manager->getRelationUri($entity_type, $bundle, $field_name, $context); @@ -204,18 +189,6 @@ public function providerTestGetRelationUri() { // No cacheability metadata bubbled. 'expected context' => ['hal_test' => TRUE] + $serialization_context_collecting_cacheability, ], - // Test hook_rest_relation_uri_alter() — for backwards compatibility. - 'site URL, with optional context, to test hook_rest_relation_uri_alter()' => $base_test_case + [ - 'context' => ['rest_test' => TRUE], - 'expected return' => 'rest_test_relation', - 'expected context' => ['rest_test' => TRUE], - ], - 'site URL, with optional context, to test hook_rest_relation_uri_alter(), and collecting cacheability metadata' => $base_test_case + [ - 'context' => ['rest_test' => TRUE] + $serialization_context_collecting_cacheability, - 'expected return' => 'rest_test_relation', - // No cacheability metadata bubbled. - 'expected context' => ['rest_test' => TRUE] + $serialization_context_collecting_cacheability, - ], 'configured URL' => [ 'link_domain' => 'http://llamas-rock.com/for-real/', 'entity_type' => 'node', @@ -243,14 +216,13 @@ public function providerTestGetRelationUri() { * @covers ::getRelationInternalIds */ public function testGetRelationInternalIds() { - /* @var \Drupal\rest\LinkManager\RelationLinkManagerInterface $relation_manager */ + /* @var \Drupal\hal\LinkManager\RelationLinkManagerInterface $relation_manager */ $relation_manager = \Drupal::service('hal.link_manager.relation'); $link = $relation_manager->getRelationUri('node', 'page', 'field_ref'); $internal_ids = $relation_manager->getRelationInternalIds($link); $this->assertEquals([ 'entity_type_id' => 'node', - 'entity_type' => \Drupal::entityTypeManager()->getDefinition('node'), 'bundle' => 'page', 'field_name' => 'field_ref', ], $internal_ids); @@ -264,7 +236,7 @@ public function testHalLinkManagersSetLinkDomain() { CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY => new CacheableMetadata(), ]; - /* @var \Drupal\rest\LinkManager\LinkManager $link_manager */ + /* @var \Drupal\hal\LinkManager\LinkManager $link_manager */ $link_manager = \Drupal::service('hal.link_manager'); $link_manager->setLinkDomain('http://example.com/'); $link = $link_manager->getTypeUri('node', 'page', $serialization_context); diff --git a/core/modules/media/tests/src/Functional/Hal/MediaHalJsonAnonTest.php b/core/modules/media/tests/src/Functional/Hal/MediaHalJsonAnonTest.php index 6f990b6641d1..f8e4b3b4164c 100644 --- a/core/modules/media/tests/src/Functional/Hal/MediaHalJsonAnonTest.php +++ b/core/modules/media/tests/src/Functional/Hal/MediaHalJsonAnonTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\media\Functional\Hal; -use Drupal\Core\Cache\Cache; use Drupal\file\Entity\File; use Drupal\Tests\hal\Functional\EntityResource\HalEntityNormalizationTrait; use Drupal\Tests\media\Functional\Rest\MediaResourceTestBase; @@ -223,11 +222,4 @@ protected function getNormalizedPostEntity() { ]; } - /** - * {@inheritdoc} - */ - protected function getExpectedCacheTags() { - return Cache::mergeTags(parent::getExpectedCacheTags(), ['config:hal.settings']); - } - } -- GitLab