.../EntityResource/Node/NodeHalJsonAnonTest.php | 1 - .../Vocabulary/VocabularyHalJsonAnonTest.php | 10 +++++++--- .../EntityResource/Block/BlockResourceTestBase.php | 5 +++-- .../EntityResource/EntityResourceTestBase.php | 23 +++++++++++----------- .../EntityTest/EntityTestResourceTestBase.php | 3 +++ .../EntityResource/Node/NodeResourceTestBase.php | 3 +++ .../EntityResource/Role/RoleResourceTestBase.php | 3 +++ .../EntityResource/Term/TermResourceTestBase.php | 3 +++ .../Vocabulary/VocabularyJsonAnonTest.php | 10 +++++++--- 9 files changed, 41 insertions(+), 20 deletions(-) diff --git a/core/modules/hal/tests/src/Functional/EntityResource/Node/NodeHalJsonAnonTest.php b/core/modules/hal/tests/src/Functional/EntityResource/Node/NodeHalJsonAnonTest.php index cb22d58..5fe42d3 100644 --- a/core/modules/hal/tests/src/Functional/EntityResource/Node/NodeHalJsonAnonTest.php +++ b/core/modules/hal/tests/src/Functional/EntityResource/Node/NodeHalJsonAnonTest.php @@ -7,7 +7,6 @@ use Drupal\Tests\rest\Functional\EntityResource\Node\NodeResourceTestBase; use Drupal\user\Entity\User; - /** * @group hal */ diff --git a/core/modules/hal/tests/src/Functional/EntityResource/Vocabulary/VocabularyHalJsonAnonTest.php b/core/modules/hal/tests/src/Functional/EntityResource/Vocabulary/VocabularyHalJsonAnonTest.php index 910da05..fc9fed7 100644 --- a/core/modules/hal/tests/src/Functional/EntityResource/Vocabulary/VocabularyHalJsonAnonTest.php +++ b/core/modules/hal/tests/src/Functional/EntityResource/Vocabulary/VocabularyHalJsonAnonTest.php @@ -32,8 +32,12 @@ class VocabularyHalJsonAnonTest extends VocabularyResourceTestBase { */ protected static $expectedErrorMimeType = 'application/json'; - // Disable the GET test coverage due to bug in taxonomy module. - // @todo Fix in https://www.drupal.org/node/2805281: remove this override. - public function testGet() {} + /** + * Disable the GET test coverage due to bug in taxonomy module. + * @todo Fix in https://www.drupal.org/node/2805281: remove this override. + */ + public function testGet() { + $this->markTestSkipped(); + } } 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 5ef4512..7857b29 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/Block/BlockResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/Block/BlockResourceTestBase.php @@ -4,8 +4,6 @@ use Drupal\block\Entity\Block; use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase; -use Drupal\user\Entity\Role; -use Drupal\user\RoleInterface; abstract class BlockResourceTestBase extends EntityResourceTestBase { @@ -64,6 +62,9 @@ protected function createEntity() { return $block; } + /** + * {@inheritdoc} + */ protected function getExpectedNormalizedEntity() { assert('$this->entity instanceof \Drupal\Core\Entity\EntityInterface', 'Entity must already have been created.'); $normalization = [ diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php index aa2b3ca..cb3227a 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php @@ -2,12 +2,9 @@ namespace Drupal\Tests\rest\Functional\EntityResource; -use Drupal\Component\Serialization\Json; use Drupal\Core\Config\Entity\ConfigEntityInterface; -use Drupal\Core\Entity\EntityType; use Drupal\Core\Url; use Drupal\Tests\rest\Functional\ResourceTestBase; -use GuzzleHttp\Exception\ClientException; use GuzzleHttp\RequestOptions; use Psr\Http\Message\ResponseInterface; @@ -25,6 +22,11 @@ */ abstract class EntityResourceTestBase extends ResourceTestBase { + /** + * The tested entity type. + * + * @var string + */ protected static $entityType = NULL; /** @@ -39,7 +41,9 @@ */ protected $entity; - + /** + * {@inheritdoc} + */ protected function provisionEntityResource() { // It's possible to not have any authentication providers enabled, when // testing public (anonymous) usage of a REST resource. @@ -47,6 +51,9 @@ protected function provisionEntityResource() { $this->provisionResource('entity.' . static::$entityType, [static::$format], $auth); } + /** + * {@inheritdoc} + */ public function setUp() { parent::setUp(); @@ -100,13 +107,7 @@ public function testGet() { // DX: 404 when resource not provisioned, 403 if canonical route. $response = $this->request('GET', $url, $request_options); - // @todo Open issue to improve this message: it should list '/relative/url?query-string', not just '/relative/url'. - if ($has_canonical_url) { - $this->assertSame(403, $response->getStatusCode()); - } - else { - $this->assertSame(404, $response->getStatusCode()); - } + $this->assertSame($has_canonical_url ? 403 : 404, $response->getStatusCode()); $this->assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type')); 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 deaf1e8..b281cc0 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestResourceTestBase.php @@ -46,6 +46,9 @@ protected function createEntity() { return $entity_test; } + /** + * {@inheritdoc} + */ protected function getExpectedNormalizedEntity() { assert('$this->entity instanceof \Drupal\Core\Entity\EntityInterface', 'Entity must already have been created.'); $author = User::load(0); 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 f32105e..5e27a0a 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/Node/NodeResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/Node/NodeResourceTestBase.php @@ -55,6 +55,9 @@ protected function createEntity() { return $node; } + /** + * {@inheritdoc} + */ protected function getExpectedNormalizedEntity() { assert('$this->entity instanceof \Drupal\Core\Entity\EntityInterface', 'Entity must already have been created.'); $author = User::load(0); diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Role/RoleResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/Role/RoleResourceTestBase.php index f5406d4..791d40c 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/Role/RoleResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/Role/RoleResourceTestBase.php @@ -38,6 +38,9 @@ protected function createEntity() { return $role; } + /** + * {@inheritdoc} + */ protected function getExpectedNormalizedEntity() { assert('$this->entity instanceof \Drupal\Core\Entity\EntityInterface', 'Entity must already have been created.'); return [ 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 77372df..303657e 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/Term/TermResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/Term/TermResourceTestBase.php @@ -53,6 +53,9 @@ protected function createEntity() { return $term; } + /** + * {@inheritdoc} + */ protected function getExpectedNormalizedEntity() { assert('$this->entity instanceof \Drupal\Core\Entity\EntityInterface', 'Entity must already have been created.'); return [ diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Vocabulary/VocabularyJsonAnonTest.php b/core/modules/rest/tests/src/Functional/EntityResource/Vocabulary/VocabularyJsonAnonTest.php index ccda474..4e29106 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/Vocabulary/VocabularyJsonAnonTest.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/Vocabulary/VocabularyJsonAnonTest.php @@ -26,8 +26,12 @@ class VocabularyJsonAnonTest extends VocabularyResourceTestBase { */ protected static $expectedErrorMimeType = 'application/json'; - // Disable the GET test coverage due to bug in taxonomy module. - // @todo Fix in https://www.drupal.org/node/2805281: remove this override. - public function testGet() {} + /** + * Disable the GET test coverage due to bug in taxonomy module. + * @todo Fix in https://www.drupal.org/node/2805281: remove this override. + */ + public function testGet() { + $this->markTestSkipped(); + } }