public function DateRecurFieldItemListTest::testDefaultValues in Recurring Dates Field 3.1.x
Same name and namespace in other branches
- 8.2 tests/src/Kernel/DateRecurFieldItemListTest.php \Drupal\Tests\date_recur\Kernel\DateRecurFieldItemListTest::testDefaultValues()
- 3.x tests/src/Kernel/DateRecurFieldItemListTest.php \Drupal\Tests\date_recur\Kernel\DateRecurFieldItemListTest::testDefaultValues()
- 3.0.x tests/src/Kernel/DateRecurFieldItemListTest.php \Drupal\Tests\date_recur\Kernel\DateRecurFieldItemListTest::testDefaultValues()
Tests default values are available programmatically.
File
- tests/
src/ Kernel/ DateRecurFieldItemListTest.php, line 106
Class
- DateRecurFieldItemListTest
- Tests date_recur field lists.
Namespace
Drupal\Tests\date_recur\KernelCode
public function testDefaultValues() {
$this
->installEntitySchema('dr_entity_test');
$defaultRrule = 'FREQ=WEEKLY;COUNT=995';
/** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entityFieldManager */
$entityFieldManager = \Drupal::service('entity_field.manager');
$baseFields = $entityFieldManager
->getBaseFieldDefinitions('dr_entity_test');
$baseFieldOverride = BaseFieldOverride::createFromBaseFieldDefinition($baseFields['dr'], 'dr_entity_test');
$baseFieldOverride
->setDefaultValue([
[
'default_rrule' => $defaultRrule,
],
]);
$baseFieldOverride
->save();
$entity = DrEntityTest::create();
$this
->assertEquals($defaultRrule, $entity->dr->rrule);
}