diff --git a/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php b/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php
index 7ee1e85..d6c3498 100644
--- a/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php
@@ -43,7 +43,7 @@ function testMultiStepNodeFormBasicOptions() {
'type' => 'text',
'cardinality' => -1,
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
// Attach an instance of the field to the page content type.
$this->instance = array(
@@ -63,7 +63,7 @@ function testMultiStepNodeFormBasicOptions() {
),
),
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
$langcode = LANGUAGE_NOT_SPECIFIED;
$edit = array(
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php
index 0db0bda..96bda75 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php
@@ -38,13 +38,15 @@ public function setUp() {
// Add a custom field to the page content type.
$this->field_name = drupal_strtolower($this->randomName() . '_field_name');
- $this->field = field_create_field(array('field_name' => $this->field_name, 'type' => 'text'));
+ $this->field = entity_create('field_entity', array('field_name' => $this->field_name, 'type' => 'text'));
+ $this->field->save();
$instance = array(
'field_name' => $this->field_name,
'entity_type' => 'node',
'bundle' => 'page',
);
- $this->instance = field_create_instance($instance);
+ $this->instance = entity_create('field_instance', $instance);
+ $this->instance->save();
entity_get_display('node', 'page', 'default')
->setComponent($this->field_name)
->save();
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php
index 930bdf3..3d1b617 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php
@@ -61,7 +61,7 @@ function setUp() {
// Make node body translatable.
$field = field_info_field('body');
$field['translatable'] = TRUE;
- field_update_field($field);
+ $field->save();
}
/**
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php
index 3632867..cceee63 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php
@@ -169,7 +169,7 @@ function testFieldTranslationForm() {
$this->assertRaw('Not translated');
// Delete the only translatable field.
- field_delete_field('field_test_et_ui_test');
+ field_info_field('field_test_et_ui_test')->delete();
// Visit translation page.
$this->drupalGet('node/' . $article->nid . '/translations');
diff --git a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
index 28b04cd..5badf96 100644
--- a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
@@ -71,7 +71,7 @@ function setUp() {
)
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'field_name' => $this->field_name,
'entity_type' => 'node',
@@ -89,7 +89,7 @@ function setUp() {
),
),
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
}
/**
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 9bd3087..26b687e 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -581,7 +581,8 @@ function node_add_body_field($type, $label = 'Body') {
'type' => 'text_with_summary',
'entity_types' => array('node'),
);
- $field = field_create_field($field);
+ $field = entity_create('field_entity', $field);
+ $field->save();
}
if (empty($instance)) {
$instance = array(
@@ -592,7 +593,8 @@ function node_add_body_field($type, $label = 'Body') {
'widget' => array('type' => 'text_textarea_with_summary'),
'settings' => array('display_summary' => TRUE),
);
- $instance = field_create_instance($instance);
+ $instance = entity_create('field_instance', $instance);
+ $instance->save();
// Assign display settings for the 'default' and 'teaser' view modes.
entity_get_display('node', $type->type, 'default')
diff --git a/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module b/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module
index 3d67454..b3db641 100644
--- a/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module
+++ b/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module
@@ -58,7 +58,8 @@ function node_access_test_language_enable() {
'allowed_values' => array(0 => 'Not private', 1 => 'Private'),
),
);
- $field_private = field_create_field($field_private);
+ $field_private = entity_create('field_entity', $field_private);
+ $field_private->save();
$instance = array(
'field_name' => $field_private['field_name'],
@@ -68,12 +69,13 @@ function node_access_test_language_enable() {
'type' => 'options_buttons',
),
);
- $instance = field_create_instance($instance);
+ $instance = entity_create('field_instance', $instance);
+ $instance->save();
}
/**
* Implements hook_disable().
*/
function node_access_test_language_disable() {
- field_delete_instance(field_read_instance('node', 'field_private', 'page'));
+ field_read_instance('node', 'field_private', 'page')->delete();
}
diff --git a/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
index aa6c06e..b3d99b9 100644
--- a/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
+++ b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
@@ -52,7 +52,7 @@ function testNumberDecimalField() {
'precision' => 8, 'scale' => 4, 'decimal_separator' => '.',
)
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'field_name' => $this->field['field_name'],
'entity_type' => 'test_entity',
@@ -64,7 +64,7 @@ function testNumberDecimalField() {
),
),
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
entity_get_display('test_entity', 'test_bundle', 'default')
->setComponent($this->field['field_name'])
->save();
diff --git a/core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php b/core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php
index a0fc778..fde2223 100644
--- a/core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php
+++ b/core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php
@@ -40,7 +40,7 @@ public function setUp() {
'field_name' => 'field_' . $type,
'type' => 'number_' . $type,
);
- field_create_field($this->field[$type]);
+ entity_create('field_entity', $this->field[$type])->save();
$this->instance[$type] = array(
'entity_type' => 'entity_test',
'field_name' => 'field_' . $type,
@@ -49,7 +49,7 @@ public function setUp() {
'type' => 'number',
),
);
- field_create_instance($this->instance[$type]);
+ entity_create('field_instance', $this->instance[$type])->save();
}
}
diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php
index 4065b7d..33bd543 100644
--- a/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php
+++ b/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php
@@ -33,7 +33,8 @@ function setUp() {
'allowed_values_function' => 'options_test_dynamic_values_callback',
),
);
- $this->field = field_create_field($this->field);
+ $this->field = entity_create('field_entity', $this->field);
+ $this->field->save();
$this->instance = array(
'field_name' => $this->field_name,
@@ -44,7 +45,8 @@ function setUp() {
'type' => 'options_select',
),
);
- $this->instance = field_create_instance($this->instance);
+ $this->instance = entity_create('field_instance', $this->instance);
+ $this->instance->save();
$this->test = array(
'id' => mt_rand(1, 10),
// Make sure this does not equal the ID so that
diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php
index 11ab663..4f84577 100644
--- a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php
+++ b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php
@@ -44,7 +44,8 @@ function setUp() {
'allowed_values' => array(1 => 'One', 2 => 'Two', 3 => 'Three'),
),
);
- $this->field = field_create_field($this->field_definition);
+ $this->field = entity_create('field_entity', $this->field_definition);
+ $this->field->save();
$this->instance = array(
'field_name' => $this->field_name,
@@ -54,7 +55,8 @@ function setUp() {
'type' => 'options_buttons',
),
);
- $this->instance = field_create_instance($this->instance);
+ $this->instance = entity_create('field_instance', $this->instance);
+ $this->instance->save();
}
/**
@@ -77,7 +79,7 @@ function testUpdateAllowedValues() {
$entity->save();
$this->field['settings']['allowed_values'] = array(2 => 'Two');
try {
- field_update_field($this->field);
+ $this->field->save();
$this->fail(t('Cannot update a list field to not include keys with existing data.'));
}
catch (FieldException $e) {
@@ -89,7 +91,7 @@ function testUpdateAllowedValues() {
// Removed options do not appear.
$this->field['settings']['allowed_values'] = array(2 => 'Two');
- field_update_field($this->field);
+ $this->field->save();
$entity = entity_create('entity_test', array());
$form = entity_get_form($entity);
$this->assertTrue(empty($form[$this->field_name][$langcode][1]), 'Option 1 does not exist');
@@ -98,7 +100,7 @@ function testUpdateAllowedValues() {
// Completely new options appear.
$this->field['settings']['allowed_values'] = array(10 => 'Update', 20 => 'Twenty');
- field_update_field($this->field);
+ $this->field->save();
$form = entity_get_form($entity);
$this->assertTrue(empty($form[$this->field_name][$langcode][1]), 'Option 1 does not exist');
$this->assertTrue(empty($form[$this->field_name][$langcode][2]), 'Option 2 does not exist');
@@ -107,9 +109,8 @@ function testUpdateAllowedValues() {
$this->assertTrue(!empty($form[$this->field_name][$langcode][20]), 'Option 20 exists');
// Options are reset when a new field with the same name is created.
- field_delete_field($this->field_name);
- unset($this->field['id']);
- field_create_field($this->field_definition);
+ $this->field->delete();
+ entity_create('field_entity', $this->field_definition)->save();
$this->instance = array(
'field_name' => $this->field_name,
'entity_type' => 'entity_test',
@@ -118,7 +119,7 @@ function testUpdateAllowedValues() {
'type' => 'options_buttons',
),
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
$entity = entity_create('entity_test', array());
$form = entity_get_form($entity);
$this->assertTrue(!empty($form[$this->field_name][$langcode][1]), 'Option 1 exists');
diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php
index 11f6035..cde3058 100644
--- a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php
+++ b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php
@@ -258,13 +258,13 @@ protected function createOptionsField($type) {
'field_name' => $this->field_name,
'type' => $type,
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => $this->field_name,
'entity_type' => 'node',
'bundle' => $this->type,
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
$this->admin_path = 'admin/structure/types/manage/' . $this->type . '/fields/' . $this->field_name . '/field-settings';
}
diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php
index 023f012..358ef0b 100644
--- a/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php
+++ b/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php
@@ -33,7 +33,7 @@ function setUp() {
parent::setUp();
// Field with cardinality 1.
- $this->card_1 = array(
+ $this->card_1 = entity_create('field_entity', array(
'field_name' => 'card_1',
'type' => 'list_integer',
'cardinality' => 1,
@@ -41,11 +41,11 @@ function setUp() {
// Make sure that 0 works as an option.
'allowed_values' => array(0 => 'Zero', 1 => 'One', 2 => 'Some & unescaped markup'),
),
- );
- $this->card_1 = field_create_field($this->card_1);
+ ));
+ $this->card_1->save();
// Field with cardinality 2.
- $this->card_2 = array(
+ $this->card_2 = entity_create('field_entity', array(
'field_name' => 'card_2',
'type' => 'list_integer',
'cardinality' => 2,
@@ -53,11 +53,11 @@ function setUp() {
// Make sure that 0 works as an option.
'allowed_values' => array(0 => 'Zero', 1 => 'One', 2 => 'Some & unescaped markup'),
),
- );
- $this->card_2 = field_create_field($this->card_2);
+ ));
+ $this->card_2->save();
// Boolean field.
- $this->bool = array(
+ $this->bool = entity_create('field_entity', array(
'field_name' => 'bool',
'type' => 'list_boolean',
'cardinality' => 1,
@@ -65,8 +65,8 @@ function setUp() {
// Make sure that 0 works as a 'on' value'.
'allowed_values' => array(1 => 'Zero', 0 => 'Some & unescaped markup'),
),
- );
- $this->bool = field_create_field($this->bool);
+ ));
+ $this->bool->save();
// Create a web user.
$this->web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content'));
@@ -78,15 +78,15 @@ function setUp() {
*/
function testRadioButtons() {
// Create an instance of the 'single value' field.
- $instance = array(
+ $instance = entity_create('field_instance', array(
'field_name' => $this->card_1['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'widget' => array(
'type' => 'options_buttons',
),
- );
- $instance = field_create_instance($instance);
+ ));
+ $instance->save();
$langcode = LANGUAGE_NOT_SPECIFIED;
// Create an entity.
@@ -120,9 +120,9 @@ function testRadioButtons() {
// Check that required radios with one option is auto-selected.
$this->card_1['settings']['allowed_values'] = array(99 => 'Only allowed value');
- field_update_field($this->card_1);
+ $this->card_1->save();
$instance['required'] = TRUE;
- field_update_instance($instance);
+ $instance->save();
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
$this->assertFieldChecked("edit-card-1-$langcode-99");
}
@@ -132,15 +132,15 @@ function testRadioButtons() {
*/
function testCheckBoxes() {
// Create an instance of the 'multiple values' field.
- $instance = array(
+ $instance = entity_create('field_instance', array(
'field_name' => $this->card_2['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'widget' => array(
'type' => 'options_buttons',
),
- );
- $instance = field_create_instance($instance);
+ ));
+ $instance->save();
$langcode = LANGUAGE_NOT_SPECIFIED;
// Create an entity.
@@ -207,9 +207,9 @@ function testCheckBoxes() {
// Required checkbox with one option is auto-selected.
$this->card_2['settings']['allowed_values'] = array(99 => 'Only allowed value');
- field_update_field($this->card_2);
+ $this->card_2->save();
$instance['required'] = TRUE;
- field_update_instance($instance);
+ $instance->save();
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
$this->assertFieldChecked("edit-card-2-$langcode-99");
}
@@ -219,7 +219,7 @@ function testCheckBoxes() {
*/
function testSelectListSingle() {
// Create an instance of the 'single value' field.
- $instance = array(
+ $instance = entity_create('field_instance', array(
'field_name' => $this->card_1['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
@@ -227,8 +227,8 @@ function testSelectListSingle() {
'widget' => array(
'type' => 'options_select',
),
- );
- $instance = field_create_instance($instance);
+ ));
+ $instance->save();
$langcode = LANGUAGE_NOT_SPECIFIED;
// Create an entity.
@@ -269,7 +269,7 @@ function testSelectListSingle() {
// Make the field non required.
$instance['required'] = FALSE;
- field_update_instance($instance);
+ $instance->save();
// Display form.
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
@@ -284,7 +284,7 @@ function testSelectListSingle() {
$this->card_1['settings']['allowed_values'] = array();
$this->card_1['settings']['allowed_values_function'] = 'options_test_allowed_values_callback';
- field_update_field($this->card_1);
+ $this->card_1->save();
// Display form: with no field data, nothing is selected
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
@@ -316,15 +316,15 @@ function testSelectListSingle() {
*/
function testSelectListMultiple() {
// Create an instance of the 'multiple values' field.
- $instance = array(
+ $instance = entity_create('field_instance', array(
'field_name' => $this->card_2['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'widget' => array(
'type' => 'options_select',
),
- );
- $instance = field_create_instance($instance);
+ ));
+ $instance->save();
$langcode = LANGUAGE_NOT_SPECIFIED;
// Create an entity.
@@ -387,7 +387,7 @@ function testSelectListMultiple() {
// A required select list does not have an empty key.
$instance['required'] = TRUE;
- field_update_instance($instance);
+ $instance->save();
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
$this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-2-' . $langcode)), 'A required select list does not have an empty key.');
@@ -399,9 +399,9 @@ function testSelectListMultiple() {
// Use a callback function defining optgroups.
$this->card_2['settings']['allowed_values'] = array();
$this->card_2['settings']['allowed_values_function'] = 'options_test_allowed_values_callback';
- field_update_field($this->card_2);
+ $this->card_2->save();
$instance['required'] = FALSE;
- field_update_instance($instance);
+ $instance->save();
// Display form: with no field data, nothing is selected.
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
@@ -433,15 +433,14 @@ function testSelectListMultiple() {
*/
function testOnOffCheckbox() {
// Create an instance of the 'boolean' field.
- $instance = array(
+ entity_create('field_instance', array(
'field_name' => $this->bool['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'widget' => array(
'type' => 'options_onoff',
),
- );
- $instance = field_create_instance($instance);
+ ))->save();
$langcode = LANGUAGE_NOT_SPECIFIED;
// Create an entity.
@@ -483,8 +482,8 @@ function testOnOffCheckbox() {
// Create a test field instance.
$fieldUpdate = $this->bool;
$fieldUpdate['settings']['allowed_values'] = array(0 => 0, 1 => 'MyOnValue');
- field_update_field($fieldUpdate);
- $instance = array(
+ $fieldUpdate->save();
+ entity_create('field_instance', array(
'field_name' => $this->bool['field_name'],
'entity_type' => 'node',
'bundle' => 'page',
@@ -492,8 +491,7 @@ function testOnOffCheckbox() {
'type' => 'options_onoff',
'module' => 'options',
),
- );
- field_create_instance($instance);
+ ))->save();
// Go to the edit page and check if the default settings works as expected
$fieldEditUrl = 'admin/structure/types/manage/page/fields/bool';
diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php
index 6f99dae..21f28df 100644
--- a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php
+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php
@@ -110,13 +110,13 @@ function testAttributesInMarkupFile() {
'field_name' => $field_name,
'type' => 'file',
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => $bundle_name,
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
entity_get_display('node', $bundle_name, 'teaser')
->setComponent($field_name, array(
'type' => 'file_default',