Commit 720924f7 authored by catch's avatar catch

Issue #2893804 by Wim Leers, Stefdewa, Berdir, catch: Remove rest.module BC layers

parent 474a6902
......@@ -2,14 +2,11 @@
namespace Drupal\Tests\aggregator\Functional\Rest;
use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
use Drupal\aggregator\Entity\Feed;
abstract class FeedResourceTestBase extends EntityResourceTestBase {
use BcTimestampNormalizerUnixTestTrait;
/**
* {@inheritdoc}
*/
......@@ -105,10 +102,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' => [
[
......@@ -136,7 +139,10 @@ protected function getExpectedNormalizedEntity() {
],
],
'modified' => [
$this->formatExpectedTimestampItemValues(123456789),
[
'value' => (new \DateTime())->setTimestamp(123456789)->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
'format' => \DateTime::RFC3339,
],
],
];
}
......@@ -173,10 +179,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.";
......
......@@ -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}
*/
......@@ -130,7 +127,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' => [],
];
......@@ -171,10 +171,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.";
......
......@@ -130,10 +130,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 "The block visibility condition 'user_role' denied access.";
......
......@@ -5,7 +5,6 @@
use Drupal\block_content\Entity\BlockContent;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\Core\Cache\Cache;
use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
/**
......@@ -13,8 +12,6 @@
*/
abstract class BlockContentResourceTestBase extends EntityResourceTestBase {
use BcTimestampNormalizerUnixTestTrait;
/**
* {@inheritdoc}
*/
......@@ -111,7 +108,12 @@ 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' => [
[
......@@ -119,7 +121,12 @@ 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' => [
......@@ -170,10 +177,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);
}
......
......@@ -7,14 +7,13 @@
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\Core\Cache\Cache;
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}
......@@ -150,10 +149,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' => [
[
......@@ -308,10 +313,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.";
......
......@@ -3,13 +3,10 @@
namespace Drupal\Tests\contact\Functional\Rest;
use Drupal\contact\Entity\ContactForm;
use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
abstract class ContactFormResourceTestBase extends EntityResourceTestBase {
use BcTimestampNormalizerUnixTestTrait;
/**
* {@inheritdoc}
*/
......@@ -94,10 +91,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.";
}
......
......@@ -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.";
}
......
......@@ -79,7 +79,7 @@ public function testWatchdog() {
$this->setUpAuthorization('GET');
$response = $this->request('GET', $url, $request_options);
$this->assertResourceResponse(200, FALSE, $response, ['config:rest.resource.dblog', 'config:rest.settings', 'http_response'], ['user.permissions'], FALSE, 'MISS');
$this->assertResourceResponse(200, FALSE, $response, ['config:rest.resource.dblog', 'http_response'], ['user.permissions'], FALSE, 'MISS');
$log = Json::decode((string) $response->getBody());
$this->assertEqual($log['wid'], $id, 'Log ID is correct.');
$this->assertEqual($log['type'], 'rest', 'Type of log message is correct.');
......
......@@ -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.";
}
......
......@@ -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.";
}
......
......@@ -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.";
......
......@@ -48,7 +48,7 @@
* label = @Translation("File Upload"),
* serialization_class = "Drupal\file\Entity\File",
* uri_paths = {
* "https://www.drupal.org/link-relations/create" = "/file/upload/{entity_type_id}/{bundle}/{field_name}"
* "create" = "/file/upload/{entity_type_id}/{bundle}/{field_name}"
* }
* )
*/
......
......@@ -3,14 +3,11 @@
namespace Drupal\Tests\file\Functional\Rest;
use Drupal\file\Entity\File;
use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
use Drupal\user\Entity\User;
abstract class FileResourceTestBase extends EntityResourceTestBase {
use BcTimestampNormalizerUnixTestTrait;
/**
* {@inheritdoc}
*/
......@@ -109,10 +106,16 @@ protected function createEntity() {
protected function getExpectedNormalizedEntity() {
return [
'changed' => [
$this->formatExpectedTimestampItemValues($this->entity->getChangedTime()),
[
'value' => (new \DateTime())->setTimestamp($this->entity->getChangedTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
'format' => \DateTime::RFC3339,
],
],
'created' => [
$this->formatExpectedTimestampItemValues((int) $this->entity->getCreatedTime()),
[
'value' => (new \DateTime())->setTimestamp((int) $this->entity->getCreatedTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
'format' => \DateTime::RFC3339,
],
],
'fid' => [
[
......@@ -217,13 +220,6 @@ public function testPost() {
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
if ($method === 'DELETE') {
return 'Only the file owner can update or delete the file entity.';
}
return parent::getExpectedUnauthorizedAccessMessage($method);
}
if ($method === 'GET') {
return "The 'access content' permission is required.";
}
......
......@@ -105,10 +105,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.";
}
......
......@@ -6,7 +6,6 @@
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
use Drupal\user\Entity\User;
/**
......@@ -16,8 +15,6 @@
*/
class EntityTestTest extends ResourceTestBase {
use BcTimestampNormalizerUnixTestTrait;
/**
* {@inheritdoc}
*/
......
......@@ -7,7 +7,6 @@
use Drupal\Core\Url;
use Drupal\file\Entity\File;
use Drupal\Tests\jsonapi\Traits\CommonCollectionFilterAccessTestPatternsTrait;
use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
use Drupal\user\Entity\User;
use GuzzleHttp\RequestOptions;
......@@ -18,7 +17,6 @@
*/
class FileTest extends ResourceTestBase {
use BcTimestampNormalizerUnixTestTrait;
use CommonCollectionFilterAccessTestPatternsTrait;
/**
......
......@@ -4,7 +4,6 @@
use Drupal\aggregator\Entity\Feed;
use Drupal\aggregator\Entity\Item;
use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
/**
* JSON:API integration test for the "Item" content entity type.
......@@ -13,8 +12,6 @@
*/
class ItemTest extends ResourceTestBase {
use BcTimestampNormalizerUnixTestTrait;
/**
* {@inheritdoc}
*/
......
......@@ -53,7 +53,6 @@ public function testOverrideField() {
[
'config:filter.format.plain_text',
'config:rest.resource.entity.node',
'config:rest.settings',
'http_response',
'node:1',
],
......
......@@ -8,7 +8,6 @@
use Drupal\media\Entity\Media;
use Drupal\media\Entity\MediaType;
use Drupal\rest\RestResourceConfigInterface;
use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
use Drupal\user\Entity\Role;
use Drupal\user\Entity\User;
......@@ -17,8 +16,6 @@
abstract class MediaResourceTestBase extends EntityResourceTestBase {
use BcTimestampNormalizerUnixTestTrait;
/**
* {@inheritdoc}
*/
......@@ -197,13 +194,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' => [
[
......@@ -271,10 +277,6 @@ protected function getNormalizedPatchEntity() {
* {@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 when the media item is published.";
......@@ -425,10 +427,16 @@ protected function getExpectedNormalizedFileEntity() {
],
],
'created' => [
$this->formatExpectedTimestampItemValues($file->getCreatedTime()),
[
'value' => (new \DateTime())->setTimestamp($file->getCreatedTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
'format' => \DateTime::RFC3339,
],
],
'changed' => [
$this->formatExpectedTimestampItemValues($file->getChangedTime()),
[
'value' => (new \DateTime())->setTimestamp($file->getChangedTime())->setTimezone(new \DateTimeZone('UTC'))->format(\DateTime::RFC3339),
'format' => \DateTime::RFC3339,
],
],
];
}
......
......@@ -3,7 +3,6 @@
namespace Drupal\Tests\menu_link_content\Functional\Rest;
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}
*/
......@@ -188,7 +185,12 @@ 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' => [
[
......@@ -197,7 +199,12 @@ protected function getExpectedNormalizedEntity() {
],
'parent' => [],
'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_log_message' => [],
......@@ -213,10 +220,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 "The 'administer menu' permission is required.";
......
......@@ -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;
/**