protected function FieldUnitTestBase::entityValidateAndSave in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/field/src/Tests/FieldUnitTestBase.php \Drupal\field\Tests\FieldUnitTestBase::entityValidateAndSave()
Validate and save entity. Fail if violations are found.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity to save.
Return value
void
13 calls to FieldUnitTestBase::entityValidateAndSave()
- BooleanItemTest::testBooleanItem in core/
modules/ field/ src/ Tests/ Boolean/ BooleanItemTest.php - Tests using entity fields of the boolean field type.
- CommentItemTest::testCommentItem in core/
modules/ comment/ src/ Tests/ CommentItemTest.php - Tests using entity fields of the comment field type.
- DateTimeItemTest::testDateTimeItem in core/
modules/ datetime/ src/ Tests/ DateTimeItemTest.php - Tests using entity fields of the date field type.
- EmailItemTest::testEmailItem in core/
modules/ field/ src/ Tests/ Email/ EmailItemTest.php - Tests using entity fields of the email field type.
- EntityReferenceItemTest::testContentEntityReferenceItem in core/
modules/ field/ src/ Tests/ EntityReference/ EntityReferenceItemTest.php - Tests the entity reference field type for referencing content entities.
File
- core/
modules/ field/ src/ Tests/ FieldUnitTestBase.php, line 148 - Contains \Drupal\field\Tests\FieldUnitTestBase.
Class
- FieldUnitTestBase
- Parent class for Field API unit tests.
Namespace
Drupal\field\TestsCode
protected function entityValidateAndSave(EntityInterface $entity) {
$violations = $entity
->validate();
if ($violations
->count()) {
$this
->fail($violations);
}
else {
$entity
->save();
}
}