diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityValidationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityValidationTest.php index 1f820bc..7540eda 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityValidationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityValidationTest.php @@ -105,26 +105,34 @@ protected function checkValidation($entity_type) { // Test triggering a fail for each of the constraints specified. $test_entity = clone $entity; $test_entity->uuid->value = $this->randomString(129); - $this->assertEqual($test_entity->validate()->count(), 1, 'Validation failed.'); + $violations = $test_entity->validate(); + $this->assertEqual($violations->count(), 1, 'Validation failed.'); + $this->assertEqual($violations[0]->getMessage(), t('This value is too long. It should have %limit characters or less.', array('%limit' => '128'))); $test_entity = clone $entity; $test_entity->langcode->value = $this->randomString(13); - $this->assertEqual($test_entity->validate()->count(), 1, 'Validation failed.'); + $violations = $test_entity->validate(); + $this->assertEqual($violations->count(), 1, 'Validation failed.'); + $this->assertEqual($violations[0]->getMessage(), t('This value is too long. It should have %limit characters or less.', array('%limit' => '12'))); + $test_entity = clone $entity; $test_entity->type->value = NULL; - $this->assertEqual($test_entity->validate()->count(), 1, 'Validation failed.'); + $violations = $test_entity->validate(); + $this->assertEqual($violations->count(), 1, 'Validation failed.'); + $this->assertEqual($violations[0]->getMessage(), t('This value should not be null.')); $test_entity = clone $entity; $test_entity->name->value = $this->randomString(33); - $this->assertEqual($test_entity->validate()->count(), 1, 'Validation failed.'); + $violations = $test_entity->validate(); + $this->assertEqual($violations->count(), 1, 'Validation failed.'); + $this->assertEqual($violations[0]->getMessage(), t('This value is too long. It should have %limit characters or less.', array('%limit' => '32'))); - // Make sure the violation is correct. + // Make sure the information provided by a violation is correct. $violations = $test_entity->validate(); - $violation = $violations->get(0); + $violation = $violations[0]; $this->assertEqual($violation->getRoot(), $test_entity, 'Violation root is entity.'); $this->assertEqual($violation->getPropertyPath(), 'name.0.value', 'Violation property path is correct.'); - $this->assertEqual($violation->getInvalidValue(), $test_entity->name->value, 'Violation contains invalid value.'); $this->assertEqual($violation->getMessage(), t('This value is too long. It should have %limit characters or less.', array('%limit' => '32'))); }