protected function FieldCrudTest::doFieldValidationTests in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/field/src/Tests/FieldCrudTest.php \Drupal\field\Tests\FieldCrudTest::doFieldValidationTests()
Tests configurable field validation.
See also
field_test_entity_bundle_field_info_alter()
1 call to FieldCrudTest::doFieldValidationTests()
- FieldCrudTest::testCreateField in core/
modules/ field/ src/ Tests/ FieldCrudTest.php - Test the creation of a field.
File
- core/
modules/ field/ src/ Tests/ FieldCrudTest.php, line 293 - Contains \Drupal\field\Tests\FieldCrudTest.
Class
- FieldCrudTest
- Create field entities by attaching fields to entities.
Namespace
Drupal\field\TestsCode
protected function doFieldValidationTests() {
$entity = entity_create('entity_test');
$entity
->set($this->fieldStorage
->getName(), 1);
$violations = $entity
->validate();
$this
->assertEqual(count($violations), 0, 'No violations found when in-range value passed.');
$entity
->set($this->fieldStorage
->getName(), 33);
$violations = $entity
->validate();
$this
->assertEqual(count($violations), 1, 'Violations found when using value outside the range.');
$this
->assertEqual($violations[0]
->getPropertyPath(), $this->fieldStorage
->getName() . '.0.value');
$this
->assertEqual($violations[0]
->getMessage(), t('This value should be %limit or less.', [
'%limit' => 32,
]));
}