diff -u b/core/modules/rest/src/Tests/UpdateTest.php b/core/modules/rest/src/Tests/UpdateTest.php --- b/core/modules/rest/src/Tests/UpdateTest.php +++ b/core/modules/rest/src/Tests/UpdateTest.php @@ -54,7 +54,7 @@ $patch_entity = entity_create($entity_type, $patch_values); // We don't want to overwrite the UUID. unset($patch_entity->uuid); - // We don't want to overwrite the changed time. + // We cannot overwrite the changed time. unset($patch_entity->changed); $serialized = $serializer->serialize($patch_entity, $this->defaultFormat, $context); @@ -147,6 +147,8 @@ // Try to send invalid data to trigger the entity validation constraints. // Send a UUID that is too long. $entity->set('uuid', $this->randomMachineName(129)); + // We cannot overwrite the changed time. + unset($entity->changed); $invalid_serialized = $serializer->serialize($entity, $this->defaultFormat, $context); $response = $this->httpRequest($entity->urlInfo(), 'PATCH', $invalid_serialized, $this->defaultMimeType); $this->assertResponse(422); reverted: --- b/core/modules/system/src/Tests/Entity/EntityChangedConstraintValidatorTest.php +++ /dev/null @@ -1,64 +0,0 @@ -typedData = $this->container->get('typed_data_manager'); - } - - /** - * Tests the EntityChangedConstraintValidator. - */ - public function testValidation() { - // Test the validation. - $account = $this->createUser(); - $entity_test = entity_create('entity_test', array('user_id' => $account->id())); - - $entity_test->save(); - $violations = $entity_test->changed->validate(); - $this->assertEqual($violations->count(), 0, 'Validation passed for correct value.'); - // Set a changed date in the future. - $entity_test->set('changed', REQUEST_TIME + 100000); - // Run validation on the changed field. - $violations = $entity_test->changed->validate(); - $this->assertEqual($violations->count(), 0, 'Validation passed for correct value.'); - - // Test the validation when an invalid value is passed. - // Set a changed date in the past. - $entity_test->set('changed', 433918800); - // Run validation on the changed field. - $violations = $entity_test->changed->validate(); - $this->assertEqual($violations->count(), 1, 'Validation failed for incorrect value.'); - - // Make sure the information provided by a violation is correct. - $violation = $violations[0]; - // The property path is 0 as the validator is being run on the field. - $this->assertEqual($violation->getPropertyPath(), '0'); - $this->assertEqual($violation->getMessage(), t('The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved.')); - } -} only in patch2: unchanged: --- a/core/modules/rest/src/Tests/CreateTest.php +++ b/core/modules/rest/src/Tests/CreateTest.php @@ -58,7 +58,8 @@ public function testCreateResourceRestApiNotEnabled() { // Populate some entity properties before create the entity. $entity_values = $this->entityValues($entity_type); $entity = EntityTest::create($entity_values); - + // We cannot overwrite the changed time. + unset($entity->changed); // Serialize the entity before the POST request. $serialized = $this->serializer->serialize($entity, $this->defaultFormat, ['account' => $account]); only in patch2: unchanged: --- a/core/modules/rest/src/Tests/CsrfTest.php +++ b/core/modules/rest/src/Tests/CsrfTest.php @@ -54,6 +54,8 @@ protected function setUp() { $serializer = $this->container->get('serializer'); $entity_values = $this->entityValues($this->testEntityType); $entity = entity_create($this->testEntityType, $entity_values); + // We cannot overwrite the changed time. + unset($entity->changed); $this->serialized = $serializer->serialize($entity, $this->defaultFormat); }