diff --git a/core/modules/datetime_range/src/Plugin/Validation/Constraint/DateRangeStartEndConstraint.php b/core/modules/datetime_range/src/Plugin/Validation/Constraint/DateRangeStartEndConstraint.php index bebdc27..74e8fa3 100644 --- a/core/modules/datetime_range/src/Plugin/Validation/Constraint/DateRangeStartEndConstraint.php +++ b/core/modules/datetime_range/src/Plugin/Validation/Constraint/DateRangeStartEndConstraint.php @@ -19,6 +19,6 @@ class DateRangeStartEndConstraint extends Constraint { * * @var string */ - public $badStartEnd = "The date range end value '@end_value' must equal to or after the start value '@value'"; + public $badStartEnd = "The date range end value '@end_value' must be equal to or after the start value '@value'"; } diff --git a/core/modules/datetime_range/src/Plugin/Validation/Constraint/DateRangeStartEndConstraintValidator.php b/core/modules/datetime_range/src/Plugin/Validation/Constraint/DateRangeStartEndConstraintValidator.php index a1d2ea9..b9ad554 100644 --- a/core/modules/datetime_range/src/Plugin/Validation/Constraint/DateRangeStartEndConstraintValidator.php +++ b/core/modules/datetime_range/src/Plugin/Validation/Constraint/DateRangeStartEndConstraintValidator.php @@ -17,19 +17,15 @@ class DateRangeStartEndConstraintValidator extends ConstraintValidator { public function validate($item, Constraint $constraint) { /* @var $item \Drupal\datetime_range\Plugin\Field\FieldType\DateRangeItem */ if (isset($item)) { - $values = $item->getValue(); - $value = $values['value']; - $end_value = $values['end_value']; + $value = $item->getValue()['value']; + $end_value = $item->getValue()['end_value']; - // Only run this validation when the item has proper start and end date - // objects, which means the values were parsed properly. - if (isset($values['start_date']) && $values['start_date'] instanceof DrupalDateTime && isset($values['end_date']) && $values['end_date'] instanceof DrupalDateTime) { - /** @var \Drupal\Core\Datetime\DrupalDateTime $start_date */ - $start_date = $values['start_date']; - /** @var \Drupal\Core\Datetime\DrupalDateTime $start_date */ - $end_date = $values['end_date']; - - if ($start_date->format('c') < $end_date->format('c')) { + // We cannot get the computed values from the item at this point, so we + // have to use string comparison. This may give false error messages, but + // the format constraints will also fail and provide a proper message for + // the user. + if (is_string($value) && is_string($end_value)) { + if ($value > $end_value) { $this->context->addViolation($constraint->badStartEnd, [ '@value' => $value, '@end_value' => $end_value, diff --git a/core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestAlldayTest.php b/core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestAlldayTest.php index 645f590..f74bc4b 100644 --- a/core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestAlldayTest.php +++ b/core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestAlldayTest.php @@ -3,19 +3,99 @@ namespace Drupal\Tests\datetime_range\Functional\EntityResource\EntityTest; use Drupal\Core\Url; -use Drupal\entity_test\Entity\EntityTest; +use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface; use Drupal\datetime_range\Plugin\Field\FieldType\DateRangeItem; -use Drupal\field\Entity\FieldConfig; -use Drupal\field\Entity\FieldStorageConfig; -use Drupal\Tests\rest\Functional\AnonResourceTestTrait; -use Drupal\Tests\rest\Functional\EntityResource\EntityTest\EntityTestResourceTestBase; -use GuzzleHttp\RequestOptions; /** * Tests the daterange field constraint with 'allday' items. * * @group datetime */ -class EntityTestAlldayTest extends EntityTestResourceTestBase { +class EntityTestAlldayTest extends EntityTestDaterangeTestBase { + + /** + * {@inheritdoc} + */ + protected static $startDateString = '2017-02-28T13:00:00'; + + /** + * {@inheritdoc} + */ + protected static $endDateString = '2017-03-01T12:59:59'; + + /** + * {@inheritdoc} + */ + protected static $datetimeType = DateRangeItem::DATETIME_TYPE_ALLDAY; + + /** + * {@inheritdoc} + */ + protected function assertNormalizationEdgeCases($method, Url $url, array $request_options) { + parent::assertNormalizationEdgeCases($method, $url, $request_options); + + if ($this->entity->getEntityType()->hasKey('bundle')) { + $fieldName = static::$fieldName; + $fieldFormat = DateTimeItemInterface::DATETIME_STORAGE_FORMAT; + + // DX: 422 when date type is incorrect. + + $value = ['2017', '03', '01', '21', '53', '00']; + $end_value = static::$endDateString; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range start value must be a string.\n{$fieldName}.0.value: This value should be of the correct primitive type.\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + $value = static::$startDateString; + $end_value = ['2017', '03', '02', '21', '53', '00']; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range end value must be a string.\n{$fieldName}.0.end_value: This value should be of the correct primitive type.\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + $value = ['2017', '03', '01', '21', '53', '00']; + $end_value = ['2017', '03', '02', '21', '53', '00']; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range start value must be a string.\n{$fieldName}.0: The date range end value must be a string.\n{$fieldName}.0.value: This value should be of the correct primitive type.\n{$fieldName}.0.end_value: This value should be of the correct primitive type.\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + // DX: 422 when date format is incorrect. + + $value = '2017-03-01'; + $end_value = static::$endDateString; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range start value '{$value}' is invalid for the format '{$fieldFormat}'\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + $value = static::$startDateString; + $end_value = '2017-03-02'; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range end value '{$end_value}' is invalid for the format '{$fieldFormat}'\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + $value = '2017-03-01'; + $end_value = '2017-03-02'; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range start value '{$value}' is invalid for the format '{$fieldFormat}'\n{$fieldName}.0: The date range end value '{$end_value}' is invalid for the format '{$fieldFormat}'\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + // DX: 422 when date format is incorrect. + + $value = '2016-13-55T20:02:00'; + $end_value = static::$endDateString; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range start value '{$value}' did not parse properly for the format '{$fieldFormat}'\n{$fieldName}.0.value: This value should be of the correct primitive type.\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + $value = static::$startDateString; + $end_value = '2018-13-56T20:02:00'; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range end value '{$end_value}' did not parse properly for the format '{$fieldFormat}'\n{$fieldName}.0.end_value: This value should be of the correct primitive type.\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + $value = '2016-13-55T20:02:00'; + $end_value = '2018-13-56T20:02:00'; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range start value '{$value}' did not parse properly for the format '{$fieldFormat}'\n{$fieldName}.0: The date range end value '{$end_value}' did not parse properly for the format '{$fieldFormat}'\n{$fieldName}.0.value: This value should be of the correct primitive type.\n{$fieldName}.0.end_value: This value should be of the correct primitive type.\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + // DX: 422 when the end date is before the start date. + + $value = static::$endDateString; + $end_value = static::$startDateString; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range end value '{$end_value}' must be equal to or after the start value '{$value}'\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + } + } } diff --git a/core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestDateonlyTest.php b/core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestDateonlyTest.php index 13bb1d5..72f1e3b 100644 --- a/core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestDateonlyTest.php +++ b/core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestDateonlyTest.php @@ -3,19 +3,99 @@ namespace Drupal\Tests\datetime_range\Functional\EntityResource\EntityTest; use Drupal\Core\Url; -use Drupal\entity_test\Entity\EntityTest; +use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface; use Drupal\datetime_range\Plugin\Field\FieldType\DateRangeItem; -use Drupal\field\Entity\FieldConfig; -use Drupal\field\Entity\FieldStorageConfig; -use Drupal\Tests\rest\Functional\AnonResourceTestTrait; -use Drupal\Tests\rest\Functional\EntityResource\EntityTest\EntityTestResourceTestBase; -use GuzzleHttp\RequestOptions; /** * Tests the daterange field constraint with 'date' items. * * @group datetime */ -class EntityTestDateonlyTest extends EntityTestResourceTestBase { +class EntityTestDateonlyTest extends EntityTestDaterangeTestBase { + + /** + * {@inheritdoc} + */ + protected static $startDateString = '2017-03-01'; + + /** + * {@inheritdoc} + */ + protected static $endDateString = '2017-03-02'; + + /** + * {@inheritdoc} + */ + protected static $datetimeType = DateRangeItem::DATETIME_TYPE_DATE; + + /** + * {@inheritdoc} + */ + protected function assertNormalizationEdgeCases($method, Url $url, array $request_options) { + parent::assertNormalizationEdgeCases($method, $url, $request_options); + + if ($this->entity->getEntityType()->hasKey('bundle')) { + $fieldName = static::$fieldName; + $fieldFormat = DateTimeItemInterface::DATE_STORAGE_FORMAT; + + // DX: 422 when date type is incorrect. + + $value = ['2017', '03', '01']; + $end_value = static::$endDateString; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range start value must be a string.\n{$fieldName}.0.value: This value should be of the correct primitive type.\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + $value = static::$startDateString; + $end_value = ['2017', '03', '02']; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range end value must be a string.\n{$fieldName}.0.end_value: This value should be of the correct primitive type.\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + $value = ['2017', '03', '01']; + $end_value = ['2017', '03', '02']; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range start value must be a string.\n{$fieldName}.0: The date range end value must be a string.\n{$fieldName}.0.value: This value should be of the correct primitive type.\n{$fieldName}.0.end_value: This value should be of the correct primitive type.\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + // DX: 422 when date format is incorrect. + + $value = '2017-03-01T20:02:00'; + $end_value = static::$endDateString; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range start value '{$value}' is invalid for the format '{$fieldFormat}'\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + $value = static::$startDateString; + $end_value = '2017-03-02T20:02:00'; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range end value '{$end_value}' is invalid for the format '{$fieldFormat}'\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + $value = '2017-03-01T20:02:00'; + $end_value = '2017-03-02T20:02:00'; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range start value '{$value}' is invalid for the format '{$fieldFormat}'\n{$fieldName}.0: The date range end value '{$end_value}' is invalid for the format '{$fieldFormat}'\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + // DX: 422 when date format is incorrect. + + $value = '2016-13-55'; + $end_value = static::$endDateString; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range start value '{$value}' did not parse properly for the format '{$fieldFormat}'\n{$fieldName}.0.value: This value should be of the correct primitive type.\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + $value = static::$startDateString; + $end_value = '2018-13-56'; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range end value '{$end_value}' did not parse properly for the format '{$fieldFormat}'\n{$fieldName}.0.end_value: This value should be of the correct primitive type.\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + $value = '2016-13-55'; + $end_value = '2018-13-56'; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range start value '{$value}' did not parse properly for the format '{$fieldFormat}'\n{$fieldName}.0: The date range end value '{$end_value}' did not parse properly for the format '{$fieldFormat}'\n{$fieldName}.0.value: This value should be of the correct primitive type.\n{$fieldName}.0.end_value: This value should be of the correct primitive type.\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + + // DX: 422 when the end date is before the start date. + + $value = static::$endDateString; + $end_value = static::$startDateString; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range end value '{$end_value}' must be equal to or after the start value '{$value}'\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + } + } } diff --git a/core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestDaterangeTest.php b/core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestDaterangeTest.php index 49baf9c..83919ef 100644 --- a/core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestDaterangeTest.php +++ b/core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestDaterangeTest.php @@ -3,131 +3,30 @@ namespace Drupal\Tests\datetime_range\Functional\EntityResource\EntityTest; use Drupal\Core\Url; -use Drupal\entity_test\Entity\EntityTest; use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface; use Drupal\datetime_range\Plugin\Field\FieldType\DateRangeItem; -use Drupal\field\Entity\FieldConfig; -use Drupal\field\Entity\FieldStorageConfig; -use Drupal\Tests\rest\Functional\AnonResourceTestTrait; -use Drupal\Tests\rest\Functional\EntityResource\EntityTest\EntityTestResourceTestBase; -use GuzzleHttp\RequestOptions; /** * Tests the daterange field constraint with 'datetime' items. * * @group datetime */ -class EntityTestDaterangeTest extends EntityTestResourceTestBase { - - use AnonResourceTestTrait; - - /** - * The starting ISO date string to use throughout the test. - * - * @var string - */ - protected static $startDateString = '2017-03-01T20:02:00'; - - /** - * The ending ISO date string to use throughout the test. - * - * @var string - */ - protected static $endDateString = '2017-03-02T20:02:00'; - - /** - * Daterange test field name. - * - * @var string - */ - protected static $fieldName = 'field_daterange'; - - /** - * Daterange field type. - */ - protected static $datetimeType = DateRangeItem::DATETIME_TYPE_DATETIME; - - /** - * {@inheritdoc} - */ - public static $modules = ['datetime', 'datetime_range', 'entity_test']; - - /** - * {@inheritdoc} - */ - public function setUp() { - parent::setUp(); - - // Add daterange field. - FieldStorageConfig::create([ - 'field_name' => static::$fieldName, - 'type' => 'daterange', - 'entity_type' => static::$entityTypeId, - 'settings' => ['datetime_type' => static::$datetimeType], - ]) - ->save(); - - FieldConfig::create([ - 'field_name' => static::$fieldName, - 'entity_type' => static::$entityTypeId, - 'bundle' => $this->entity->bundle(), - ]) - ->save(); - - // Reload entity so that it has the new field. - $this->entity = $this->entityStorage->load($this->entity->id()); - $this->entity->set(static::$fieldName, [ - 'value' => static::$startDateString, - 'end_value' => static::$endDateString, - ]); - $this->entity->save(); - } +class EntityTestDaterangeTest extends EntityTestDaterangeTestBase { /** * {@inheritdoc} */ - protected function createEntity() { - $entity_test = EntityTest::create([ - 'name' => 'Llama', - 'type' => static::$entityTypeId, - static::$fieldName => [ - 'value' => static::$startDateString, - 'end_value' => static::$endDateString, - ], - ]); - $entity_test->setOwnerId(0); - $entity_test->save(); - - return $entity_test; - } + protected static $startDateString = '2017-03-01T20:02:00'; /** * {@inheritdoc} */ - protected function getExpectedNormalizedEntity() { - return parent::getExpectedNormalizedEntity() + [ - static::$fieldName => [ - [ - 'value' => $this->entity->get(static::$fieldName)->value, - 'end_value' => $this->entity->get(static::$fieldName)->end_value, - ], - ], - ]; - } + protected static $endDateString = '2017-03-02T20:02:00'; /** * {@inheritdoc} */ - protected function getNormalizedPostEntity() { - return parent::getNormalizedPostEntity() + [ - static::$fieldName => [ - [ - 'value' => static::$startDateString, - 'end_value' => static::$endDateString, - ], - ], - ]; - } + protected static $datetimeType = DateRangeItem::DATETIME_TYPE_DATETIME; /** * {@inheritdoc} @@ -175,47 +74,28 @@ protected function assertNormalizationEdgeCases($method, Url $url, array $reques // DX: 422 when date format is incorrect. - $value = '2017-13-55T20:02:00'; + $value = '2016-13-55T20:02:00'; $end_value = static::$endDateString; $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range start value '{$value}' did not parse properly for the format '{$fieldFormat}'\n{$fieldName}.0.value: This value should be of the correct primitive type.\n"; $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); $value = static::$startDateString; - $end_value = '2017-13-56T20:02:00'; + $end_value = '2018-13-56T20:02:00'; $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range end value '{$end_value}' did not parse properly for the format '{$fieldFormat}'\n{$fieldName}.0.end_value: This value should be of the correct primitive type.\n"; $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); - $value = '2017-13-55T20:02:00'; - $end_value = '2017-13-56T20:02:00'; + $value = '2016-13-55T20:02:00'; + $end_value = '2018-13-56T20:02:00'; $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range start value '{$value}' did not parse properly for the format '{$fieldFormat}'\n{$fieldName}.0: The date range end value '{$end_value}' did not parse properly for the format '{$fieldFormat}'\n{$fieldName}.0.value: This value should be of the correct primitive type.\n{$fieldName}.0.end_value: This value should be of the correct primitive type.\n"; $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); - } - } - /** - * Performs a REST call to test an edge case. - * - * @param string $method - * HTTP method. - * @param \Drupal\Core\Url $url - * URL to request. - * @param array $request_options - * Request options to apply. - * @var mixed $value - * The test start date value. - * @var mixed $end_value - * The test end date value. - * @var string $message - * The expected error message. - */ - protected function doEdgeCaseCall($method, Url $url, array $request_options, $value, $end_value, $message) { - $normalization = $this->getNormalizedPostEntity(); - $normalization[static::$fieldName][0]['value'] = $value; - $normalization[static::$fieldName][0]['end_value'] = $end_value; - - $request_options[RequestOptions::BODY] = $this->serializer->encode($normalization, static::$format); - $response = $this->request($method, $url, $request_options); - $this->assertResourceErrorResponse(422, $message, $response); + // DX: 422 when the end date is before the start date. + + $value = static::$endDateString; + $end_value = static::$startDateString; + $message = "Unprocessable Entity: validation failed.\n{$fieldName}.0: The date range end value '{$end_value}' must be equal to or after the start value '{$value}'\n"; + $this->doEdgeCaseCall($method, $url, $request_options, $value, $end_value, $message); + } } } diff --git a/core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestDaterangeTestBase.php b/core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestDaterangeTestBase.php new file mode 100644 index 0000000..d989ec4 --- /dev/null +++ b/core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestDaterangeTestBase.php @@ -0,0 +1,163 @@ + static::$fieldName, + 'type' => 'daterange', + 'entity_type' => static::$entityTypeId, + 'settings' => ['datetime_type' => static::$datetimeType], + ]) + ->save(); + + FieldConfig::create([ + 'field_name' => static::$fieldName, + 'entity_type' => static::$entityTypeId, + 'bundle' => $this->entity->bundle(), + ]) + ->save(); + + // Reload entity so that it has the new field. + $this->entity = $this->entityStorage->load($this->entity->id()); + $this->entity->set(static::$fieldName, [ + 'value' => static::$startDateString, + 'end_value' => static::$endDateString, + ]); + $this->entity->save(); + } + + /** + * {@inheritdoc} + */ + protected function createEntity() { + $entity_test = EntityTest::create([ + 'name' => 'Llama', + 'type' => static::$entityTypeId, + static::$fieldName => [ + 'value' => static::$startDateString, + 'end_value' => static::$endDateString, + ], + ]); + $entity_test->setOwnerId(0); + $entity_test->save(); + + return $entity_test; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedNormalizedEntity() { + return parent::getExpectedNormalizedEntity() + [ + static::$fieldName => [ + [ + 'value' => $this->entity->get(static::$fieldName)->value, + 'end_value' => $this->entity->get(static::$fieldName)->end_value, + ], + ], + ]; + } + + /** + * {@inheritdoc} + */ + protected function getNormalizedPostEntity() { + return parent::getNormalizedPostEntity() + [ + static::$fieldName => [ + [ + 'value' => static::$startDateString, + 'end_value' => static::$endDateString, + ], + ], + ]; + } + + /** + * {@inheritdoc} + */ + protected function assertNormalizationEdgeCases($method, Url $url, array $request_options) { + parent::assertNormalizationEdgeCases($method, $url, $request_options); + } + + /** + * Performs a REST call to test an edge case. + * + * @param string $method + * HTTP method. + * @param \Drupal\Core\Url $url + * URL to request. + * @param array $request_options + * Request options to apply. + * @var mixed $value + * The test start date value. + * @var mixed $end_value + * The test end date value. + * @var string $message + * The expected error message. + */ + protected function doEdgeCaseCall($method, Url $url, array $request_options, $value, $end_value, $message) { + $normalization = $this->getNormalizedPostEntity(); + $normalization[static::$fieldName][0]['value'] = $value; + $normalization[static::$fieldName][0]['end_value'] = $end_value; + + $request_options[RequestOptions::BODY] = $this->serializer->encode($normalization, static::$format); + $response = $this->request($method, $url, $request_options); + $this->assertResourceErrorResponse(422, $message, $response); + } + +}