diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php index e9526d8..f35b254 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php @@ -49,8 +49,8 @@ function setUp() { // Make the body field translatable. // The parent class has already created the article and page content types. $field = field_info_field('body'); - $field['translatable'] = TRUE; - field_update_field($field); + $field->translatable = TRUE; + $field->save(); // Create a few page nodes with multilingual body values. $default_format = filter_default_format(); diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php b/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php index dfbb7ba..48d0293 100644 --- a/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php +++ b/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php @@ -34,22 +34,20 @@ protected function setUp() { parent::setUp(); // Create the test field. - $field = array( + entity_create('field_entity', array( 'settings' => array( 'target_type' => 'entity_test_mulrev', ), 'field_name' => 'field_test_entity_reference', 'type' => 'entity_reference', - ); - field_create_field($field); + ))->save(); // Create the test field instance. - $instance = array( + entity_create('field_instance', array( 'entity_type' => 'entity_test_mulrev', 'field_name' => 'field_test_entity_reference', 'bundle' => 'entity_test_mulrev', - ); - field_create_instance($instance); + ))->save(); } /** diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/NormalizerTestBase.php b/core/modules/serialization/lib/Drupal/serialization/Tests/NormalizerTestBase.php index 1d9bff6..74fa8d9 100644 --- a/core/modules/serialization/lib/Drupal/serialization/Tests/NormalizerTestBase.php +++ b/core/modules/serialization/lib/Drupal/serialization/Tests/NormalizerTestBase.php @@ -26,13 +26,13 @@ protected function setUp() { $this->installConfig(array('field')); // Auto-create a field for testing. - field_create_field(array( + entity_create('field_entity', array( 'field_name' => 'field_test_text', 'type' => 'text', 'cardinality' => 1, 'translatable' => FALSE, - )); - $instance = array( + ))->save(); + entity_create('field_instance', array( 'entity_type' => 'entity_test_mulrev', 'field_name' => 'field_test_text', 'bundle' => 'entity_test_mulrev', @@ -41,7 +41,7 @@ protected function setUp() { 'type' => 'text_textfield', 'weight' => 0, ), - ); - field_create_instance($instance); + ))->save(); } + } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php index b2eed63..4615b39 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php @@ -231,17 +231,16 @@ function testEnableModulesFixedList() { 'bundle' => 'entity_test', 'mode' => 'default', )); - $field = array( + $field = entity_create('field_entity', array( 'field_name' => 'test_field', 'type' => 'test_field' - ); - field_create_field($field); - $instance = array( - 'field_name' => $field['field_name'], + )); + $field->save(); + entity_create('field_instance', array( + 'field_name' => $field->id(), 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - ); - field_create_instance($instance); + ))->save(); } /** diff --git a/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php index d3ba0b7..f15f382 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php @@ -34,18 +34,16 @@ function setUp() { // Create a multi-valued field for 'page' nodes to use for Ajax testing. $field_name = 'field_ajax_test'; - $field = array( + entity_create('field_entity', array( 'field_name' => $field_name, 'type' => 'text', 'cardinality' => FIELD_CARDINALITY_UNLIMITED, - ); - field_create_field($field); - $instance = array( + ))->save(); + entity_create('field_instance', array( 'field_name' => $field_name, 'entity_type' => 'node', 'bundle' => 'page', - ); - field_create_instance($instance); + ))->save(); entity_get_form_display('node', 'page', 'default') ->setComponent($field_name, array('type' => 'text_default')) ->save(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php index 93fc552..4d24a51 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php @@ -598,8 +598,8 @@ public function testComputedProperties() { protected function assertComputedProperties($entity_type) { // Make the test text field processed. $instance = field_info_instance($entity_type, 'field_test_text', $entity_type); - $instance['settings']['text_processing'] = 1; - field_update_instance($instance); + $instance->settings['text_processing'] = 1; + $instance->save(); $entity = $this->createTestEntity($entity_type); $entity->field_test_text->value = "The text text to filter."; diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php index 54c6934..faa7090 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php @@ -60,18 +60,17 @@ public function setUp() { // Add some fieldapi fields to be used in the test. for ($i = 1; $i <= 2; $i++) { - $field = array( - 'field_name' => 'field_test_' . $i, + $field_name = 'field_test_' . $i; + entity_create('field_entity', array( + 'field_name' => $field_name, 'type' => 'number_integer', 'cardinality' => 2, - ); - field_create_field($field); - $instance = array( - 'field_name' => $field['field_name'], + ))->save(); + entity_create('field_instance', array( + 'field_name' => $field_name, 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - ); - field_create_instance($instance); + ))->save(); } $entity = $this->entityStorageController->create(array( diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php index f36fca7..7a40d9b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php @@ -85,14 +85,13 @@ public function setUp() { 'type' => 'taxonomy_term_reference', ); $field['settings']['allowed_values']['vocabulary'] = $vocabulary->id(); - field_create_field($field); + entity_create('field_entity', $field)->save(); // Third, create the instance. - $instance = array( + entity_create('field_instance', array( 'entity_type' => 'entity_test', 'field_name' => $this->fieldName, 'bundle' => 'entity_test', - ); - field_create_instance($instance); + ))->save(); // Create two terms and also two accounts. for ($i = 0; $i <= 1; $i++) { $term = entity_create('taxonomy_term', array( diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php index 8b5b19b..b0e52b2 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php @@ -61,13 +61,13 @@ function setUp() { $figures = drupal_strtolower($this->randomName()); $greetings = drupal_strtolower($this->randomName()); foreach (array($figures => 'shape', $greetings => 'text') as $field_name => $field_type) { - $field = array( + $fields[] = $field = entity_create('field_instance', array( 'field_name' => $field_name, 'type' => $field_type, 'cardinality' => 2, 'translatable' => TRUE, - ); - $fields[] = field_create_field($field); + )); + $field->save(); } $bundles = array(); for ($i = 0; $i < 2; $i++) { @@ -78,12 +78,12 @@ function setUp() { } while ($bundles && strtolower($bundles[0]) >= strtolower($bundle)); entity_test_create_bundle($bundle); foreach ($fields as $field) { - $instance = array( + $instance = entity_create('field_instance', array( 'field_name' => $field['field_name'], 'entity_type' => 'entity_test_mulrev', 'bundle' => $bundle, - ); - field_create_instance($instance); + )); + $instance->save(); } $bundles[] = $bundle; } @@ -410,12 +410,12 @@ protected function testCount() { // can test whether cross entity type fields produce the correct query. $field_name = $this->figures; $bundle = $this->randomName(); - $instance = array( + $instance = entity_create('field_instance', array( 'field_name' => $field_name, 'entity_type' => 'entity_test', 'bundle' => $bundle, - ); - field_create_instance($instance); + )); + $instance->save(); $entity = entity_create('entity_test', array( 'id' => 1, diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php index 2a6e833..6623d3f 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php @@ -105,8 +105,8 @@ function testEntityFormLanguage() { // Make body translatable. $field = field_info_field('body'); - $field['translatable'] = TRUE; - field_update_field($field); + $field->translatable = TRUE; + $field->save(); $field = field_info_field('body'); $this->assertTrue($field['translatable'], 'Field body is translatable.'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php index 919565c..a235add 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php @@ -50,23 +50,21 @@ function setUp() { // Create a translatable test field. $this->field_name = drupal_strtolower($this->randomName() . '_field_name'); - $field = array( + entity_create('field_entity', array( 'field_name' => $this->field_name, 'type' => 'text', 'cardinality' => 4, 'translatable' => TRUE, - ); - field_create_field($field); + ))->save(); $this->field = field_read_field($this->field_name); // Create instance in all entity variations. foreach (entity_test_entity_types() as $entity_type) { - $instance = array( + entity_create('field_instance', array( 'field_name' => $this->field_name, 'entity_type' => $entity_type, 'bundle' => $entity_type, - ); - field_create_instance($instance); + ))->save(); $this->instance[$entity_type] = field_read_instance($entity_type, $this->field_name, $entity_type); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/ArbitraryRebuildTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/ArbitraryRebuildTest.php index f049ac8..ff1bad3 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/ArbitraryRebuildTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/ArbitraryRebuildTest.php @@ -33,15 +33,13 @@ function setUp() { parent::setUp(); // Auto-create a field for testing. - $field = array( + entity_create('field_entity', array( 'field_name' => 'test_multiple', 'type' => 'text', 'cardinality' => -1, 'translatable' => FALSE, - ); - field_create_field($field); - - $instance = array( + ))->save(); + entity_create('field_instance', array( 'entity_type' => 'user', 'field_name' => 'test_multiple', 'bundle' => 'user', @@ -49,8 +47,7 @@ function setUp() { 'settings' => array( 'user_register_form' => TRUE, ), - ); - field_create_instance($instance); + ))->save(); entity_get_form_display('user', 'user', 'default') ->setComponent('test_multiple', array( 'type' => 'text_textfield', diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/RebuildTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/RebuildTest.php index 8e9f649..c580e88 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/RebuildTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/RebuildTest.php @@ -76,13 +76,13 @@ function testPreserveFormActionAfterAJAX() { 'type' => 'text', 'cardinality' => FIELD_CARDINALITY_UNLIMITED, ); - field_create_field($field); + entity_create('field_entity', $field)->save(); $instance = array( 'field_name' => $field_name, 'entity_type' => 'node', 'bundle' => 'page', ); - field_create_instance($instance); + entity_create('field_instance', $instance)->save(); entity_get_form_display('node', 'page', 'default') ->setComponent($field_name, array('type' => 'text_test')) ->save(); diff --git a/core/modules/system/tests/modules/entity_test/entity_test.install b/core/modules/system/tests/modules/entity_test/entity_test.install index f7b8726..d6f1b34 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.install +++ b/core/modules/system/tests/modules/entity_test/entity_test.install @@ -10,13 +10,12 @@ */ function entity_test_install() { // Auto-create a field for testing. - $field = array( + entity_create('field_entity', array( 'field_name' => 'field_test_text', 'type' => 'text', 'cardinality' => 1, 'translatable' => FALSE, - ); - field_create_field($field); + ))->save(); $entity_types = array( 'entity_test', @@ -25,13 +24,12 @@ function entity_test_install() { 'entity_test_mulrev', ); foreach ($entity_types as $entity_type) { - $instance = array( + entity_create('field_instance', array( 'entity_type' => $entity_type, 'field_name' => 'field_test_text', 'bundle' => $entity_type, 'label' => 'Test text-field', - ); - field_create_instance($instance); + ))->save(); entity_get_form_display($entity_type, $entity_type, 'default') ->setComponent('field_test_text', array('type' => 'text_text')) diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php index 8da2c2b..170b8ed 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php @@ -195,34 +195,34 @@ function testRegistrationDefaultValues() { */ function testRegistrationWithUserFields() { // Create a field, and an instance on 'user' entity type. - $field = array( + $field = entity_create('field_entity', array( 'type' => 'test_field', 'field_name' => 'test_user_field', 'cardinality' => 1, - ); - field_create_field($field); - $instance = array( + )); + $field->save(); + $instance = entity_create('field_instance', array( 'field_name' => 'test_user_field', 'entity_type' => 'user', 'label' => 'Some user field', 'bundle' => 'user', 'required' => TRUE, 'settings' => array('user_register_form' => FALSE), - ); - field_create_instance($instance); + )); + $instance->save(); entity_get_form_display('user', 'user', 'default') ->setComponent('test_user_field', array('type' => 'test_field_widget')) ->save(); // Check that the field does not appear on the registration form. $this->drupalGet('user/register'); - $this->assertNoText($instance['label'], 'The field does not appear on user registration form'); + $this->assertNoText($instance->id(), 'The field does not appear on user registration form'); // Have the field appear on the registration form. - $instance['settings']['user_register_form'] = TRUE; - field_update_instance($instance); + $instance->settings['user_register_form'] = TRUE; + $instance->save(); $this->drupalGet('user/register'); - $this->assertText($instance['label'], 'The field appears on user registration form'); + $this->assertText($instance->id(), 'The field appears on user registration form'); // Check that validation errors are correctly reported. $edit = array(); @@ -231,11 +231,11 @@ function testRegistrationWithUserFields() { // Missing input in required field. $edit['test_user_field[und][0][value]'] = ''; $this->drupalPost(NULL, $edit, t('Create new account')); - $this->assertRaw(t('@name field is required.', array('@name' => $instance['label'])), 'Field validation error was correctly reported.'); + $this->assertRaw(t('@name field is required.', array('@name' => $instance->id())), 'Field validation error was correctly reported.'); // Invalid input. $edit['test_user_field[und][0][value]'] = '-1'; $this->drupalPost(NULL, $edit, t('Create new account')); - $this->assertRaw(t('%name does not accept the value -1.', array('%name' => $instance['label'])), 'Field validation error was correctly reported.'); + $this->assertRaw(t('%name does not accept the value -1.', array('%name' => $instance->id())), 'Field validation error was correctly reported.'); // Submit with valid data. $value = rand(1, 255); @@ -247,8 +247,8 @@ function testRegistrationWithUserFields() { $this->assertEqual($new_user->test_user_field->value, $value, 'The field value was correclty saved.'); // Check that the 'add more' button works. - $field['cardinality'] = FIELD_CARDINALITY_UNLIMITED; - field_update_field($field); + $field->cardinality = FIELD_CARDINALITY_UNLIMITED; + $field->save(); foreach (array('js', 'nojs') as $js) { $this->drupalGet('user/register'); // Add two inputs. diff --git a/core/modules/user/user.install b/core/modules/user/user.install index 69d96b6..d445d41 100644 --- a/core/modules/user/user.install +++ b/core/modules/user/user.install @@ -317,7 +317,7 @@ function user_install_picture_field() { 'default_image' => FALSE, ), ); - $field = field_create_field($field); + entity_create('field_entity', $field)->save(); $instance = array( 'field_name' => 'user_picture', @@ -337,7 +337,7 @@ function user_install_picture_field() { 'default_image' => 0, ), ); - field_create_instance($instance); + entity_create('field_instance', $instance)->save(); // Assign form display settings for the 'default' view mode. entity_get_form_display('user', 'user', 'default') diff --git a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php index 9cfdce9..8bcf05b 100644 --- a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php @@ -61,7 +61,7 @@ protected function setUp() { // Setup a field and instance. $this->field_name = drupal_strtolower($this->randomName()); - $this->field = array( + entity_create('field_entity', array( 'field_name' => $this->field_name, 'type' => 'taxonomy_term_reference', 'settings' => array( @@ -72,14 +72,13 @@ protected function setUp() { ), ), ) - ); - field_create_field($this->field); + ))->save(); $this->instance = array( 'field_name' => $this->field_name, 'entity_type' => 'node', 'bundle' => 'page', - ); - field_create_instance($this->instance); + )); + $this->instance->save(); // Create a time in the past for the archive. $time = REQUEST_TIME - 3600; diff --git a/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php b/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php index bb52895..2f870d8 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php @@ -55,7 +55,7 @@ function setUp() { $this->tag_vocabulary->save(); // Create the tag field itself. - $this->tag_field = array( + $this->tag_field = entity_create('field_entity', array( 'field_name' => 'field_views_testing_tags', 'type' => 'taxonomy_term_reference', 'cardinality' => FIELD_CARDINALITY_UNLIMITED, @@ -67,8 +67,8 @@ function setUp() { ), ), ), - ); - field_create_field($this->tag_field); + )); + $this->tag_field->save(); // Create an instance of the tag field on one of the content types, and // configure it to display an autocomplete widget. @@ -77,7 +77,7 @@ function setUp() { 'entity_type' => 'node', 'bundle' => $this->node_type_with_tags->type, ); - field_create_instance($this->tag_instance); + entity_create('field_instance', $this->tag_instance)->save(); entity_get_form_display('node', $this->node_type_with_tags->type, 'default') ->setComponent('field_views_testing_tags', array( @@ -108,7 +108,7 @@ function testTaggedWith() { $node_add_path = 'node/add/' . $this->node_type_with_tags->type; // Create three nodes, with different tags. - $tag_field = $this->tag_field['field_name'] . '[' . Language::LANGCODE_NOT_SPECIFIED . ']'; + $tag_field = $this->tag_field->id() . '[' . Language::LANGCODE_NOT_SPECIFIED . ']'; $edit = array(); $edit['title'] = $node_tag1_title = $this->randomName(); $edit[$tag_field] = 'tag1'; @@ -189,7 +189,7 @@ function testTaggedWithByNodeType() { // "tagged with" form element should not appear for it too. $instance = $this->tag_instance; $instance['bundle'] = $this->node_type_without_tags->type; - field_create_instance($instance); + entity_create('field_instance', $instance)->save(); entity_get_form_display('node', $this->node_type_without_tags->type, 'default') ->setComponent('field_views_testing_tags', array( 'type' => 'taxonomy_autocomplete',