.../Comment/CommentHalJsonAnonTest.php | 2 +- .../Comment/CommentHalJsonTestBase.php | 2 +- .../EntityResource/HalEntityNormalizationTrait.php | 4 +++- .../EntityResource/User/UserHalJsonAnonTest.php | 2 +- .../HalJsonBasicAuthWorkaroundFor2805281Trait.php | 3 ++- .../config_test_rest/config_test_rest.module | 6 +++++- .../Comment/CommentJsonBasicAuthTest.php | 1 - .../EntityResource/EntityResourceTestBase.php | 22 +++++++++++----------- .../EntityResource/Node/NodeJsonBasicAuthTest.php | 1 - .../EntityResource/Role/RoleJsonCookieTest.php | 2 -- .../EntityResource/Role/RoleResourceTestBase.php | 1 - .../EntityResource/User/UserResourceTestBase.php | 6 +++--- .../Vocabulary/VocabularyResourceTestBase.php | 3 --- .../rest/tests/src/Functional/ResourceTestBase.php | 4 ---- 14 files changed, 27 insertions(+), 32 deletions(-) diff --git a/core/modules/hal/tests/src/Functional/EntityResource/Comment/CommentHalJsonAnonTest.php b/core/modules/hal/tests/src/Functional/EntityResource/Comment/CommentHalJsonAnonTest.php index 9313640..3edd9b1 100644 --- a/core/modules/hal/tests/src/Functional/EntityResource/Comment/CommentHalJsonAnonTest.php +++ b/core/modules/hal/tests/src/Functional/EntityResource/Comment/CommentHalJsonAnonTest.php @@ -7,7 +7,7 @@ /** * @group hal */ -class CommentHalJsonAnonTest extends CommentHalJsonTestBase { +class CommentHalJsonAnonTest extends CommentHalJsonTestBase { use AnonResourceTestTrait; diff --git a/core/modules/hal/tests/src/Functional/EntityResource/Comment/CommentHalJsonTestBase.php b/core/modules/hal/tests/src/Functional/EntityResource/Comment/CommentHalJsonTestBase.php index 5328d11..f4b03af 100644 --- a/core/modules/hal/tests/src/Functional/EntityResource/Comment/CommentHalJsonTestBase.php +++ b/core/modules/hal/tests/src/Functional/EntityResource/Comment/CommentHalJsonTestBase.php @@ -8,7 +8,7 @@ use Drupal\Tests\rest\Functional\EntityResource\Comment\CommentResourceTestBase; use Drupal\user\Entity\User; -abstract class CommentHalJsonTestBase extends CommentResourceTestBase { +abstract class CommentHalJsonTestBase extends CommentResourceTestBase { use HalEntityNormalizationTrait; diff --git a/core/modules/hal/tests/src/Functional/EntityResource/HalEntityNormalizationTrait.php b/core/modules/hal/tests/src/Functional/EntityResource/HalEntityNormalizationTrait.php index 16cca6e..d3bd85a 100644 --- a/core/modules/hal/tests/src/Functional/EntityResource/HalEntityNormalizationTrait.php +++ b/core/modules/hal/tests/src/Functional/EntityResource/HalEntityNormalizationTrait.php @@ -98,6 +98,7 @@ protected function assertNormalizationEdgeCases($method, Url $url, array $reques $normalization = $this->getNormalizedPostEntity(); // @todo Uncomment this in https://www.drupal.org/node/2824827. + // @codingStandardsIgnoreStart /* $normalization['_links']['type'] = Url::fromUri('base:rest/type/' . static::$entityTypeId . '/bad_bundle_name'); $request_options[RequestOptions::BODY] = $this->serializer->encode($normalization, static::$format); @@ -110,6 +111,7 @@ protected function assertNormalizationEdgeCases($method, Url $url, array $reques $this->assertSame([static::$mimeType], $response->getHeader('Content-Type')); $this->assertSame($this->serializer->encode(['error' => 'The type link relation must be specified.'], static::$format), (string) $response->getBody()); */ + // @codingStandardsIgnoreEnd unset($normalization['_links']['type']); $request_options[RequestOptions::BODY] = $this->serializer->encode($normalization, static::$format); @@ -118,7 +120,7 @@ protected function assertNormalizationEdgeCases($method, Url $url, array $reques // DX: 400 when no entity type bundle is specified. $response = $this->request($method, $url, $request_options); // @todo Uncomment, remove next 3 in https://www.drupal.org/node/2813853. -// $this->assertResourceErrorResponse(400, 'The type link relation must be specified.', $response); + // $this->assertResourceErrorResponse(400, 'The type link relation must be specified.', $response); $this->assertSame(400, $response->getStatusCode()); $this->assertSame([static::$mimeType], $response->getHeader('Content-Type')); $this->assertSame($this->serializer->encode(['error' => 'The type link relation must be specified.'], static::$format), (string) $response->getBody()); diff --git a/core/modules/hal/tests/src/Functional/EntityResource/User/UserHalJsonAnonTest.php b/core/modules/hal/tests/src/Functional/EntityResource/User/UserHalJsonAnonTest.php index 3d5fe9a..d839a72 100644 --- a/core/modules/hal/tests/src/Functional/EntityResource/User/UserHalJsonAnonTest.php +++ b/core/modules/hal/tests/src/Functional/EntityResource/User/UserHalJsonAnonTest.php @@ -10,7 +10,7 @@ /** * @group hal */ -class UserHalJsonAnonTest extends UserResourceTestBase { +class UserHalJsonAnonTest extends UserResourceTestBase { use HalEntityNormalizationTrait; use AnonResourceTestTrait; diff --git a/core/modules/hal/tests/src/Functional/HalJsonBasicAuthWorkaroundFor2805281Trait.php b/core/modules/hal/tests/src/Functional/HalJsonBasicAuthWorkaroundFor2805281Trait.php index 5661d33..ef77d96 100644 --- a/core/modules/hal/tests/src/Functional/HalJsonBasicAuthWorkaroundFor2805281Trait.php +++ b/core/modules/hal/tests/src/Functional/HalJsonBasicAuthWorkaroundFor2805281Trait.php @@ -19,7 +19,8 @@ protected function assertResponseWhenMissingAuthentication(ResponseInterface $re $this->assertSame(401, $response->getStatusCode()); // @todo this works fine locally, but on testbot it comes back with // 'text/plain; charset=UTF-8'. WTF. -// $this->assertSame(['application/hal+json'], $response->getHeader('Content-Type')); + // $this->assertSame(['application/hal+json'], $response->getHeader('Content-Type')); $this->assertSame('No authentication credentials provided.', (string) $response->getBody()); } + } diff --git a/core/modules/rest/tests/modules/config_test_rest/config_test_rest.module b/core/modules/rest/tests/modules/config_test_rest/config_test_rest.module index f7e24a2..fcd9979 100644 --- a/core/modules/rest/tests/modules/config_test_rest/config_test_rest.module +++ b/core/modules/rest/tests/modules/config_test_rest/config_test_rest.module @@ -1,10 +1,14 @@ request('POST', $url, $request_options); // @todo Uncomment, remove next 3 in https://www.drupal.org/node/2813853. -// $this->assertResourceErrorResponse(400, 'Syntax error', $response); + // $this->assertResourceErrorResponse(400, 'Syntax error', $response); $this->assertSame(400, $response->getStatusCode()); $this->assertSame([static::$mimeType], $response->getHeader('Content-Type')); $this->assertSame($this->serializer->encode(['error' => 'Syntax error'], static::$format), (string) $response->getBody()); @@ -566,7 +566,7 @@ public function testPost() { $label_field = $this->entity->getEntityType()->hasKey('label') ? $this->entity->getEntityType()->getKey('label') : static::$labelFieldName; $label_field_capitalized = ucfirst($label_field); // @todo Uncomment, remove next 3 in https://www.drupal.org/node/2813755. -// $this->assertErrorResponse(422, "Unprocessable Entity: validation failed.\ntitle: Title: this field cannot hold more than 1 values.\n", $response); + // $this->assertErrorResponse(422, "Unprocessable Entity: validation failed.\ntitle: Title: this field cannot hold more than 1 values.\n", $response); $this->assertSame(422, $response->getStatusCode()); $this->assertSame([static::$mimeType], $response->getHeader('Content-Type')); $this->assertSame($this->serializer->encode(['message' => "Unprocessable Entity: validation failed.\n$label_field: $label_field_capitalized: this field cannot hold more than 1 values.\n"], static::$format), (string) $response->getBody()); @@ -578,7 +578,7 @@ public function testPost() { // DX: 422 when invalid entity: UUID field too long. $response = $this->request('POST', $url, $request_options); // @todo Uncomment, remove next 3 in https://www.drupal.org/node/2813755. -// $this->assertErrorResponse(422, "Unprocessable Entity: validation failed.\nuuid.0.value: UUID: may not be longer than 128 characters.\n", $response); + // $this->assertErrorResponse(422, "Unprocessable Entity: validation failed.\nuuid.0.value: UUID: may not be longer than 128 characters.\n", $response); $this->assertSame(422, $response->getStatusCode()); $this->assertSame([static::$mimeType], $response->getHeader('Content-Type')); $this->assertSame($this->serializer->encode(['message' => "Unprocessable Entity: validation failed.\nuuid.0.value: UUID: may not be longer than 128 characters.\n"], static::$format), (string) $response->getBody()); @@ -732,7 +732,7 @@ public function testPatch() { // DX: 400 when unparseable request body. $response = $this->request('PATCH', $url, $request_options); // @todo Uncomment, remove next 3 in https://www.drupal.org/node/2813853. -// $this->assertResourceErrorResponse(400, 'Syntax error', $response); + // $this->assertResourceErrorResponse(400, 'Syntax error', $response); $this->assertSame(400, $response->getStatusCode()); $this->assertSame([static::$mimeType], $response->getHeader('Content-Type')); $this->assertSame($this->serializer->encode(['error' => 'Syntax error'], static::$format), (string) $response->getBody()); @@ -767,9 +767,9 @@ public function testPatch() { $label_field = $this->entity->getEntityType()->hasKey('label') ? $this->entity->getEntityType()->getKey('label') : static::$labelFieldName; $label_field_capitalized = ucfirst($label_field); // @todo Uncomment, remove next 3 in https://www.drupal.org/node/2813755. -// $this->assertErrorResponse(422, "Unprocessable Entity: validation failed.\ntitle: Title: this field cannot hold more than 1 values.\n", $response); -// $this->assertSame(422, $response->getStatusCode()); -// $this->assertSame([static::$mimeType], $response->getHeader('Content-Type')); + // $this->assertErrorResponse(422, "Unprocessable Entity: validation failed.\ntitle: Title: this field cannot hold more than 1 values.\n", $response); + // $this->assertSame(422, $response->getStatusCode()); + // $this->assertSame([static::$mimeType], $response->getHeader('Content-Type')); $this->assertSame($this->serializer->encode(['message' => "Unprocessable Entity: validation failed.\n$label_field: $label_field_capitalized: this field cannot hold more than 1 values.\n"], static::$format), (string) $response->getBody()); @@ -791,7 +791,7 @@ public function testPatch() { $max_normalization = $this->removeFieldsFromNormalization($max_normalization, array_slice(static::$patchProtectedFieldNames, 0, $i)); $request_options[RequestOptions::BODY] = $this->serializer->serialize($max_normalization, static::$format); $response = $this->request('PATCH', $url, $request_options); - $this->assertResourceErrorResponse(403, "Access denied on updating field '" . static::$patchProtectedFieldNames[$i] . "'.", $response); + $this->assertResourceErrorResponse(403, "Access denied on updating field '" . static::$patchProtectedFieldNames[$i] . "'.", $response); } // 200 for well-formed request that sends the maximum number of fields. @@ -928,7 +928,7 @@ public function testDelete() { $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(FALSE, $response->hasHeader('Content-Type')); $this->assertSame('', $response->getBody()->getContents()); $this->assertFalse($response->hasHeader('X-Drupal-Cache')); @@ -953,7 +953,7 @@ public function testDelete() { $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(FALSE, $response->hasHeader('Content-Type')); $this->assertSame('', $response->getBody()->getContents()); $this->assertFalse($response->hasHeader('X-Drupal-Cache')); } @@ -993,7 +993,7 @@ protected function assertNormalizationEdgeCases($method, Url $url, array $reques // DX: 400 when no entity type bundle is specified. $response = $this->request($method, $url, $request_options); // @todo use this commented line instead of the 3 lines thereafter once https://www.drupal.org/node/2813853 lands. -// $this->assertResourceErrorResponse(400, 'A string must be provided as a bundle value.', $response); + // $this->assertResourceErrorResponse(400, 'A string must be provided as a bundle value.', $response); $this->assertSame(400, $response->getStatusCode()); $this->assertSame([static::$mimeType], $response->getHeader('Content-Type')); $this->assertSame($this->serializer->encode(['error' => 'A string must be provided as a bundle value.'], static::$format), (string) $response->getBody()); diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Node/NodeJsonBasicAuthTest.php b/core/modules/rest/tests/src/Functional/EntityResource/Node/NodeJsonBasicAuthTest.php index f79776e..b71d1d5 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/Node/NodeJsonBasicAuthTest.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/Node/NodeJsonBasicAuthTest.php @@ -4,7 +4,6 @@ use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait; use Drupal\Tests\rest\Functional\JsonBasicAuthWorkaroundFor2805281Trait; -use Psr\Http\Message\ResponseInterface; /** * @group rest diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Role/RoleJsonCookieTest.php b/core/modules/rest/tests/src/Functional/EntityResource/Role/RoleJsonCookieTest.php index 3aa4149..9f4ec07 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/Role/RoleJsonCookieTest.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/Role/RoleJsonCookieTest.php @@ -2,9 +2,7 @@ namespace Drupal\Tests\rest\Functional\EntityResource\Role; -use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait; use Drupal\Tests\rest\Functional\CookieResourceTestTrait; -use Psr\Http\Message\ResponseInterface; /** * @group rest 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 6a405a9..ee719c4 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/Role/RoleResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/Role/RoleResourceTestBase.php @@ -4,7 +4,6 @@ use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase; use Drupal\user\Entity\Role; -use Drupal\user\RoleInterface; abstract class RoleResourceTestBase extends EntityResourceTestBase { 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 195e1ad..31cf083 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/User/UserResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/User/UserResourceTestBase.php @@ -164,7 +164,7 @@ public function testPatchDxForSecuritySensitiveBaseFields() { // DX: 422 when changing email without providing the password. $response = $this->request('PATCH', $url, $request_options); // @todo use this commented line instead of the 3 lines thereafter once https://www.drupal.org/node/2813755 lands. -// $this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\nmail: Your current password is missing or incorrect; it's required to change the Email.\n", $response); + // $this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\nmail: Your current password is missing or incorrect; it's required to change the Email.\n", $response); $this->assertSame(422, $response->getStatusCode()); $this->assertSame([static::$mimeType], $response->getHeader('Content-Type')); $this->assertSame($this->serializer->encode(['message' => "Unprocessable Entity: validation failed.\nmail: Your current password is missing or incorrect; it's required to change the Email.\n"], static::$format), (string) $response->getBody()); @@ -176,7 +176,7 @@ public function testPatchDxForSecuritySensitiveBaseFields() { // DX: 422 when changing email while providing a wrong password. $response = $this->request('PATCH', $url, $request_options); // @todo use this commented line instead of the 3 lines thereafter once https://www.drupal.org/node/2813755 lands. -// $this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\nmail: Your current password is missing or incorrect; it's required to change the Email.\n", $response); + // $this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\nmail: Your current password is missing or incorrect; it's required to change the Email.\n", $response); $this->assertSame(422, $response->getStatusCode()); $this->assertSame([static::$mimeType], $response->getHeader('Content-Type')); $this->assertSame($this->serializer->encode(['message' => "Unprocessable Entity: validation failed.\nmail: Your current password is missing or incorrect; it's required to change the Email.\n"], static::$format), (string) $response->getBody()); @@ -201,7 +201,7 @@ public function testPatchDxForSecuritySensitiveBaseFields() { // DX: 422 when changing password without providing the current password. $response = $this->request('PATCH', $url, $request_options); // @todo use this commented line instead of the 3 lines thereafter once https://www.drupal.org/node/2813755 lands. -// $this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\npass: Your current password is missing or incorrect; it's required to change the Password.\n", $response); + // $this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\npass: Your current password is missing or incorrect; it's required to change the Password.\n", $response); $this->assertSame(422, $response->getStatusCode()); $this->assertSame([static::$mimeType], $response->getHeader('Content-Type')); $this->assertSame($this->serializer->encode(['message' => "Unprocessable Entity: validation failed.\npass: Your current password is missing or incorrect; it's required to change the Password.\n"], static::$format), (string) $response->getBody()); diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Vocabulary/VocabularyResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/Vocabulary/VocabularyResourceTestBase.php index 47ea86c..abada74 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/Vocabulary/VocabularyResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/Vocabulary/VocabularyResourceTestBase.php @@ -4,9 +4,6 @@ use Drupal\taxonomy\Entity\Vocabulary; use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase; -use Drupal\user\Entity\Role; -use Drupal\user\Entity\User; -use Drupal\user\RoleInterface; abstract class VocabularyResourceTestBase extends EntityResourceTestBase { diff --git a/core/modules/rest/tests/src/Functional/ResourceTestBase.php b/core/modules/rest/tests/src/Functional/ResourceTestBase.php index 4822fa1..f1f0458 100644 --- a/core/modules/rest/tests/src/Functional/ResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/ResourceTestBase.php @@ -172,8 +172,6 @@ protected function provisionResource($resource_type, $formats = [], $authenticat * @param string $method * The HTTP method for which to set up authentication. * - * @return void - * * @see ::grantPermissionsToAnonymousRole() * @see ::grantPermissionsToAuthenticatedRole() */ @@ -181,8 +179,6 @@ protected function provisionResource($resource_type, $formats = [], $authenticat /** * Verifies the error response in case of missing authentication. - * - * @return void */ abstract protected function assertResponseWhenMissingAuthentication(ResponseInterface $response);