function FieldKernelTestBase::entityValidateAndSave
Same name in other branches
- 9 core/modules/field/tests/src/Kernel/FieldKernelTestBase.php \Drupal\Tests\field\Kernel\FieldKernelTestBase::entityValidateAndSave()
- 8.9.x core/modules/field/tests/src/Kernel/FieldKernelTestBase.php \Drupal\Tests\field\Kernel\FieldKernelTestBase::entityValidateAndSave()
- 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.
20 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.
- CommentItemTest::testCommentItem in core/
modules/ comment/ tests/ src/ Kernel/ CommentItemTest.php - Tests using entity fields of the comment field type.
- DateTimeItemTest::testDateOnly in core/
modules/ datetime/ tests/ src/ Kernel/ DateTimeItemTest.php - Tests using entity fields of the date field type.
- DateTimeItemTest::testDateOnlyValidation in core/
modules/ datetime/ tests/ src/ Kernel/ DateTimeItemTest.php - Tests the constraint validations for fields with date only.
- DateTimeItemTest::testDateTime in core/
modules/ datetime/ tests/ src/ Kernel/ DateTimeItemTest.php - Tests using entity fields of the datetime field type.
File
-
core/
modules/ field/ tests/ src/ Kernel/ FieldKernelTestBase.php, line 155
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((string) $violations);
}
else {
$entity->save();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.