diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php index d1a5ac0d0d7b8e002bdacfc4095ac6b4a9510c49..54ff1b81763661bd02492d0da6272abe9fe4fc95 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php @@ -285,6 +285,23 @@ protected function getNormalizedPatchEntity() { return $this->getNormalizedPostEntity(); } + /** + * Gets the second normalized POST entity. + * + * Entity types can have non-sequential IDs, and in that case the second + * entity created for POST testing needs to be able to specify a different ID. + * + * @see ::testPost + * @see ::getNormalizedPostEntity + * + * @return array + * An array structure as returned by ::getNormalizedPostEntity(). + */ + protected function getSecondNormalizedPostEntity() { + // Return the values of the "parent" method by default. + return $this->getNormalizedPostEntity(); + } + /** * Gets the normalized POST entity with random values for its unique fields. * @@ -778,7 +795,7 @@ public function testPost() { // Try with all of the following request bodies. $unparseable_request_body = '!{>}<'; $parseable_valid_request_body = $this->serializer->encode($this->getNormalizedPostEntity(), static::$format); - $parseable_valid_request_body_2 = $this->serializer->encode($this->getNormalizedPostEntity(), static::$format); + $parseable_valid_request_body_2 = $this->serializer->encode($this->getSecondNormalizedPostEntity(), static::$format); $parseable_invalid_request_body = $this->serializer->encode($this->makeNormalizationInvalid($this->getNormalizedPostEntity(), 'label'), static::$format); $parseable_invalid_request_body_2 = $this->serializer->encode($this->getNormalizedPostEntity() + ['uuid' => [$this->randomMachineName(129)]], static::$format); $parseable_invalid_request_body_3 = $this->serializer->encode($this->getNormalizedPostEntity() + ['field_rest_test' => [['value' => $this->randomString()]]], static::$format);