X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Frest%2Ftests%2Fsrc%2FFunctional%2FEntityResource%2FComment%2FCommentResourceTestBase.php;fp=web%2Fcore%2Fmodules%2Frest%2Ftests%2Fsrc%2FFunctional%2FEntityResource%2FComment%2FCommentResourceTestBase.php;h=bade2a76c695869793daa7751799fa520b277622;hp=43a0e3d05e89efbad39874066d076acb9a27c669;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5
diff --git a/web/core/modules/rest/tests/src/Functional/EntityResource/Comment/CommentResourceTestBase.php b/web/core/modules/rest/tests/src/Functional/EntityResource/Comment/CommentResourceTestBase.php
index 43a0e3d05..bade2a76c 100644
--- a/web/core/modules/rest/tests/src/Functional/EntityResource/Comment/CommentResourceTestBase.php
+++ b/web/core/modules/rest/tests/src/Functional/EntityResource/Comment/CommentResourceTestBase.php
@@ -6,13 +6,14 @@ use Drupal\comment\Entity\Comment;
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;
+ use CommentTestTrait, BcTimestampNormalizerUnixTestTrait;
/**
* {@inheritdoc}
@@ -148,14 +149,10 @@ abstract class CommentResourceTestBase extends EntityResourceTestBase {
],
],
'created' => [
- [
- 'value' => 123456789,
- ],
+ $this->formatExpectedTimestampItemValues(123456789),
],
'changed' => [
- [
- 'value' => $this->entity->getChangedTime(),
- ],
+ $this->formatExpectedTimestampItemValues($this->entity->getChangedTime()),
],
'default_langcode' => [
[
@@ -222,7 +219,7 @@ abstract class CommentResourceTestBase extends EntityResourceTestBase {
],
'entity_id' => [
[
- 'target_id' => EntityTest::load(1)->id(),
+ 'target_id' => (int) EntityTest::load(1)->id(),
],
],
'field_name' => [
@@ -280,9 +277,9 @@ abstract class CommentResourceTestBase extends EntityResourceTestBase {
$response = $this->request('POST', $url, $request_options);
// @todo Uncomment, remove next 3 lines in https://www.drupal.org/node/2820364.
$this->assertSame(500, $response->getStatusCode());
- $this->assertSame(['application/json'], $response->getHeader('Content-Type'));
- $this->assertSame('{"message":"A fatal error occurred: Internal Server Error"}', (string) $response->getBody());
- //$this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\nentity_type: This value should not be null.\n", $response);
+ $this->assertSame(['text/plain; charset=UTF-8'], $response->getHeader('Content-Type'));
+ $this->assertStringStartsWith('The website encountered an unexpected error. Please try again later.Symfony\Component\HttpKernel\Exception\HttpException: Internal Server Error in Drupal\rest\Plugin\rest\resource\EntityResource->post()', (string) $response->getBody());
+ // $this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\nentity_type: This value should not be null.\n", $response);
// DX: 422 when missing 'entity_id' field.
$request_options[RequestOptions::BODY] = $this->serializer->encode(array_diff_key($this->getNormalizedPostEntity(), ['entity_id' => TRUE]), static::$format);
@@ -291,23 +288,22 @@ abstract class CommentResourceTestBase extends EntityResourceTestBase {
try {
$response = $this->request('POST', $url, $request_options);
// This happens on DrupalCI.
- //$this->assertSame(500, $response->getStatusCode());
+ // $this->assertSame(500, $response->getStatusCode());
}
catch (\Exception $e) {
// This happens on Wim's local machine.
- //$this->assertSame("Error: Call to a member function get() on null\nDrupal\\comment\\Plugin\\Validation\\Constraint\\CommentNameConstraintValidator->getAnonymousContactDetailsSetting()() (Line: 96)\n", $e->getMessage());
+ // $this->assertSame("Error: Call to a member function get() on null\nDrupal\\comment\\Plugin\\Validation\\Constraint\\CommentNameConstraintValidator->getAnonymousContactDetailsSetting()() (Line: 96)\n", $e->getMessage());
}
- //$response = $this->request('POST', $url, $request_options);
- //$this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\nentity_type: This value should not be null.\n", $response);
+ // $response = $this->request('POST', $url, $request_options);
+ // $this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\nentity_type: This value should not be null.\n", $response);
// DX: 422 when missing 'entity_type' field.
$request_options[RequestOptions::BODY] = $this->serializer->encode(array_diff_key($this->getNormalizedPostEntity(), ['field_name' => TRUE]), static::$format);
$response = $this->request('POST', $url, $request_options);
- // @todo Uncomment, remove next 3 lines in https://www.drupal.org/node/2820364.
+ // @todo Uncomment, remove next 2 lines in https://www.drupal.org/node/2820364.
$this->assertSame(500, $response->getStatusCode());
- $this->assertSame(['application/json'], $response->getHeader('Content-Type'));
- $this->assertSame('{"message":"A fatal error occurred: Field is unknown."}', (string) $response->getBody());
- //$this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\nfield_name: This value should not be null.\n", $response);
+ $this->assertSame(['text/plain; charset=UTF-8'], $response->getHeader('Content-Type'));
+ // $this->assertResourceErrorResponse(422, "Unprocessable Entity: validation failed.\nfield_name: This value should not be null.\n", $response);
}
/**