CF>NWRb?%Erh*P9Wf0a&pBk%bj4R1MIUXkM=UjjGpnMM968M8
zUPkTxNJr{Dtnq3Q=DS00A8s;f5~_s{O*juqlFuh1M*+j&AMOPMMsZHG_XDB@lZuNr
z$i|#)i5(7?xAU)Uhdbfi
zDBf^fTsgcM^jae{Bgk{^Mvj0tUlJZ&l2ArdBqlCQ9HPkCwp3=irWT=0jYg!oKRHAK
zGu?V-w;LV^7Edziv?r@+H+3=x;N$Xcr*2_EgLA5o@vuTuR^g=a_ieLt2p=x;1Xp}u>2tEzBT%j8%RiVjT>Suv!>2XN>K0`D$1n$aP7``
z)eLQ+x->cZUs-6c+MP$V6Kr1g7Z*U2!`KWtD4qGN`!KzrZO9~3;LIMF$|KI-!{NuF
zc^P*tJNRF_j@LTJM&s&TD361EN#B&3-~$}p%L=>8%ZgppV(xEZF=oJK
zJr|V1qO81d_<%v*en3Dc@P!2(U)P(s?}!4OjUdbu0ueQQD;BE3_apS?C{j4|o)Qv#
SAhS=12Z>(`#?DFaT>Tf|^skfv
diff --git a/core/modules/rest/tests/fixtures/update/drupal-8.rest-rest_update_8201.php b/core/modules/rest/tests/fixtures/update/drupal-8.rest-rest_update_8201.php
deleted file mode 100644
index 17a69d5..0000000
--- a/core/modules/rest/tests/fixtures/update/drupal-8.rest-rest_update_8201.php
+++ /dev/null
@@ -1,59 +0,0 @@
-insert('key_value')
- ->fields([
- 'collection' => 'system.schema',
- 'name' => 'rest',
- 'value' => 'i:8000;',
- ])
- ->execute();
-
-// Update core.extension.
-$extensions = $connection->select('config')
- ->fields('config', ['data'])
- ->condition('collection', '')
- ->condition('name', 'core.extension')
- ->execute()
- ->fetchField();
-$extensions = unserialize($extensions);
-$extensions['module']['basic_auth'] = 0;
-$extensions['module']['rest'] = 0;
-$extensions['module']['serialization'] = 0;
-$connection->update('config')
- ->fields([
- 'data' => serialize($extensions),
- ])
- ->condition('collection', '')
- ->condition('name', 'core.extension')
- ->execute();
-
-// Install the rest configuration.
-$config = [
- 'resources' => [
- 'entity:node' => [
- 'GET' => [
- 'supported_formats' => ['json'],
- 'supported_auth' => ['basic_auth'],
- ],
- ],
- ],
- 'link_domain' => NULL,
-];
-$data = $connection->insert('config')
- ->fields([
- 'name' => 'rest.settings',
- 'data' => serialize($config),
- 'collection' => ''
- ])
- ->execute();
diff --git a/core/modules/rest/tests/fixtures/update/drupal-8.rest-rest_update_8203.php b/core/modules/rest/tests/fixtures/update/drupal-8.rest-rest_update_8203.php
deleted file mode 100644
index 15acff9..0000000
--- a/core/modules/rest/tests/fixtures/update/drupal-8.rest-rest_update_8203.php
+++ /dev/null
@@ -1,58 +0,0 @@
-insert('key_value')
- ->fields([
- 'collection' => 'system.schema',
- 'name' => 'rest',
- 'value' => 'i:8000;',
- ])
- ->execute();
-
-// Update core.extension.
-$extensions = $connection->select('config')
- ->fields('config', ['data'])
- ->condition('collection', '')
- ->condition('name', 'core.extension')
- ->execute()
- ->fetchField();
-$extensions = unserialize($extensions);
-$extensions['module']['rest'] = 0;
-$extensions['module']['serialization'] = 0;
-$connection->update('config')
- ->fields([
- 'data' => serialize($extensions),
- ])
- ->condition('collection', '')
- ->condition('name', 'core.extension')
- ->execute();
-
-// Install the rest configuration.
-$config = [
- 'resources' => [
- 'entity:node' => [
- 'GET' => [
- 'supported_formats' => ['json'],
- 'supported_auth' => ['basic_auth'],
- ],
- ],
- ],
- 'link_domain' => NULL,
-];
-$data = $connection->insert('config')
- ->fields([
- 'name' => 'rest.settings',
- 'data' => serialize($config),
- 'collection' => ''
- ])
- ->execute();
diff --git a/core/modules/rest/tests/fixtures/update/rest-export-with-authentication-correction.php b/core/modules/rest/tests/fixtures/update/rest-export-with-authentication-correction.php
deleted file mode 100644
index 6cbd04e..0000000
--- a/core/modules/rest/tests/fixtures/update/rest-export-with-authentication-correction.php
+++ /dev/null
@@ -1,63 +0,0 @@
-insert('key_value')
- ->fields([
- 'collection' => 'system.schema',
- 'name' => 'rest',
- 'value' => 'i:8000;',
- ])
- ->execute();
-
-// Update core.extension.
-$extensions = $connection->select('config')
- ->fields('config', ['data'])
- ->condition('collection', '')
- ->condition('name', 'core.extension')
- ->execute()
- ->fetchField();
-$extensions = unserialize($extensions);
-$extensions['module']['rest'] = 0;
-$extensions['module']['serialization'] = 0;
-$extensions['module']['basic_auth'] = 0;
-$connection->update('config')
- ->fields([
- 'data' => serialize($extensions),
- ])
- ->condition('collection', '')
- ->condition('name', 'core.extension')
- ->execute();
-
-$connection->insert('config')
- ->fields([
- 'name' => 'rest.settings',
- 'data' => serialize([
- 'link_domain' => '~',
- ]),
- 'collection' => '',
- ])
- ->execute();
-
-$connection->insert('config')
- ->fields([
- 'name' => 'views.view.rest_export_with_authorization_correction',
- ])
- ->execute();
-
-$connection->merge('config')
- ->condition('name', 'views.view.rest_export_with_authorization_correction')
- ->condition('collection', '')
- ->fields([
- 'data' => serialize(Yaml::decode(file_get_contents('core/modules/views/tests/modules/views_test_config/test_views/views.view.rest_export_with_authorization_correction.yml'))),
- ])
- ->execute();
diff --git a/core/modules/rest/tests/fixtures/update/rest-export-with-authentication.php b/core/modules/rest/tests/fixtures/update/rest-export-with-authentication.php
deleted file mode 100644
index 7d72d49..0000000
--- a/core/modules/rest/tests/fixtures/update/rest-export-with-authentication.php
+++ /dev/null
@@ -1,65 +0,0 @@
-insert('key_value')
- ->fields([
- 'collection' => 'system.schema',
- 'name' => 'rest',
- 'value' => 'i:8000;',
- ])
- ->execute();
-
-// Update core.extension.
-$extensions = $connection->select('config')
- ->fields('config', ['data'])
- ->condition('collection', '')
- ->condition('name', 'core.extension')
- ->execute()
- ->fetchField();
-$extensions = unserialize($extensions);
-$extensions['module']['rest'] = 0;
-$extensions['module']['serialization'] = 0;
-$extensions['module']['basic_auth'] = 0;
-$connection->update('config')
- ->fields([
- 'data' => serialize($extensions),
- ])
- ->condition('collection', '')
- ->condition('name', 'core.extension')
- ->execute();
-
-$config = [
- 'link_domain' => '~',
-];
-$data = $connection->insert('config')
- ->fields([
- 'name' => 'rest.settings',
- 'data' => serialize($config),
- 'collection' => '',
- ])
- ->execute();
-
-$connection->insert('config')
- ->fields([
- 'name' => 'views.view.rest_export_with_authorization',
- ])
- ->execute();
-
-$connection->merge('config')
- ->condition('name', 'views.view.rest_export_with_authorization')
- ->condition('collection', '')
- ->fields([
- 'data' => serialize(Yaml::decode(file_get_contents('core/modules/views/tests/modules/views_test_config/test_views/views.view.rest_export_with_authorization.yml'))),
- ])
- ->execute();
diff --git a/core/modules/rest/tests/fixtures/update/rest.resource.entity.comment_2721595.yml b/core/modules/rest/tests/fixtures/update/rest.resource.entity.comment_2721595.yml
deleted file mode 100644
index 7e86bab..0000000
--- a/core/modules/rest/tests/fixtures/update/rest.resource.entity.comment_2721595.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-id: entity.comment
-plugin_id: 'entity:comment'
-granularity: method
-configuration:
- GET:
- supported_formats:
- - hal_json
- # This resource has a method-specific format.
- # @see \Drupal\rest\Tests\Update\ResourceGranularityUpdateTest
- - xml
- supported_auth:
- - basic_auth
- POST:
- supported_formats:
- - hal_json
- supported_auth:
- - basic_auth
- PATCH:
- supported_formats:
- - hal_json
- supported_auth:
- - basic_auth
- DELETE:
- supported_formats:
- - hal_json
- supported_auth:
- - basic_auth
-dependencies:
- module:
- - node
- - basic_auth
- - hal
diff --git a/core/modules/rest/tests/fixtures/update/rest.resource.entity.node_2721595.yml b/core/modules/rest/tests/fixtures/update/rest.resource.entity.node_2721595.yml
deleted file mode 100644
index 0cf4d78..0000000
--- a/core/modules/rest/tests/fixtures/update/rest.resource.entity.node_2721595.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-id: entity.node
-plugin_id: 'entity:node'
-granularity: method
-configuration:
- GET:
- supported_formats:
- - hal_json
- supported_auth:
- - basic_auth
- POST:
- supported_formats:
- - hal_json
- supported_auth:
- - basic_auth
- PATCH:
- supported_formats:
- - hal_json
- supported_auth:
- - basic_auth
- DELETE:
- supported_formats:
- - hal_json
- supported_auth:
- - basic_auth
-dependencies:
- module:
- - node
- - basic_auth
- - hal
diff --git a/core/modules/rest/tests/fixtures/update/rest.resource.entity.user_2721595.yml b/core/modules/rest/tests/fixtures/update/rest.resource.entity.user_2721595.yml
deleted file mode 100644
index 593a260..0000000
--- a/core/modules/rest/tests/fixtures/update/rest.resource.entity.user_2721595.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-id: entity.user
-plugin_id: 'entity:user'
-granularity: method
-configuration:
- GET:
- supported_formats:
- - hal_json
- supported_auth:
- - basic_auth
- # This resource has a method-specific authentication.
- # @see \Drupal\rest\Tests\Update\ResourceGranularityUpdateTest
- - oauth
- POST:
- supported_formats:
- - hal_json
- supported_auth:
- - basic_auth
- PATCH:
- supported_formats:
- - hal_json
- supported_auth:
- - basic_auth
- DELETE:
- supported_formats:
- - hal_json
- supported_auth:
- - basic_auth
-dependencies:
- module:
- - node
- - basic_auth
- - hal
diff --git a/core/modules/rest/tests/src/Functional/BcTimestampNormalizerUnixTestTrait.php b/core/modules/rest/tests/src/Functional/BcTimestampNormalizerUnixTestTrait.php
deleted file mode 100644
index a275f64..0000000
--- a/core/modules/rest/tests/src/Functional/BcTimestampNormalizerUnixTestTrait.php
+++ /dev/null
@@ -1,43 +0,0 @@
-config('serialization.settings')->get('bc_timestamp_normalizer_unix')) {
- return ['value' => $timestamp];
- }
-
- // Otherwise, format the date string to the same that
- // \Drupal\serialization\Normalizer\TimestampItemNormalizer will produce.
- $date = new \DateTime();
- $date->setTimestamp($timestamp);
- $date->setTimezone(new \DateTimeZone('UTC'));
-
- // Format is also added to the expected return values.
- return [
- 'value' => $date->format(\DateTime::RFC3339),
- 'format' => \DateTime::RFC3339,
- ];
- }
-
-}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/BaseFieldOverride/BaseFieldOverrideResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/BaseFieldOverride/BaseFieldOverrideResourceTestBase.php
index 1f4b03a..9725e34 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/BaseFieldOverride/BaseFieldOverrideResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/BaseFieldOverride/BaseFieldOverrideResourceTestBase.php
@@ -101,10 +101,6 @@ protected function getExpectedCacheContexts() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
return "The 'administer node fields' permission is required.";
}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Block/BlockResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/Block/BlockResourceTestBase.php
index d86f9b1..ee2cc64 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/Block/BlockResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/Block/BlockResourceTestBase.php
@@ -129,10 +129,6 @@ protected function getExpectedCacheTags() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
switch ($method) {
case 'GET':
return "You are not authorized to view this block entity.";
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/BlockContent/BlockContentResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/BlockContent/BlockContentResourceTestBase.php
index 8b67cc6..f5b8e10 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/BlockContent/BlockContentResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/BlockContent/BlockContentResourceTestBase.php
@@ -12,8 +12,6 @@
*/
abstract class BlockContentResourceTestBase extends EntityResourceTestBase {
- use BcTimestampNormalizerUnixTestTrait;
-
/**
* {@inheritdoc}
*/
@@ -105,7 +103,10 @@ protected function getExpectedNormalizedEntity() {
],
'revision_log' => [],
'changed' => [
- $this->formatExpectedTimestampItemValues($this->entity->getChangedTime()),
+ [
+ 'value' => (new \DateTime())->setTimestamp((int) $this->entity->getChangedTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'revision_id' => [
[
@@ -113,7 +114,10 @@ protected function getExpectedNormalizedEntity() {
],
],
'revision_created' => [
- $this->formatExpectedTimestampItemValues((int) $this->entity->getRevisionCreationTime()),
+ [
+ 'value' => (new \DateTime())->setTimestamp((int) $this->entity->getRevisionCreationTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'revision_user' => [],
'revision_translation_affected' => [
@@ -164,10 +168,6 @@ protected function getNormalizedPostEntity() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
return parent::getExpectedUnauthorizedAccessMessage($method);
}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Comment/CommentResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/Comment/CommentResourceTestBase.php
index bade2a7..69d46f7 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/Comment/CommentResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/Comment/CommentResourceTestBase.php
@@ -6,14 +6,13 @@
use Drupal\comment\Entity\CommentType;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\entity_test\Entity\EntityTest;
-use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
use Drupal\user\Entity\User;
use GuzzleHttp\RequestOptions;
abstract class CommentResourceTestBase extends EntityResourceTestBase {
- use CommentTestTrait, BcTimestampNormalizerUnixTestTrait;
+ use CommentTestTrait;
/**
* {@inheritdoc}
@@ -149,10 +148,16 @@ protected function getExpectedNormalizedEntity() {
],
],
'created' => [
- $this->formatExpectedTimestampItemValues(123456789),
+ [
+ 'value' => (new \DateTime())->setTimestamp(123456789)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'changed' => [
- $this->formatExpectedTimestampItemValues($this->entity->getChangedTime()),
+ [
+ 'value' => (new \DateTime())->setTimestamp((int) $this->entity->getChangedTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'default_langcode' => [
[
@@ -310,10 +315,6 @@ public function testPostDxWithoutCriticalBaseFields() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
switch ($method) {
case 'GET';
return "The 'access comments' permission is required and the comment must be published.";
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/ContactForm/ContactFormResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/ContactForm/ContactFormResourceTestBase.php
index 51e297a..214e06c 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/ContactForm/ContactFormResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/ContactForm/ContactFormResourceTestBase.php
@@ -8,8 +8,6 @@
abstract class ContactFormResourceTestBase extends EntityResourceTestBase {
- use BcTimestampNormalizerUnixTestTrait;
-
/**
* {@inheritdoc}
*/
@@ -94,10 +92,6 @@ protected function getNormalizedPostEntity() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
return "The 'access site-wide contact form' permission is required.";
}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Editor/EditorResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/Editor/EditorResourceTestBase.php
index 4eb4a6e..4f20778 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/Editor/EditorResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/Editor/EditorResourceTestBase.php
@@ -174,10 +174,6 @@ protected function getExpectedCacheContexts() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
return "The 'administer filters' permission is required.";
}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityFormDisplay/EntityFormDisplayResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityFormDisplay/EntityFormDisplayResourceTestBase.php
index cc4cf58..54798c4 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/EntityFormDisplay/EntityFormDisplayResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityFormDisplay/EntityFormDisplayResourceTestBase.php
@@ -151,10 +151,6 @@ protected function getExpectedCacheContexts() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
return "The 'administer node form display' permission is required.";
}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
index 7196940..714c8a9 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
@@ -233,11 +233,6 @@ protected function getNormalizedPatchEntity() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
-
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
$permission = $this->entity->getEntityType()->getAdminPermission();
if ($permission !== FALSE) {
return "The '{$permission}' permission is required.";
@@ -485,83 +480,6 @@ public function testGet() {
$head_headers = $header_cleaner($head_headers);
$this->assertSame($get_headers, $head_headers);
- // BC: serialization_update_8302().
- // Only run this for fieldable entities. It doesn't make sense for config
- // entities as config values are already casted. They also run through the
- // ConfigEntityNormalizer, which doesn't deal with fields individually.
- if ($this->entity instanceof FieldableEntityInterface) {
- // Test primitive data casting BC (strings).
- $this->config('serialization.settings')->set('bc_primitives_as_strings', TRUE)->save(TRUE);
- // Rebuild the container so new config is reflected in the addition of the
- // PrimitiveDataNormalizer.
- $this->rebuildAll();
-
- $response = $this->request('GET', $url, $request_options);
- $this->assertResourceResponse(200, FALSE, $response);
-
- // Again do an identical comparison, but this time transform the expected
- // normalized entity's values to strings. This ensures the BC layer for
- // bc_primitives_as_strings works as expected.
- $expected = $this->getExpectedNormalizedEntity();
- // Config entities are not affected.
- // @see \Drupal\serialization\Normalizer\ConfigEntityNormalizer::normalize()
- $expected = static::castToString($expected);
- static::recursiveKSort($expected);
- $actual = $this->serializer->decode((string) $response->getBody(), static::$format);
- static::recursiveKSort($actual);
- $this->assertSame($expected, $actual);
-
- // Reset the config value and rebuild.
- $this->config('serialization.settings')->set('bc_primitives_as_strings', FALSE)->save(TRUE);
- $this->rebuildAll();
- }
-
- // BC: serialization_update_8401().
- // Only run this for fieldable entities. It doesn't make sense for config
- // entities as config values always use the raw values (as per the config
- // schema), returned directly from the ConfigEntityNormalizer, which
- // doesn't deal with fields individually.
- if ($this->entity instanceof FieldableEntityInterface) {
- // Test the BC settings for timestamp values.
- $this->config('serialization.settings')->set('bc_timestamp_normalizer_unix', TRUE)->save(TRUE);
- // Rebuild the container so new config is reflected in the addition of the
- // TimestampItemNormalizer.
- $this->rebuildAll();
-
- $response = $this->request('GET', $url, $request_options);
- $this->assertResourceResponse(200, FALSE, $response);
-
- // This ensures the BC layer for bc_timestamp_normalizer_unix works as
- // expected. This method should be using
- // ::formatExpectedTimestampValue() to generate the timestamp value. This
- // will take into account the above config setting.
- $expected = $this->getExpectedNormalizedEntity();
- // Config entities are not affected.
- // @see \Drupal\serialization\Normalizer\ConfigEntityNormalizer::normalize()
- static::recursiveKSort($expected);
- $actual = $this->serializer->decode((string) $response->getBody(), static::$format);
- static::recursiveKSort($actual);
- $this->assertSame($expected, $actual);
-
- // Reset the config value and rebuild.
- $this->config('serialization.settings')->set('bc_timestamp_normalizer_unix', FALSE)->save(TRUE);
- $this->rebuildAll();
- }
-
- // BC: rest_update_8203().
- $this->config('rest.settings')->set('bc_entity_resource_permissions', TRUE)->save(TRUE);
- $this->refreshTestStateAfterRestConfigChange();
-
- // DX: 403 when unauthorized.
- $response = $this->request('GET', $url, $request_options);
- $this->assertResourceErrorResponse(403, $this->getExpectedUnauthorizedAccessMessage('GET'), $response);
-
- $this->grantPermissionsToTestedRole(['restful get entity:' . static::$entityTypeId]);
-
- // 200 for well-formed request.
- $response = $this->request('GET', $url, $request_options);
- $this->assertResourceResponse(200, FALSE, $response);
-
$this->resourceConfigStorage->load(static::$resourceConfigId)->disable()->save();
$this->refreshTestStateAfterRestConfigChange();
@@ -810,44 +728,6 @@ public function testPost() {
}
}
}
-
- $this->config('rest.settings')->set('bc_entity_resource_permissions', TRUE)->save(TRUE);
- $this->refreshTestStateAfterRestConfigChange();
- $request_options[RequestOptions::BODY] = $parseable_valid_request_body_2;
-
- // DX: 403 when unauthorized.
- $response = $this->request('POST', $url, $request_options);
- $this->assertResourceErrorResponse(403, $this->getExpectedUnauthorizedAccessMessage('POST'), $response);
-
- $this->grantPermissionsToTestedRole(['restful post entity:' . static::$entityTypeId]);
-
- // 201 for well-formed request.
- // If the entity is stored, delete the first created entity (in case there
- // is a uniqueness constraint).
- if (get_class($this->entityStorage) !== ContentEntityNullStorage::class) {
- $this->entityStorage->load(static::$firstCreatedEntityId)->delete();
- }
- $response = $this->request('POST', $url, $request_options);
- $this->assertResourceResponse(201, FALSE, $response);
- if ($has_canonical_url) {
- $location = $this->entityStorage->load(static::$secondCreatedEntityId)->toUrl('canonical')->setAbsolute(TRUE)->toString();
- $this->assertSame([$location], $response->getHeader('Location'));
- }
- else {
- $this->assertSame([], $response->getHeader('Location'));
- }
- $this->assertFalse($response->hasHeader('X-Drupal-Cache'));
-
- // BC: old default POST URLs have their path updated by the inbound path
- // processor \Drupal\rest\PathProcessor\PathProcessorEntityResourceBC to the
- // new URL, which is derived from the 'create' link template if an entity
- // type specifies it.
- if ($this->entity->getEntityType()->hasLinkTemplate('create')) {
- $this->entityStorage->load(static::$secondCreatedEntityId)->delete();
- $old_url = Url::fromUri('base:entity/' . static::$entityTypeId);
- $response = $this->request('POST', $old_url, $request_options);
- $this->assertResourceResponse(201, FALSE, $response);
- }
}
/**
@@ -1017,21 +897,6 @@ public function testPatch() {
// request. Test this using the configurable field that we added, but which
// is not sent in the PATCH request.
$this->assertSame('All the faith he had had had had no effect on the outcome of his life.', $updated_entity->get('field_rest_test')->value);
-
- $this->config('rest.settings')->set('bc_entity_resource_permissions', TRUE)->save(TRUE);
- $this->refreshTestStateAfterRestConfigChange();
- $request_options[RequestOptions::BODY] = $parseable_valid_request_body_2;
-
- // DX: 403 when unauthorized.
- $response = $this->request('PATCH', $url, $request_options);
- $this->assertResourceErrorResponse(403, $this->getExpectedUnauthorizedAccessMessage('PATCH'), $response);
-
- $this->grantPermissionsToTestedRole(['restful patch entity:' . static::$entityTypeId]);
-
- // 200 for well-formed request.
- $response = $this->request('PATCH', $url, $request_options);
- $this->assertResourceResponse(200, FALSE, $response);
- $this->assertFalse($response->hasHeader('X-Drupal-Cache'));
}
/**
@@ -1112,25 +977,6 @@ public function testDelete() {
// $this->assertSame(FALSE, $response->hasHeader('Content-Type'));
$this->assertSame('', (string) $response->getBody());
$this->assertFalse($response->hasHeader('X-Drupal-Cache'));
-
- $this->config('rest.settings')->set('bc_entity_resource_permissions', TRUE)->save(TRUE);
- $this->refreshTestStateAfterRestConfigChange();
- $this->entity = $this->createEntity();
- $url = $this->getEntityResourceUrl()->setOption('query', $url->getOption('query'));
-
- // DX: 403 when unauthorized.
- $response = $this->request('DELETE', $url, $request_options);
- $this->assertResourceErrorResponse(403, $this->getExpectedUnauthorizedAccessMessage('DELETE'), $response);
-
- $this->grantPermissionsToTestedRole(['restful delete entity:' . static::$entityTypeId]);
-
- // 204 for well-formed request.
- $response = $this->request('DELETE', $url, $request_options);
- $this->assertSame(204, $response->getStatusCode());
- // @todo Uncomment the following line when https://www.drupal.org/node/2821711 is fixed.
- // $this->assertSame(FALSE, $response->hasHeader('Content-Type'));
- $this->assertSame('', (string) $response->getBody());
- $this->assertFalse($response->hasHeader('X-Drupal-Cache'));
}
/**
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestResourceTestBase.php
index d14ec38..315f5be 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestResourceTestBase.php
@@ -3,14 +3,11 @@
namespace Drupal\Tests\rest\Functional\EntityResource\EntityTest;
use Drupal\entity_test\Entity\EntityTest;
-use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
use Drupal\user\Entity\User;
abstract class EntityTestResourceTestBase extends EntityResourceTestBase {
- use BcTimestampNormalizerUnixTestTrait;
-
/**
* {@inheritdoc}
*/
@@ -106,7 +103,10 @@ protected function getExpectedNormalizedEntity() {
]
],
'created' => [
- $this->formatExpectedTimestampItemValues((int) $this->entity->get('created')->value)
+ [
+ 'value' => (new \DateTime())->setTimestamp((int) $this->entity->get('created')->value)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'user_id' => [
[
@@ -144,10 +144,6 @@ protected function getNormalizedPostEntity() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
switch ($method) {
case 'GET':
return "The 'view test entity' permission is required.";
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityTestBundle/EntityTestBundleResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityTestBundle/EntityTestBundleResourceTestBase.php
index f43d877..bb42717 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/EntityTestBundle/EntityTestBundleResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityTestBundle/EntityTestBundleResourceTestBase.php
@@ -8,8 +8,6 @@
abstract class EntityTestBundleResourceTestBase extends EntityResourceTestBase {
- use BcTimestampNormalizerUnixTestTrait;
-
/**
* {@inheritdoc}
*/
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityTestLabel/EntityTestLabelResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityTestLabel/EntityTestLabelResourceTestBase.php
index 2257d6c..9ae5cc5 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/EntityTestLabel/EntityTestLabelResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityTestLabel/EntityTestLabelResourceTestBase.php
@@ -3,14 +3,11 @@
namespace Drupal\Tests\rest\Functional\EntityResource\EntityTestLabel;
use Drupal\entity_test\Entity\EntityTestLabel;
-use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
use Drupal\user\Entity\User;
abstract class EntityTestLabelResourceTestBase extends EntityResourceTestBase {
- use BcTimestampNormalizerUnixTestTrait;
-
/**
* {@inheritdoc}
*/
@@ -97,7 +94,10 @@ protected function getExpectedNormalizedEntity() {
],
],
'created' => [
- $this->formatExpectedTimestampItemValues((int) $this->entity->get('created')->value),
+ [
+ 'value' => (new \DateTime())->setTimestamp((int) $this->entity->get('created')->value)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'user_id' => [
[
@@ -141,10 +141,6 @@ protected function getExpectedCacheContexts() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
switch ($method) {
case 'GET':
return "The 'view test entity' permission is required.";
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityViewDisplay/EntityViewDisplayResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityViewDisplay/EntityViewDisplayResourceTestBase.php
index ccc3aad..871b4c1 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/EntityViewDisplay/EntityViewDisplayResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityViewDisplay/EntityViewDisplayResourceTestBase.php
@@ -108,10 +108,6 @@ protected function getExpectedCacheContexts() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
return "The 'administer node display' permission is required.";
}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Feed/FeedResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/Feed/FeedResourceTestBase.php
index 1e79395..eda368d 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/Feed/FeedResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/Feed/FeedResourceTestBase.php
@@ -2,14 +2,11 @@
namespace Drupal\Tests\rest\Functional\EntityResource\Feed;
-use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\EntityTest\EntityTestResourceTestBase;
use Drupal\aggregator\Entity\Feed;
abstract class FeedResourceTestBase extends EntityTestResourceTestBase {
- use BcTimestampNormalizerUnixTestTrait;
-
/**
* {@inheritdoc}
*/
@@ -95,10 +92,16 @@ protected function getExpectedNormalizedEntity() {
]
],
'checked' => [
- $this->formatExpectedTimestampItemValues(123456789),
+ [
+ 'value' => (new \DateTime())->setTimestamp(123456789)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'queued' => [
- $this->formatExpectedTimestampItemValues(123456789),
+ [
+ 'value' => (new \DateTime())->setTimestamp(123456789)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'link' => [
[
@@ -126,7 +129,10 @@ protected function getExpectedNormalizedEntity() {
]
],
'modified' => [
- $this->formatExpectedTimestampItemValues(123456789),
+ [
+ 'value' => (new \DateTime())->setTimestamp(123456789)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
];
}
@@ -163,10 +169,6 @@ protected function getNormalizedPostEntity() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
switch ($method) {
case 'GET':
return "The 'access news feeds' permission is required.";
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/FieldConfig/FieldConfigResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/FieldConfig/FieldConfigResourceTestBase.php
index 05c05f4..fd82c7a 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/FieldConfig/FieldConfigResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/FieldConfig/FieldConfigResourceTestBase.php
@@ -109,10 +109,6 @@ protected function getExpectedCacheContexts() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
return "The 'administer node fields' permission is required.";
}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/FieldStorageConfig/FieldStorageConfigResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/FieldStorageConfig/FieldStorageConfigResourceTestBase.php
index aafc253..817c8e8 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/FieldStorageConfig/FieldStorageConfigResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/FieldStorageConfig/FieldStorageConfigResourceTestBase.php
@@ -79,10 +79,6 @@ protected function getNormalizedPostEntity() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
switch ($method) {
case 'GET':
return "The 'administer node fields' permission is required.";
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/ImageStyle/ImageStyleResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/ImageStyle/ImageStyleResourceTestBase.php
index ccd68d9..3dbc1ab 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/ImageStyle/ImageStyleResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/ImageStyle/ImageStyleResourceTestBase.php
@@ -103,10 +103,6 @@ protected function getNormalizedPostEntity() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
return "The 'administer image styles' permission is required.";
}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Item/ItemResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/Item/ItemResourceTestBase.php
index f217b97..8ca3005 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/Item/ItemResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/Item/ItemResourceTestBase.php
@@ -4,7 +4,6 @@
use Drupal\aggregator\Entity\Feed;
use Drupal\aggregator\Entity\Item;
-use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
/**
@@ -12,8 +11,6 @@
*/
abstract class ItemResourceTestBase extends EntityResourceTestBase {
- use BcTimestampNormalizerUnixTestTrait;
-
/**
* {@inheritdoc}
*/
@@ -116,7 +113,10 @@ protected function getExpectedNormalizedEntity() {
'author' => [],
'description' => [],
'timestamp' => [
- $this->formatExpectedTimestampItemValues(123456789),
+ [
+ 'value' => (new \DateTime())->setTimestamp(123456789)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'guid' => [],
];
@@ -157,10 +157,6 @@ protected function getExpectedCacheContexts() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
switch ($method) {
case 'GET':
return "The 'access news feeds' permission is required.";
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Media/MediaResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/Media/MediaResourceTestBase.php
index 475a1ca..5504ff4 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/Media/MediaResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/Media/MediaResourceTestBase.php
@@ -11,8 +11,6 @@
abstract class MediaResourceTestBase extends EntityResourceTestBase {
- use BcTimestampNormalizerUnixTestTrait;
-
/**
* {@inheritdoc}
*/
@@ -175,13 +173,22 @@ protected function getExpectedNormalizedEntity() {
],
],
'created' => [
- $this->formatExpectedTimestampItemValues(123456789),
+ [
+ 'value' => (new \DateTime())->setTimestamp(123456789)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'changed' => [
- $this->formatExpectedTimestampItemValues($this->entity->getChangedTime()),
+ [
+ 'value' => (new \DateTime())->setTimestamp((int) $this->entity->getChangedTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'revision_created' => [
- $this->formatExpectedTimestampItemValues((int) $this->entity->getRevisionCreationTime()),
+ [
+ 'value' => (new \DateTime())->setTimestamp((int) $this->entity->getRevisionCreationTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'default_langcode' => [
[
@@ -235,10 +242,6 @@ protected function getNormalizedPostEntity() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
switch ($method) {
case 'GET';
return "The 'view media' permission is required and the media item must be published.";
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/MenuLinkContent/MenuLinkContentResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/MenuLinkContent/MenuLinkContentResourceTestBase.php
index 0b1f967..c01c985 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/MenuLinkContent/MenuLinkContentResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/MenuLinkContent/MenuLinkContentResourceTestBase.php
@@ -3,7 +3,6 @@
namespace Drupal\Tests\rest\Functional\EntityResource\MenuLinkContent;
use Drupal\menu_link_content\Entity\MenuLinkContent;
-use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
/**
@@ -11,8 +10,6 @@
*/
abstract class MenuLinkContentResourceTestBase extends EntityResourceTestBase {
- use BcTimestampNormalizerUnixTestTrait;
-
/**
* {@inheritdoc}
*/
@@ -164,7 +161,10 @@ protected function getExpectedNormalizedEntity() {
],
],
'changed' => [
- $this->formatExpectedTimestampItemValues($this->entity->getChangedTime()),
+ [
+ 'value' => (new \DateTime())->setTimestamp($this->entity->getChangedTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'default_langcode' => [
[
@@ -179,10 +179,6 @@ protected function getExpectedNormalizedEntity() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
switch ($method) {
case 'DELETE':
return "You are not authorized to delete this menu_link_content entity.";
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Message/MessageResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/Message/MessageResourceTestBase.php
index 3f1cab9..75ebdd2 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/Message/MessageResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/Message/MessageResourceTestBase.php
@@ -101,10 +101,6 @@ protected function getExpectedNormalizedEntity() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
if ($method === 'POST') {
return "The 'access site-wide contact form' permission is required.";
}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Node/NodeResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/Node/NodeResourceTestBase.php
index 492ff64..2bb1b9e 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/Node/NodeResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/Node/NodeResourceTestBase.php
@@ -4,15 +4,12 @@
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
-use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
use Drupal\user\Entity\User;
use GuzzleHttp\RequestOptions;
abstract class NodeResourceTestBase extends EntityResourceTestBase {
- use BcTimestampNormalizerUnixTestTrait;
-
/**
* {@inheritdoc}
*/
@@ -129,10 +126,16 @@ protected function getExpectedNormalizedEntity() {
],
],
'created' => [
- $this->formatExpectedTimestampItemValues(123456789),
+ [
+ 'value' => (new \DateTime())->setTimestamp(123456789)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'changed' => [
- $this->formatExpectedTimestampItemValues($this->entity->getChangedTime()),
+ [
+ 'value' => (new \DateTime())->setTimestamp($this->entity->getChangedTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'promote' => [
[
@@ -145,7 +148,10 @@ protected function getExpectedNormalizedEntity() {
],
],
'revision_timestamp' => [
- $this->formatExpectedTimestampItemValues(123456789),
+ [
+ 'value' => (new \DateTime())->setTimestamp(123456789)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'revision_translation_affected' => [
[
@@ -206,10 +212,6 @@ protected function getNormalizedPostEntity() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
if ($method === 'GET' || $method == 'PATCH' || $method == 'DELETE') {
return "The 'access content' permission is required.";
}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/NodeType/NodeTypeResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/NodeType/NodeTypeResourceTestBase.php
index c374bfb..2bf5523 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/NodeType/NodeTypeResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/NodeType/NodeTypeResourceTestBase.php
@@ -80,10 +80,6 @@ protected function getNormalizedPostEntity() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
return "The 'access content' permission is required.";
}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/ResponsiveImageStyle/ResponsiveImageStyleResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/ResponsiveImageStyle/ResponsiveImageStyleResourceTestBase.php
index 4221314..91d7c38 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/ResponsiveImageStyle/ResponsiveImageStyleResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/ResponsiveImageStyle/ResponsiveImageStyleResourceTestBase.php
@@ -123,10 +123,6 @@ protected function getNormalizedPostEntity() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
return "The 'administer responsive images' permission is required.";
}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/SearchPage/SearchPageResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/SearchPage/SearchPageResourceTestBase.php
index e81993f..58cf9e2 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/SearchPage/SearchPageResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/SearchPage/SearchPageResourceTestBase.php
@@ -86,10 +86,6 @@ protected function getNormalizedPostEntity() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
switch ($method) {
case 'GET':
return "The 'access content' permission is required.";
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Shortcut/ShortcutResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/Shortcut/ShortcutResourceTestBase.php
index 36be5b5..c4cfd4b 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/Shortcut/ShortcutResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/Shortcut/ShortcutResourceTestBase.php
@@ -144,10 +144,6 @@ protected function getNormalizedPostEntity() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
switch ($method) {
case 'GET':
case 'POST':
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Term/TermResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/Term/TermResourceTestBase.php
index e0a1581..a9ca768 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/Term/TermResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/Term/TermResourceTestBase.php
@@ -4,14 +4,11 @@
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\Entity\Vocabulary;
-use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
use GuzzleHttp\RequestOptions;
abstract class TermResourceTestBase extends EntityResourceTestBase {
- use BcTimestampNormalizerUnixTestTrait;
-
/**
* {@inheritdoc}
*/
@@ -123,7 +120,10 @@ protected function getExpectedNormalizedEntity() {
],
],
'changed' => [
- $this->formatExpectedTimestampItemValues($this->entity->getChangedTime()),
+ [
+ 'value' => (new \DateTime())->setTimestamp($this->entity->getChangedTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'default_langcode' => [
[
@@ -168,10 +168,6 @@ protected function getNormalizedPostEntity() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
switch ($method) {
case 'GET':
return "The 'access content' permission is required.";
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Tour/TourResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/Tour/TourResourceTestBase.php
index 294e3ee..7f0b99a 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/Tour/TourResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/Tour/TourResourceTestBase.php
@@ -113,10 +113,6 @@ protected function getExpectedCacheContexts() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
return "The following permissions are required: 'access tour' OR 'administer site configuration'.";
}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/User/UserResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/User/UserResourceTestBase.php
index d758cf6..8ebe7f8 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/User/UserResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/User/UserResourceTestBase.php
@@ -3,15 +3,12 @@
namespace Drupal\Tests\rest\Functional\EntityResource\User;
use Drupal\Core\Url;
-use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
use Drupal\user\Entity\User;
use GuzzleHttp\RequestOptions;
abstract class UserResourceTestBase extends EntityResourceTestBase {
- use BcTimestampNormalizerUnixTestTrait;
-
/**
* {@inheritdoc}
*/
@@ -101,10 +98,16 @@ protected function getExpectedNormalizedEntity() {
],
],
'created' => [
- $this->formatExpectedTimestampItemValues(123456789),
+ [
+ 'value' => (new \DateTime())->setTimestamp(123456789)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'changed' => [
- $this->formatExpectedTimestampItemValues($this->entity->getChangedTime()),
+ [
+ 'value' => (new \DateTime())->setTimestamp($this->entity->getChangedTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'default_langcode' => [
[
@@ -247,10 +250,6 @@ protected function assertRpcLogin($username, $password) {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
- if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
- return parent::getExpectedUnauthorizedAccessMessage($method);
- }
-
switch ($method) {
case 'GET':
return "The 'access user profiles' permission is required and the user must be active.";
diff --git a/core/modules/rest/tests/src/Functional/ResourceTestBase.php b/core/modules/rest/tests/src/Functional/ResourceTestBase.php
index 0a0e34c..b30c5d4 100644
--- a/core/modules/rest/tests/src/Functional/ResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/ResourceTestBase.php
@@ -163,7 +163,6 @@ protected function provisionResource($formats = [], $authentication = []) {
*
* Should be called after every change made to:
* - RestResourceConfig entities
- * - the 'rest.settings' simple configuration
*/
protected function refreshTestStateAfterRestConfigChange() {
// Ensure that the cache tags invalidator has its internal values reset.
@@ -171,8 +170,8 @@ protected function refreshTestStateAfterRestConfigChange() {
$this->refreshVariables();
// Tests using this base class may trigger route rebuilds due to changes to
- // RestResourceConfig entities or 'rest.settings'. Ensure the test generates
- // routes using an up-to-date router.
+ // RestResourceConfig entities. Ensure the test generates routes using an
+ // up-to-date router.
\Drupal::service('router.builder')->rebuildIfNeeded();
}
diff --git a/core/modules/rest/tests/src/Functional/Update/EntityResourcePermissionsUpdateTest.php b/core/modules/rest/tests/src/Functional/Update/EntityResourcePermissionsUpdateTest.php
deleted file mode 100644
index 9add9c5..0000000
--- a/core/modules/rest/tests/src/Functional/Update/EntityResourcePermissionsUpdateTest.php
+++ /dev/null
@@ -1,56 +0,0 @@
-databaseDumpFiles = [
- __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
- __DIR__ . '/../../../fixtures/update/drupal-8.rest-rest_update_8203.php',
- ];
- }
-
- /**
- * Tests rest_update_8203().
- */
- public function testBcEntityResourcePermissionSettingAdded() {
- $permission_handler = $this->container->get('user.permissions');
-
- $is_rest_resource_permission = function ($permission) {
- return $permission['provider'] === 'rest' && (string) $permission['title'] !== 'Administer REST resource configuration';
- };
-
- // Make sure we have the expected values before the update.
- $rest_settings = $this->config('rest.settings');
- $this->assertFalse(array_key_exists('bc_entity_resource_permissions', $rest_settings->getRawData()));
- $this->assertEqual([], array_filter($permission_handler->getPermissions(), $is_rest_resource_permission));
-
- $this->runUpdates();
-
- // Make sure we have the expected values after the update.
- $rest_settings = $this->config('rest.settings');
- $this->assertTrue(array_key_exists('bc_entity_resource_permissions', $rest_settings->getRawData()));
- $this->assertTrue($rest_settings->get('bc_entity_resource_permissions'));
- $rest_permissions = array_keys(array_filter($permission_handler->getPermissions(), $is_rest_resource_permission));
- $this->assertEqual(['restful delete entity:node', 'restful get entity:node', 'restful patch entity:node', 'restful post entity:node'], $rest_permissions);
- }
-
-}
diff --git a/core/modules/rest/tests/src/Functional/Update/ResourceGranularityUpdateTest.php b/core/modules/rest/tests/src/Functional/Update/ResourceGranularityUpdateTest.php
deleted file mode 100644
index 19ef545..0000000
--- a/core/modules/rest/tests/src/Functional/Update/ResourceGranularityUpdateTest.php
+++ /dev/null
@@ -1,71 +0,0 @@
-databaseDumpFiles = [
- __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
- __DIR__ . '/../../../fixtures/update/drupal-8.rest-rest_post_update_resource_granularity.php',
- ];
- }
-
- /**
- * Tests rest_post_update_simplify_resource_granularity().
- */
- public function testMethodGranularityConvertedToResourceGranularity() {
- /** @var \Drupal\Core\Entity\EntityStorageInterface $resource_config_storage */
- $resource_config_storage = $this->container->get('entity_type.manager')->getStorage('rest_resource_config');
-
- // Make sure we have the expected values before the update.
- $resource_config_entities = $resource_config_storage->loadMultiple();
- $this->assertIdentical(['entity.comment', 'entity.node', 'entity.user'], array_keys($resource_config_entities));
- $this->assertIdentical('method', $resource_config_entities['entity.node']->get('granularity'));
- $this->assertIdentical('method', $resource_config_entities['entity.comment']->get('granularity'));
- $this->assertIdentical('method', $resource_config_entities['entity.user']->get('granularity'));
-
- // Read the existing 'entity:comment' and 'entity:user' resource
- // configuration so we can verify it after the update.
- $comment_resource_configuration = $resource_config_entities['entity.comment']->get('configuration');
- $user_resource_configuration = $resource_config_entities['entity.user']->get('configuration');
-
- $this->runUpdates();
-
- // Make sure we have the expected values after the update.
- $resource_config_entities = $resource_config_storage->loadMultiple();
- $this->assertIdentical(['entity.comment', 'entity.node', 'entity.user'], array_keys($resource_config_entities));
- // 'entity:node' should be updated.
- $this->assertIdentical('resource', $resource_config_entities['entity.node']->get('granularity'));
- $this->assertidentical($resource_config_entities['entity.node']->get('configuration'), [
- 'methods' => ['GET', 'POST', 'PATCH', 'DELETE'],
- 'formats' => ['hal_json'],
- 'authentication' => ['basic_auth'],
- ]);
- // 'entity:comment' should be unchanged.
- $this->assertIdentical('method', $resource_config_entities['entity.comment']->get('granularity'));
- $this->assertIdentical($comment_resource_configuration, $resource_config_entities['entity.comment']->get('configuration'));
- // 'entity:user' should be unchanged.
- $this->assertIdentical('method', $resource_config_entities['entity.user']->get('granularity'));
- $this->assertIdentical($user_resource_configuration, $resource_config_entities['entity.user']->get('configuration'));
- }
-
-}
diff --git a/core/modules/rest/tests/src/Functional/Update/RestConfigurationEntitiesUpdateTest.php b/core/modules/rest/tests/src/Functional/Update/RestConfigurationEntitiesUpdateTest.php
deleted file mode 100644
index f4d8199..0000000
--- a/core/modules/rest/tests/src/Functional/Update/RestConfigurationEntitiesUpdateTest.php
+++ /dev/null
@@ -1,65 +0,0 @@
-databaseDumpFiles = [
- __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
- __DIR__ . '/../../../fixtures/update/drupal-8.rest-rest_update_8201.php',
- ];
- }
-
- /**
- * Tests rest_update_8201().
- */
- public function testResourcesConvertedToConfigEntities() {
- /** @var \Drupal\Core\Entity\EntityStorageInterface $resource_config_storage */
- $resource_config_storage = $this->container->get('entity_type.manager')->getStorage('rest_resource_config');
-
- // Make sure we have the expected values before the update.
- $rest_settings = $this->config('rest.settings');
- $this->assertTrue(array_key_exists('resources', $rest_settings->getRawData()));
- $this->assertTrue(array_key_exists('entity:node', $rest_settings->getRawData()['resources']));
- $resource_config_entities = $resource_config_storage->loadMultiple();
- $this->assertIdentical([], array_keys($resource_config_entities));
-
- $this->runUpdates();
-
- // Make sure we have the expected values after the update.
- $rest_settings = $this->config('rest.settings');
- $this->assertFalse(array_key_exists('resources', $rest_settings->getRawData()));
- $resource_config_entities = $resource_config_storage->loadMultiple();
- $this->assertIdentical(['entity.node'], array_keys($resource_config_entities));
- $node_resource_config_entity = $resource_config_entities['entity.node'];
- $this->assertIdentical(RestResourceConfigInterface::RESOURCE_GRANULARITY, $node_resource_config_entity->get('granularity'));
- $this->assertIdentical([
- 'methods' => ['GET'],
- 'formats' => ['json'],
- 'authentication' => ['basic_auth'],
- ], $node_resource_config_entity->get('configuration'));
- $this->assertIdentical(['module' => ['basic_auth', 'node', 'serialization']], $node_resource_config_entity->getDependencies());
- }
-
-}
diff --git a/core/modules/rest/tests/src/Functional/Update/RestExportAuthUpdateTest.php b/core/modules/rest/tests/src/Functional/Update/RestExportAuthUpdateTest.php
deleted file mode 100644
index 87cd5db..0000000
--- a/core/modules/rest/tests/src/Functional/Update/RestExportAuthUpdateTest.php
+++ /dev/null
@@ -1,36 +0,0 @@
-databaseDumpFiles = [
- __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
- __DIR__ . '/../../../../tests/fixtures/update/rest-export-with-authentication.php',
- ];
- }
-
- /**
- * Ensures that update hook is run for rest module.
- */
- public function testUpdate() {
- $this->runUpdates();
-
- // Get particular view.
- $view = \Drupal::entityTypeManager()->getStorage('view')->load('rest_export_with_authorization');
- $displays = $view->get('display');
- $this->assertIdentical($displays['rest_export_1']['display_options']['auth']['basic_auth'], 'basic_auth', 'Basic authentication is set as authentication method.');
- }
-
-}
diff --git a/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php b/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php
index 5b71b93..5bde06b 100644
--- a/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php
+++ b/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php
@@ -13,8 +13,6 @@
*/
class EntitySerializationTest extends NormalizerTestBase {
- use BcTimestampNormalizerUnixTestTrait;
-
/**
* Modules to install.
*
@@ -109,7 +107,10 @@ public function testNormalize() {
['value' => 'entity_test_mulrev'],
],
'created' => [
- $this->formatExpectedTimestampItemValues($this->entity->created->value),
+ [
+ 'value' => (new \DateTime())->setTimestamp((int) $this->entity->get('created')->value)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
+ 'format' => \DateTime::RFC3339,
+ ],
],
'user_id' => [
[
|