diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php index 2e56066..1035212 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php @@ -220,13 +220,13 @@ function testFieldAttachSaveEmptyDataDefaultValue() { $this->createFieldWithInstance('', $entity_type); // Add a default value function. - /// @todo: What's this? - //$this->instance['default_value_function'] = 'field_test_default_value'; + $this->instance['default_value_function'] = 'field_test_default_value'; $this->instance->save(); // Verify that fields are populated with default values. $entity_init = entity_create($entity_type, array('id' => 1, 'revision_id' => 1)); - $this->assertEqual($entity_init->{$this->field_name}->value, 99, 'Default field value correctly populated.'); + $default = field_test_default_value($entity_init, $this->field, $this->instance); + $this->assertEqual($entity_init->{$this->field_name}->getValue(), $default, 'Default field value correctly populated.'); // Insert: Field is NULL. $entity = clone($entity_init); @@ -236,7 +236,7 @@ function testFieldAttachSaveEmptyDataDefaultValue() { $this->assertTrue($entity->{$this->field_name}->isEmpty(), 'Insert: NULL field results in no value saved'); // Verify that prepopulated field values are not overwritten by defaults. - $value = array(array('value' => 99 - mt_rand(1, 127))); + $value = array(array('value' => $default[0]['value'] - mt_rand(1, 127))); $entity = entity_create($entity_type, array('type' => $entity_init->bundle(), $this->field_name => $value)); $this->assertEqual($entity->{$this->field_name}->getValue(), $value, 'Prepopulated field value correctly maintained.'); } diff --git a/core/modules/field/tests/modules/field_test/field_test.field.inc b/core/modules/field/tests/modules/field_test/field_test.field.inc index 1952d8d..3e10d6a 100644 --- a/core/modules/field/tests/modules/field_test/field_test.field.inc +++ b/core/modules/field/tests/modules/field_test/field_test.field.inc @@ -27,27 +27,6 @@ function field_test_field_update_forbid($field, $prior_field) { } /** - * Implements hook_field_load(). - */ -function field_test_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) { - $args = func_get_args(); - field_test_memorize(__FUNCTION__, $args); - - foreach ($items as $id => $item) { - // To keep the test non-intrusive, only act for instances with the - // test_hook_field_load setting explicitly set to TRUE. - if (!empty($instances[$id]['settings']['test_hook_field_load'])) { - foreach ($item as $delta => $value) { - // Don't add anything on empty values. - if ($value) { - $items[$id][$delta]['additional_key'] = 'additional_value'; - } - } - } - } -} - -/** * Sample 'default value' callback. */ function field_test_default_value(EntityInterface $entity, $field, $instance) { diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/field/field_type/TestItem.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/field/field_type/TestItem.php index 7f39177..a22fbab 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/field/field_type/TestItem.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/field/field_type/TestItem.php @@ -30,8 +30,7 @@ * "test_hook_field_load" = FALSE * }, * default_widget = "test_field_widget", - * default_formatter = "field_test_default", - * default_value_function = "field_test_default_value" + * default_formatter = "field_test_default" * ) */ class TestItem extends ConfigFieldItemBase implements PrepareCacheInterface {