function FieldKernelTestBase::entityValidateAndSave
Same name and namespace in other branches
- 11.x core/modules/field/tests/src/Kernel/FieldKernelTestBase.php \Drupal\Tests\field\Kernel\FieldKernelTestBase::entityValidateAndSave()
Validate and save entity. Fail if violations are found.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity to save.
9 calls to FieldKernelTestBase::entityValidateAndSave()
- BooleanItemTest::testBooleanItem in core/
modules/ field/ tests/ src/ Kernel/ Boolean/ BooleanItemTest.php - Tests using entity fields of the boolean field type.
- EmailItemTest::testEmailItem in core/
modules/ field/ tests/ src/ Kernel/ Email/ EmailItemTest.php - Tests using entity fields of the email field type.
- EntityReferenceItemTest::testContentEntityReferenceItem in core/
modules/ field/ tests/ src/ Kernel/ EntityReference/ EntityReferenceItemTest.php - Tests the entity reference field type for referencing content entities.
- EntityReferenceItemTest::testGenerateSampleValue in core/
modules/ field/ tests/ src/ Kernel/ EntityReference/ EntityReferenceItemTest.php - Tests the ::generateSampleValue() method.
- FileItemTest::testFileItem in core/
modules/ file/ tests/ src/ Kernel/ FileItemTest.php - Tests using entity fields of the file field type.
File
-
core/
modules/ field/ tests/ src/ Kernel/ FieldKernelTestBase.php, line 156
Class
- FieldKernelTestBase
- Parent class for Field API unit tests.
Namespace
Drupal\Tests\field\KernelCode
protected function entityValidateAndSave(EntityInterface $entity) {
$violations = $entity->validate();
if ($violations->count()) {
$this->fail($violations);
}
else {
$entity->save();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.