.../EntityResource/EntityResourceTestBase.php | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
index 4b7e779..158385b 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
@@ -310,7 +310,8 @@ public function testPost() {
$unparseable_request_body = '!{>}<';
$parseable_valid_request_body = $this->serializer->encode($this->getNormalizedEntityToCreate(), static::$format);
$parseable_valid_request_body_2 = $this->serializer->encode($this->getNormalizedEntityToCreate(), static::$format);
- $parseable_invalid_request_body = $this->serializer->encode($this->getInvalidNormalizedEntityToCreate(), static::$format);
+ $parseable_invalid_request_body = $this->serializer->encode($this->getInvalidNormalizedEntityToCreate(), static::$format);
+ $parseable_invalid_request_body_2 = $this->serializer->encode($this->getNormalizedEntityToCreate() + ['uuid' => $this->randomMachineName(129)], static::$format);
// The URL and Guzzle request options that will be used in this test. The
// request options will be modified/expanded throughout this test:
@@ -410,7 +411,7 @@ public function testPost() {
$this->setUpAuthorization('POST');
- // DX: 422 when invalid entity.
+ // DX: 422 when invalid entity: multiple values sent for single-value field.
$response = $this->request('POST', $url, $request_options);
$label_field = $this->entity->getEntityType()->hasKey('label') ? $this->entity->getEntityType()->getKey('label') : static::$labelField;
$label_field_capitalized = ucfirst($label_field);
@@ -421,6 +422,18 @@ public function testPost() {
$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());
+ $request_options[RequestOptions::BODY] = $parseable_invalid_request_body_2;
+
+
+ // DX: 422 when invalid entity: UUID field too long.
+ $response = $this->request('POST', $url, $request_options);
+ // @todo use this commented line instead of the 3 lines thereafter once https://www.drupal.org/node/2813755 lands.
+// $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());
+
+
$request_options[RequestOptions::BODY] = $parseable_valid_request_body;