function FieldTestHelper::defaultValue

Same name and namespace in other branches
  1. 11.x core/modules/field/tests/modules/field_test/src/FieldTestHelper.php \Drupal\field_test\FieldTestHelper::defaultValue()

Sample 'default value' callback.

1 call to FieldTestHelper::defaultValue()
FieldAttachStorageTest::testFieldAttachSaveEmptyDataDefaultValue in core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php
Tests insert with empty or NULL fields, with default value.

File

core/modules/field/tests/modules/field_test/src/FieldTestHelper.php, line 36

Class

FieldTestHelper
Helper class for testing fields.

Namespace

Drupal\field_test

Code

public static function defaultValue(FieldableEntityInterface $entity, FieldDefinitionInterface $definition) : array {
  return [
    [
      'value' => 99,
    ],
  ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.