summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2016-02-16 11:13:36 (GMT)
committerNathaniel Catchpole2016-02-16 11:13:36 (GMT)
commit8e4fe5c0f91e1797c83720e880f07c6f94ae1d0d (patch)
tree1fcd0fd7a6d2df6260454400be3bf8c7a9e960a2
parent854649c9238aa79ad17d294e3f2864ce11bc4f83 (diff)
Issue #2641584 by Mac_Weber, heykarthikwithu, legovaer: Replace deprecated usage of entity_create('field_config') with a direct call to FieldConfig::create()
-rw-r--r--core/modules/block_content/block_content.module4
-rw-r--r--core/modules/config/src/Tests/ConfigExportImportUITest.php4
-rw-r--r--core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php5
-rw-r--r--core/modules/contact/src/Tests/Views/ContactFieldsTest.php5
-rw-r--r--core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php5
-rw-r--r--core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php5
-rw-r--r--core/modules/content_translation/src/Tests/ContentTranslationTestBase.php5
-rw-r--r--core/modules/datetime/src/Tests/DateTimeFieldTest.php9
-rw-r--r--core/modules/datetime/src/Tests/DateTimeItemTest.php5
-rw-r--r--core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php3
-rw-r--r--core/modules/field/src/Entity/FieldConfig.php2
-rw-r--r--core/modules/field/src/Tests/Boolean/BooleanItemTest.php5
-rw-r--r--core/modules/field/src/Tests/BulkDeleteTest.php4
-rw-r--r--core/modules/field/src/Tests/DisplayApiTest.php3
-rw-r--r--core/modules/field/src/Tests/Email/EmailFieldTest.php5
-rw-r--r--core/modules/field/src/Tests/Email/EmailItemTest.php5
-rw-r--r--core/modules/field/src/Tests/EntityReference/EntityReferenceAutoCreateTest.php5
-rw-r--r--core/modules/field/src/Tests/EntityReference/EntityReferenceFieldDefaultValueTest.php9
-rw-r--r--core/modules/field/src/Tests/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php5
-rw-r--r--core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php9
-rw-r--r--core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php5
-rw-r--r--core/modules/field/src/Tests/EntityReference/Views/SelectionTest.php5
-rw-r--r--core/modules/field/src/Tests/FieldAccessTest.php3
-rw-r--r--core/modules/field/src/Tests/FieldAttachStorageTest.php10
-rw-r--r--core/modules/field/src/Tests/FieldCrudTest.php26
-rw-r--r--core/modules/field/src/Tests/FieldDataCountTest.php4
-rw-r--r--core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php13
-rw-r--r--core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php9
-rw-r--r--core/modules/field/src/Tests/FieldStorageCrudTest.php12
-rw-r--r--core/modules/field/src/Tests/FieldUnitTestBase.php3
-rw-r--r--core/modules/field/src/Tests/FormTest.php24
-rw-r--r--core/modules/field/src/Tests/NestedFormTest.php5
-rw-r--r--core/modules/field/src/Tests/Number/NumberFieldTest.php29
-rw-r--r--core/modules/field/src/Tests/Number/NumberItemTest.php5
-rw-r--r--core/modules/field/src/Tests/ShapeItemTest.php5
-rw-r--r--core/modules/field/src/Tests/String/StringFieldTest.php5
-rw-r--r--core/modules/field/src/Tests/TestItemTest.php5
-rw-r--r--core/modules/field/src/Tests/TestItemWithDependenciesTest.php5
-rw-r--r--core/modules/field/src/Tests/TranslationTest.php5
-rw-r--r--core/modules/field/src/Tests/TranslationWebTest.php2
-rw-r--r--core/modules/field/src/Tests/Views/FieldTestBase.php5
-rw-r--r--core/modules/field/src/Tests/reEnableModuleFieldTest.php9
-rw-r--r--core/modules/file/src/Tests/FileFieldTestBase.php2
-rw-r--r--core/modules/file/src/Tests/FileItemTest.php4
-rw-r--r--core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php5
-rw-r--r--core/modules/hal/src/Tests/NormalizerTestBase.php13
-rw-r--r--core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php9
-rw-r--r--core/modules/image/src/Tests/ImageFieldTestBase.php5
-rw-r--r--core/modules/image/src/Tests/ImageItemTest.php5
-rw-r--r--core/modules/image/src/Tests/ImageThemeFunctionTest.php5
-rw-r--r--core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php5
-rw-r--r--core/modules/language/src/Entity/ContentLanguageSettings.php2
-rw-r--r--core/modules/link/src/Tests/LinkFieldTest.php17
-rw-r--r--core/modules/node/node.module4
-rw-r--r--core/modules/node/src/Tests/MultiStepNodeFormBasicOptionsTest.php5
-rw-r--r--core/modules/node/src/Tests/NodeAccessFieldTest.php5
-rw-r--r--core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php5
-rw-r--r--core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php5
-rw-r--r--core/modules/options/src/Tests/OptionsDynamicValuesTestBase.php3
-rw-r--r--core/modules/options/src/Tests/OptionsFieldTest.php5
-rw-r--r--core/modules/options/src/Tests/OptionsFieldUITest.php5
-rw-r--r--core/modules/options/src/Tests/OptionsFieldUnitTestBase.php5
-rw-r--r--core/modules/options/src/Tests/OptionsWidgetsTest.php17
-rw-r--r--core/modules/options/src/Tests/Views/ViewsDataTest.php3
-rw-r--r--core/modules/quickedit/src/Tests/QuickEditTestBase.php5
-rw-r--r--core/modules/rdf/src/Tests/Field/FieldRdfaTestBase.php5
-rw-r--r--core/modules/serialization/src/Tests/EntityResolverTest.php5
-rw-r--r--core/modules/simpletest/src/Tests/KernelTestBaseTest.php5
-rw-r--r--core/modules/system/src/Tests/Ajax/MultiFormTest.php5
-rw-r--r--core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php8
-rw-r--r--core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php8
-rw-r--r--core/modules/system/src/Tests/Entity/EntityQueryAggregateTest.php5
-rw-r--r--core/modules/system/src/Tests/Entity/EntityQueryTest.php8
-rw-r--r--core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php5
-rw-r--r--core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php17
-rw-r--r--core/modules/system/src/Tests/Form/ArbitraryRebuildTest.php5
-rw-r--r--core/modules/system/src/Tests/Form/RebuildTest.php5
-rw-r--r--core/modules/system/tests/modules/entity_test/entity_test.install5
-rw-r--r--core/modules/taxonomy/src/Tests/TaxonomyImageTest.php5
-rw-r--r--core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php5
-rw-r--r--core/modules/taxonomy/src/Tests/VocabularyCrudTest.php5
-rw-r--r--core/modules/telephone/src/Tests/TelephoneFieldTest.php5
-rw-r--r--core/modules/telephone/src/Tests/TelephoneItemTest.php5
-rw-r--r--core/modules/text/src/Tests/Formatter/TextFormatterTest.php5
-rw-r--r--core/modules/text/src/Tests/TextFieldTest.php17
-rw-r--r--core/modules/text/src/Tests/TextWithSummaryItemTest.php5
-rw-r--r--core/modules/user/src/Tests/UserCreateTest.php5
-rw-r--r--core/modules/user/src/Tests/UserRegistrationTest.php4
-rw-r--r--core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php9
-rw-r--r--core/modules/views/src/Tests/FieldApiDataTest.php2
-rw-r--r--core/modules/views/src/Tests/Handler/FieldGroupRowsTest.php3
-rw-r--r--core/modules/views/src/Tests/Wizard/TaggedWithTest.php5
92 files changed, 337 insertions, 264 deletions
diff --git a/core/modules/block_content/block_content.module b/core/modules/block_content/block_content.module
index 74fe9f1..e7a59e7 100644
--- a/core/modules/block_content/block_content.module
+++ b/core/modules/block_content/block_content.module
@@ -79,12 +79,12 @@ function block_content_add_body_field($block_type_id, $label = 'Body') {
// Add or remove the body field, as needed.
$field = FieldConfig::loadByName('block_content', $block_type_id, 'body');
if (empty($field)) {
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'),
'bundle' => $block_type_id,
'label' => $label,
'settings' => array('display_summary' => FALSE),
- ));
+ ]);
$field->save();
// Assign widget settings for the 'default' form mode.
diff --git a/core/modules/config/src/Tests/ConfigExportImportUITest.php b/core/modules/config/src/Tests/ConfigExportImportUITest.php
index 4dd6d8f..d1a9cab 100644
--- a/core/modules/config/src/Tests/ConfigExportImportUITest.php
+++ b/core/modules/config/src/Tests/ConfigExportImportUITest.php
@@ -114,10 +114,10 @@ class ConfigExportImportUITest extends WebTestBase {
'type' => 'text',
));
$this->fieldStorage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => $this->contentType->id(),
- ))->save();
+ ])->save();
// Update the displays so that configuration does not change unexpectedly on
// import.
entity_get_form_display('node', $this->contentType->id(), 'default')
diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php
index 379659d..88c6c8f 100644
--- a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php
+++ b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php
@@ -8,6 +8,7 @@
namespace Drupal\config_translation\Tests;
use Drupal\Component\Utility\Unicode;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\simpletest\WebTestBase;
@@ -399,14 +400,14 @@ class ConfigTranslationListUiTest extends WebTestBase {
'revision' => FALSE
));
$block_content_type->save();
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
// The field storage is guaranteed to exist because it is supplied by the
// block_content module.
'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'),
'bundle' => $block_content_type->id(),
'label' => 'Body',
'settings' => array('display_summary' => FALSE),
- ));
+ ]);
$field->save();
// Look at a few fields on a few entity types.
diff --git a/core/modules/contact/src/Tests/Views/ContactFieldsTest.php b/core/modules/contact/src/Tests/Views/ContactFieldsTest.php
index 25d02d2..197a69f 100644
--- a/core/modules/contact/src/Tests/Views/ContactFieldsTest.php
+++ b/core/modules/contact/src/Tests/Views/ContactFieldsTest.php
@@ -7,6 +7,7 @@
namespace Drupal\contact\Tests\Views;
+use Drupal\field\Entity\FieldConfig;
use Drupal\views\Tests\ViewTestBase;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\contact\Entity\ContactForm;
@@ -47,10 +48,10 @@ class ContactFieldsTest extends ViewTestBase {
'label' => 'Test contact form',
])->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => 'contact_message',
- ))->save();
+ ])->save();
$this->container->get('views.views_data')->clear();
}
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php b/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php
index ae0a888..320180f 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php
@@ -8,6 +8,7 @@
namespace Drupal\content_translation\Tests;
use Drupal\Component\Serialization\Json;
+use Drupal\field\Entity\FieldConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\node\Entity\NodeType;
use Drupal\simpletest\WebTestBase;
@@ -79,12 +80,12 @@ class ContentTranslationContextualLinksTest extends WebTestBase {
'type' => 'text',
'cardinality' => 1,
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => 'node',
'field_name' => 'field_test_text',
'bundle' => $this->bundle,
'label' => 'Test text-field',
- ))->save();
+ ])->save();
entity_get_form_display('node', $this->bundle, 'default')
->setComponent('field_test_text', array(
'type' => 'text_textfield',
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php b/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php
index ea80e27..380e1dc 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php
@@ -8,6 +8,7 @@
namespace Drupal\content_translation\Tests;
use Drupal\Core\Entity\EntityInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
@@ -57,7 +58,7 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
'cardinality' => $this->cardinality,
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => $this->entityTypeId,
'field_name' => $this->fieldName,
'bundle' => $this->entityTypeId,
@@ -71,7 +72,7 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
),
),
),
- ))->save();
+ ])->save();
}
/**
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php b/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php
index f7a4d65..9a93ba2 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php
@@ -8,6 +8,7 @@
namespace Drupal\content_translation\Tests;
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
+use Drupal\field\Entity\FieldConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -190,12 +191,12 @@ abstract class ContentTranslationTestBase extends WebTestBase {
'entity_type' => $this->entityTypeId,
'cardinality' => 1,
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => $this->entityTypeId,
'field_name' => $this->fieldName,
'bundle' => $this->bundle,
'label' => 'Test translatable text-field',
- ))->save();
+ ])->save();
entity_get_form_display($this->entityTypeId, $this->bundle, 'default')
->setComponent($this->fieldName, array(
'type' => 'string_textfield',
diff --git a/core/modules/datetime/src/Tests/DateTimeFieldTest.php b/core/modules/datetime/src/Tests/DateTimeFieldTest.php
index 0aa39fc..dc55bfe 100644
--- a/core/modules/datetime/src/Tests/DateTimeFieldTest.php
+++ b/core/modules/datetime/src/Tests/DateTimeFieldTest.php
@@ -11,6 +11,7 @@ use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\Core\Datetime\DrupalDateTime;
+use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -85,11 +86,11 @@ class DateTimeFieldTest extends WebTestBase {
'settings' => array('datetime_type' => 'date'),
));
$this->fieldStorage->save();
- $this->field = entity_create('field_config', array(
+ $this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
'required' => TRUE,
- ));
+ ]);
$this->field->save();
entity_get_form_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'default')
@@ -633,10 +634,10 @@ class DateTimeFieldTest extends WebTestBase {
));
$field_storage->save();
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'date_content',
- ));
+ ]);
$field->save();
// Set now as default_value.
diff --git a/core/modules/datetime/src/Tests/DateTimeItemTest.php b/core/modules/datetime/src/Tests/DateTimeItemTest.php
index 658e0fb..2f4fbcc 100644
--- a/core/modules/datetime/src/Tests/DateTimeItemTest.php
+++ b/core/modules/datetime/src/Tests/DateTimeItemTest.php
@@ -9,6 +9,7 @@ namespace Drupal\datetime\Tests;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldItemInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\FieldUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -37,13 +38,13 @@ class DateTimeItemTest extends FieldUnitTestBase {
'settings' => array('datetime_type' => 'date'),
));
$field_storage->save();
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
'settings' => array(
'default_value' => 'blank',
),
- ));
+ ]);
$field->save();
}
diff --git a/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php b/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php
index b563f04..4913e4d 100644
--- a/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php
+++ b/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php
@@ -8,6 +8,7 @@
namespace Drupal\datetime\Tests\Views;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem;
+use Drupal\field\Entity\FieldConfig;
use Drupal\views\Tests\Handler\HandlerTestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\field\Entity\FieldStorageConfig;
@@ -57,7 +58,7 @@ abstract class DateTimeHandlerTestBase extends HandlerTestBase {
'settings' => ['datetime_type' => DateTimeItem::DATETIME_TYPE_DATETIME],
]);
$fieldStorage->save();
- $field = entity_create('field_config', [
+ $field = FieldConfig::create([
'field_storage' => $fieldStorage,
'bundle' => 'page',
'required' => TRUE,
diff --git a/core/modules/field/src/Entity/FieldConfig.php b/core/modules/field/src/Entity/FieldConfig.php
index 8e0e0b4..1597994 100644
--- a/core/modules/field/src/Entity/FieldConfig.php
+++ b/core/modules/field/src/Entity/FieldConfig.php
@@ -72,7 +72,7 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface {
* Constructs a FieldConfig object.
*
* In most cases, Field entities are created via
- * entity_create('field_config', $values), where $values is the same
+ * FieldConfig::create($values), where $values is the same
* parameter as in this constructor.
*
* @param array $values
diff --git a/core/modules/field/src/Tests/Boolean/BooleanItemTest.php b/core/modules/field/src/Tests/Boolean/BooleanItemTest.php
index 5647073..8b8c192 100644
--- a/core/modules/field/src/Tests/Boolean/BooleanItemTest.php
+++ b/core/modules/field/src/Tests/Boolean/BooleanItemTest.php
@@ -9,6 +9,7 @@ namespace Drupal\field\Tests\Boolean;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldItemInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\FieldUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -31,11 +32,11 @@ class BooleanItemTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => 'boolean',
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_boolean',
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
// Create a form display for the default form mode.
entity_get_form_display('entity_test', 'entity_test', 'default')
diff --git a/core/modules/field/src/Tests/BulkDeleteTest.php b/core/modules/field/src/Tests/BulkDeleteTest.php
index 3a9f5b8..2c7835f 100644
--- a/core/modules/field/src/Tests/BulkDeleteTest.php
+++ b/core/modules/field/src/Tests/BulkDeleteTest.php
@@ -127,10 +127,10 @@ class BulkDeleteTest extends FieldUnitTestBase {
// fields.
foreach ($this->bundles as $bundle) {
foreach ($this->fieldStorages as $field_storage) {
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $bundle,
- ))->save();
+ ])->save();
}
for ($i = 0; $i < 10; $i++) {
$entity = entity_create($this->entityTypeId, array('type' => $bundle));
diff --git a/core/modules/field/src/Tests/DisplayApiTest.php b/core/modules/field/src/Tests/DisplayApiTest.php
index f06f782..1526a4f 100644
--- a/core/modules/field/src/Tests/DisplayApiTest.php
+++ b/core/modules/field/src/Tests/DisplayApiTest.php
@@ -8,6 +8,7 @@
namespace Drupal\field\Tests;
use Drupal\Core\Entity\Entity\EntityViewMode;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
@@ -96,7 +97,7 @@ class DisplayApiTest extends FieldUnitTestBase {
);
FieldStorageConfig::create($field_storage)->save();
- entity_create('field_config', $field)->save();
+ FieldConfig::create($field)->save();
// Create a display for the default view mode.
entity_get_display($field['entity_type'], $field['bundle'], 'default')
->setComponent($this->fieldName, $this->displayOptions['default'])
diff --git a/core/modules/field/src/Tests/Email/EmailFieldTest.php b/core/modules/field/src/Tests/Email/EmailFieldTest.php
index 1bbd0f6..d730585 100644
--- a/core/modules/field/src/Tests/Email/EmailFieldTest.php
+++ b/core/modules/field/src/Tests/Email/EmailFieldTest.php
@@ -8,6 +8,7 @@
namespace Drupal\field\Tests\Email;
use Drupal\Component\Utility\Unicode;
+use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -61,10 +62,10 @@ class EmailFieldTest extends WebTestBase {
'type' => 'email',
));
$this->fieldStorage->save();
- $this->field = entity_create('field_config', array(
+ $this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
- ));
+ ]);
$this->field->save();
// Create a form display for the default form mode.
diff --git a/core/modules/field/src/Tests/Email/EmailItemTest.php b/core/modules/field/src/Tests/Email/EmailItemTest.php
index 58c1e29..3267ce4 100644
--- a/core/modules/field/src/Tests/Email/EmailItemTest.php
+++ b/core/modules/field/src/Tests/Email/EmailItemTest.php
@@ -9,6 +9,7 @@ namespace Drupal\field\Tests\Email;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldItemInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\FieldUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -28,11 +29,11 @@ class EmailItemTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => 'email',
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_email',
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
// Create a form display for the default form mode.
entity_get_form_display('entity_test', 'entity_test', 'default')
diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceAutoCreateTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceAutoCreateTest.php
index 9279dc0..a381b1f 100644
--- a/core/modules/field/src/Tests/EntityReference/EntityReferenceAutoCreateTest.php
+++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceAutoCreateTest.php
@@ -8,6 +8,7 @@
namespace Drupal\field\Tests\EntityReference;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\node\Entity\Node;
use Drupal\field\Entity\FieldStorageConfig;
@@ -57,7 +58,7 @@ class EntityReferenceAutoCreateTest extends WebTestBase {
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'label' => 'Entity reference field',
'field_name' => 'test_field',
'entity_type' => 'node',
@@ -73,7 +74,7 @@ class EntityReferenceAutoCreateTest extends WebTestBase {
'auto_create' => TRUE,
),
),
- ))->save();
+ ])->save();
entity_get_display('node', $referencing->id(), 'default')
->setComponent('test_field')
diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldDefaultValueTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldDefaultValueTest.php
index 473f9e0..19d99f2 100644
--- a/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldDefaultValueTest.php
+++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldDefaultValueTest.php
@@ -9,6 +9,7 @@ namespace Drupal\field\Tests\EntityReference;
use Drupal\Component\Utility\Unicode;
use Drupal\config\Tests\SchemaCheckTestTrait;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\simpletest\WebTestBase;
@@ -62,7 +63,7 @@ class EntityReferenceFieldDefaultValueTest extends WebTestBase {
'settings' => array('target_type' => 'node'),
));
$field_storage->save();
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'reference_content',
'settings' => array(
@@ -72,7 +73,7 @@ class EntityReferenceFieldDefaultValueTest extends WebTestBase {
'sort' => array('field' => '_none'),
),
),
- ));
+ ]);
$field->save();
// Set created node as default_value.
@@ -126,7 +127,7 @@ class EntityReferenceFieldDefaultValueTest extends WebTestBase {
'cardinality' => FieldStorageConfig::CARDINALITY_UNLIMITED,
));
$field_storage->save();
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'reference_content',
'settings' => array(
@@ -135,7 +136,7 @@ class EntityReferenceFieldDefaultValueTest extends WebTestBase {
'sort' => array('field' => '_none'),
),
),
- ));
+ ]);
$field->save();
// Set created node as default_value.
diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php
index bad3d98..6d2ffc2 100644
--- a/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php
+++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php
@@ -7,6 +7,7 @@
namespace Drupal\field\Tests\EntityReference;
+use Drupal\field\Entity\FieldConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\simpletest\WebTestBase;
@@ -222,11 +223,11 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends WebTestBase {
),
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $this->referenceFieldName,
'bundle' => $this->referrerType->id(),
'entity_type' => $this->testEntityTypeName,
- ))
+ ])
->save();
entity_get_form_display($this->testEntityTypeName, $this->referrerType->id(), 'default')
->setComponent($this->referenceFieldName, array(
diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php
index 922b865..a487f6a 100644
--- a/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php
+++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceFileUploadTest.php
@@ -8,6 +8,7 @@
namespace Drupal\field\Tests\EntityReference;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -64,7 +65,7 @@ class EntityReferenceFileUploadTest extends WebTestBase {
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'label' => 'Entity reference field',
'field_name' => 'test_field',
'entity_type' => 'node',
@@ -79,7 +80,7 @@ class EntityReferenceFileUploadTest extends WebTestBase {
),
),
),
- ))->save();
+ ])->save();
// Create a file field.
@@ -90,12 +91,12 @@ class EntityReferenceFileUploadTest extends WebTestBase {
'type' => 'file'
));
$field_storage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => 'node',
'field_storage' => $field_storage,
'bundle' => $referencing->id(),
'label' => $this->randomMachineName() . '_label',
- ))->save();
+ ])->save();
entity_get_display('node', $referencing->id(), 'default')
->setComponent('test_field')
diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php
index 4c651e6..6d0d0a8 100644
--- a/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php
+++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceFormatterTest.php
@@ -10,6 +10,7 @@ namespace Drupal\field\Tests\EntityReference;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\filter\Entity\FilterFormat;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
@@ -89,12 +90,12 @@ class EntityReferenceFormatterTest extends EntityUnitTestBase {
'type' => 'text',
'settings' => array(),
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => $this->entityType,
'bundle' => $this->bundle,
'field_name' => 'body',
'label' => 'Body',
- ))->save();
+ ])->save();
entity_get_display($this->entityType, $this->bundle, 'default')
->setComponent('body', array(
'type' => 'text_default',
diff --git a/core/modules/field/src/Tests/EntityReference/Views/SelectionTest.php b/core/modules/field/src/Tests/EntityReference/Views/SelectionTest.php
index 69986d8..6bcba87 100644
--- a/core/modules/field/src/Tests/EntityReference/Views/SelectionTest.php
+++ b/core/modules/field/src/Tests/EntityReference/Views/SelectionTest.php
@@ -7,6 +7,7 @@
namespace Drupal\field\Tests\EntityReference\Views;
+use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\views\Views;
use Drupal\field\Entity\FieldStorageConfig;
@@ -62,7 +63,7 @@ class SelectionTest extends WebTestBase {
'cardinality' => '1',
));
$field_storage->save();
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'test_bundle',
'settings' => array(
@@ -75,7 +76,7 @@ class SelectionTest extends WebTestBase {
),
),
),
- ));
+ ]);
$field->save();
$this->field = $field;
}
diff --git a/core/modules/field/src/Tests/FieldAccessTest.php b/core/modules/field/src/Tests/FieldAccessTest.php
index d00ce92..b837e85 100644
--- a/core/modules/field/src/Tests/FieldAccessTest.php
+++ b/core/modules/field/src/Tests/FieldAccessTest.php
@@ -7,6 +7,7 @@
namespace Drupal\field\Tests;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
@@ -58,7 +59,7 @@ class FieldAccessTest extends FieldTestBase {
'entity_type' => 'node',
'bundle' => $content_type,
);
- entity_create('field_config', $field)->save();
+ FieldConfig::create($field)->save();
// Assign display properties for the 'default' and 'teaser' view modes.
foreach (array('default', 'teaser') as $view_mode) {
diff --git a/core/modules/field/src/Tests/FieldAttachStorageTest.php b/core/modules/field/src/Tests/FieldAttachStorageTest.php
index 31c11d9..d700334 100644
--- a/core/modules/field/src/Tests/FieldAttachStorageTest.php
+++ b/core/modules/field/src/Tests/FieldAttachStorageTest.php
@@ -104,11 +104,11 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
$field_storage->save();
$field_ids[$i] = $field_storage->uuid();
foreach ($field_bundles_map[$i] as $bundle) {
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $field_names[$i],
'entity_type' => $entity_type,
'bundle' => $bundles[$bundle],
- ))->save();
+ ])->save();
}
}
@@ -289,7 +289,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
// Add a field to that bundle.
$this->fieldTestData->field_definition['bundle'] = $new_bundle;
- entity_create('field_config', $this->fieldTestData->field_definition)->save();
+ FieldConfig::create($this->fieldTestData->field_definition)->save();
// Save an entity with data in the field.
$entity = entity_create($entity_type, array('type' => $this->fieldTestData->field->getTargetBundle()));
@@ -314,7 +314,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
// Add a field to that bundle.
$this->fieldTestData->field_definition['bundle'] = $new_bundle;
- entity_create('field_config', $this->fieldTestData->field_definition)->save();
+ FieldConfig::create($this->fieldTestData->field_definition)->save();
// Create a second field for the test bundle
$field_name = Unicode::strtolower($this->randomMachineName() . '_field_name');
@@ -333,7 +333,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
'description' => $this->randomMachineName() . '_description',
'weight' => mt_rand(0, 127),
);
- entity_create('field_config', $field)->save();
+ FieldConfig::create($field)->save();
// Save an entity with data for both fields
$entity = entity_create($entity_type, array('type' => $this->fieldTestData->field->getTargetBundle()));
diff --git a/core/modules/field/src/Tests/FieldCrudTest.php b/core/modules/field/src/Tests/FieldCrudTest.php
index 621f58e..08daa6c 100644
--- a/core/modules/field/src/Tests/FieldCrudTest.php
+++ b/core/modules/field/src/Tests/FieldCrudTest.php
@@ -73,7 +73,7 @@ class FieldCrudTest extends FieldUnitTestBase {
// constraint for this field.
\Drupal::state()->set('field_test_add_constraint', $this->fieldStorage->getName());
/** @var \Drupal\Core\Field\FieldConfigInterface $field */
- $field = entity_create('field_config', $this->fieldDefinition);
+ $field = FieldConfig::create($this->fieldDefinition);
$field->save();
$field = FieldConfig::load($field->id());
@@ -118,7 +118,7 @@ class FieldCrudTest extends FieldUnitTestBase {
// Guarantee that the field/bundle combination is unique.
try {
- entity_create('field_config', $this->fieldDefinition)->save();
+ FieldConfig::create($this->fieldDefinition)->save();
$this->fail(t('Cannot create two fields with the same field / bundle combination.'));
}
catch (EntityStorageException $e) {
@@ -128,7 +128,7 @@ class FieldCrudTest extends FieldUnitTestBase {
// Check that the specified field exists.
try {
$this->fieldDefinition['field_name'] = $this->randomMachineName();
- entity_create('field_config', $this->fieldDefinition)->save();
+ FieldConfig::create($this->fieldDefinition)->save();
$this->fail(t('Cannot create a field with a non-existing storage.'));
}
catch (FieldException $e) {
@@ -180,7 +180,7 @@ class FieldCrudTest extends FieldUnitTestBase {
* Test reading back a field definition.
*/
function testReadField() {
- entity_create('field_config', $this->fieldDefinition)->save();
+ FieldConfig::create($this->fieldDefinition)->save();
// Read the field back.
$field = FieldConfig::load('entity_test.' . $this->fieldDefinition['bundle'] . '.' . $this->fieldDefinition['field_name']);
@@ -193,7 +193,7 @@ class FieldCrudTest extends FieldUnitTestBase {
* Test the update of a field.
*/
function testUpdateField() {
- entity_create('field_config', $this->fieldDefinition)->save();
+ FieldConfig::create($this->fieldDefinition)->save();
// Check that basic changes are saved.
$field = FieldConfig::load('entity_test.' . $this->fieldDefinition['bundle'] . '.' . $this->fieldDefinition['field_name']);
@@ -221,11 +221,11 @@ class FieldCrudTest extends FieldUnitTestBase {
// Create two fields for the same field storage so we can test that only one
// is deleted.
- entity_create('field_config', $this->fieldDefinition)->save();
+ FieldConfig::create($this->fieldDefinition)->save();
$another_field_definition = $this->fieldDefinition;
$another_field_definition['bundle'] .= '_another_bundle';
entity_test_create_bundle($another_field_definition['bundle']);
- entity_create('field_config', $another_field_definition)->save();
+ FieldConfig::create($another_field_definition)->save();
// Test that the first field is not deleted, and then delete it.
$field = current(entity_load_multiple_by_properties('field_config', array('entity_type' => 'entity_test', 'field_name' => $this->fieldDefinition['field_name'], 'bundle' => $this->fieldDefinition['bundle'], 'include_deleted' => TRUE)));
@@ -255,8 +255,8 @@ class FieldCrudTest extends FieldUnitTestBase {
// Check that deletion of a field storage deletes its fields.
$field_storage = $this->fieldStorage;
- entity_create('field_config', $this->fieldDefinition)->save();
- entity_create('field_config', $field_definition_2)->save();
+ FieldConfig::create($this->fieldDefinition)->save();
+ FieldConfig::create($field_definition_2)->save();
$field_storage->delete();
$this->assertFalse(FieldConfig::loadByName('entity_test', $this->fieldDefinition['bundle'], $field_storage->getName()));
$this->assertFalse(FieldConfig::loadByName('entity_test', $field_definition_2['bundle'], $field_storage->getName()));
@@ -264,9 +264,9 @@ class FieldCrudTest extends FieldUnitTestBase {
// Check that deletion of the last field deletes the storage.
$field_storage = FieldStorageConfig::create($this->fieldStorageDefinition);
$field_storage->save();
- $field = entity_create('field_config', $this->fieldDefinition);
+ $field = FieldConfig::create($this->fieldDefinition);
$field->save();
- $field_2 = entity_create('field_config', $field_definition_2);
+ $field_2 = FieldConfig::create($field_definition_2);
$field_2->save();
$field->delete();
$this->assertTrue(FieldStorageConfig::loadByName('entity_test', $field_storage->getName()));
@@ -277,9 +277,9 @@ class FieldCrudTest extends FieldUnitTestBase {
// the storage.
$field_storage = FieldStorageConfig::create($this->fieldStorageDefinition);
$field_storage->save();
- $field = entity_create('field_config', $this->fieldDefinition);
+ $field = FieldConfig::create($this->fieldDefinition);
$field->save();
- $field_2 = entity_create('field_config', $field_definition_2);
+ $field_2 = FieldConfig::create($field_definition_2);
$field_2->save();
$this->container->get('entity.manager')->getStorage('field_config')->delete(array($field, $field_2));
$this->assertFalse(FieldStorageConfig::loadByName('entity_test', $field_storage->getName()));
diff --git a/core/modules/field/src/Tests/FieldDataCountTest.php b/core/modules/field/src/Tests/FieldDataCountTest.php
index 76dc6a0..8b992b7 100644
--- a/core/modules/field/src/Tests/FieldDataCountTest.php
+++ b/core/modules/field/src/Tests/FieldDataCountTest.php
@@ -61,10 +61,10 @@ class FieldDataCountTest extends FieldUnitTestBase {
'cardinality' => 2,
));
$field_storage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
$this->assertIdentical($field_storage->hasdata(), FALSE, 'There are no entities with field data.');
$this->assertIdentical($this->storage->countFieldData($field_storage), 0, 'There are 0 entities with field data.');
diff --git a/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php b/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php
index 04547a8..fe54ddd 100644
--- a/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php
+++ b/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php
@@ -7,6 +7,7 @@
namespace Drupal\field\Tests;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
@@ -47,10 +48,10 @@ class FieldImportDeleteUninstallTest extends FieldUnitTestBase {
'type' => 'integer',
));
$unrelated_field_storage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $unrelated_field_storage,
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
// Create a telephone field for validation.
$field_storage = FieldStorageConfig::create(array(
@@ -59,10 +60,10 @@ class FieldImportDeleteUninstallTest extends FieldUnitTestBase {
'type' => 'telephone',
));
$field_storage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
$entity = entity_create('entity_test');
$value = '+0123456789';
@@ -122,10 +123,10 @@ class FieldImportDeleteUninstallTest extends FieldUnitTestBase {
));
$field_storage->save();
$field_storage_uuid = $field_storage->uuid();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
// Create 12 entities to ensure that the purging works as expected.
for ($i=0; $i < 12; $i++) {
diff --git a/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php b/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php
index 3d602ba..e8a964e 100644
--- a/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php
+++ b/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php
@@ -7,6 +7,7 @@
namespace Drupal\field\Tests;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
@@ -44,10 +45,10 @@ class FieldImportDeleteUninstallUiTest extends FieldTestBase {
'type' => 'telephone',
));
$field_storage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
// Create a text field.
$date_field_storage = FieldStorageConfig::create(array(
@@ -56,10 +57,10 @@ class FieldImportDeleteUninstallUiTest extends FieldTestBase {
'type' => 'datetime',
));
$date_field_storage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $date_field_storage,
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
// Create an entity which has values for the telephone and text field.
$entity = entity_create('entity_test');
diff --git a/core/modules/field/src/Tests/FieldStorageCrudTest.php b/core/modules/field/src/Tests/FieldStorageCrudTest.php
index 0def12c..43d0aa0 100644
--- a/core/modules/field/src/Tests/FieldStorageCrudTest.php
+++ b/core/modules/field/src/Tests/FieldStorageCrudTest.php
@@ -232,7 +232,7 @@ class FieldStorageCrudTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
);
- entity_create('field_config', $field_definition)->save();
+ FieldConfig::create($field_definition)->save();
}
/**
@@ -311,10 +311,10 @@ class FieldStorageCrudTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
);
- entity_create('field_config', $field_definition)->save();
+ FieldConfig::create($field_definition)->save();
$another_field_definition = $field_definition;
$another_field_definition['field_name'] = $another_field_storage_definition['field_name'];
- entity_create('field_config', $another_field_definition)->save();
+ FieldConfig::create($another_field_definition)->save();
// Test that the first field is not deleted, and then delete it.
$field_storage = current(entity_load_multiple_by_properties('field_storage_config', array('field_name' => $field_storage_definition['field_name'], 'include_deleted' => TRUE)));
@@ -348,7 +348,7 @@ class FieldStorageCrudTest extends FieldUnitTestBase {
// Try to create a new field the same name as a deleted field and
// write data into it.
FieldStorageConfig::create($field_storage_definition)->save();
- entity_create('field_config', $field_definition)->save();
+ FieldConfig::create($field_definition)->save();
$field_storage = FieldStorageConfig::load('entity_test.' . $field_storage_definition['field_name']);
$this->assertTrue(!empty($field_storage) && !$field_storage->isDeleted(), 'A new storage with a previously used name is created.');
$field = FieldConfig::load('entity_test.' . $field_definition['bundle'] . '.' . $field_definition['field_name'] );
@@ -400,11 +400,11 @@ class FieldStorageCrudTest extends FieldUnitTestBase {
'cardinality' => $cardinality,
));
$field_storage->save();
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
- ));
+ ]);
$field->save();
do {
diff --git a/core/modules/field/src/Tests/FieldUnitTestBase.php b/core/modules/field/src/Tests/FieldUnitTestBase.php
index c8a62c8..512ef35 100644
--- a/core/modules/field/src/Tests/FieldUnitTestBase.php
+++ b/core/modules/field/src/Tests/FieldUnitTestBase.php
@@ -10,6 +10,7 @@ namespace Drupal\field\Tests;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Language\LanguageInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\KernelTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -109,7 +110,7 @@ abstract class FieldUnitTestBase extends KernelTestBase {
'test_field_setting' => $this->randomMachineName(),
),
);
- $this->fieldTestData->$field = entity_create('field_config', $this->fieldTestData->$field_definition);
+ $this->fieldTestData->$field = FieldConfig::create($this->fieldTestData->$field_definition);
$this->fieldTestData->$field->save();
entity_get_form_display($entity_type, $bundle, 'default')
diff --git a/core/modules/field/src/Tests/FormTest.php b/core/modules/field/src/Tests/FormTest.php
index c7d305b..c629ca7 100644
--- a/core/modules/field/src/Tests/FormTest.php
+++ b/core/modules/field/src/Tests/FormTest.php
@@ -100,7 +100,7 @@ class FormTest extends FieldTestBase {
$field_name = $field_storage['field_name'];
$this->field['field_name'] = $field_name;
FieldStorageConfig::create($field_storage)->save();
- entity_create('field_config', $this->field)->save();
+ FieldConfig::create($this->field)->save();
entity_get_form_display($this->field['entity_type'], $this->field['bundle'], 'default')
->setComponent($field_name)
->save();
@@ -176,7 +176,7 @@ class FormTest extends FieldTestBase {
$default = rand(1, 127);
$this->field['default_value'] = array(array('value' => $default));
FieldStorageConfig::create($field_storage)->save();
- entity_create('field_config', $this->field)->save();
+ FieldConfig::create($this->field)->save();
entity_get_form_display($this->field['entity_type'], $this->field['bundle'], 'default')
->setComponent($field_name)
->save();
@@ -204,7 +204,7 @@ class FormTest extends FieldTestBase {
$this->field['field_name'] = $field_name;
$this->field['required'] = TRUE;
FieldStorageConfig::create($field_storage)->save();
- entity_create('field_config', $this->field)->save();
+ FieldConfig::create($this->field)->save();
entity_get_form_display($this->field['entity_type'], $this->field['bundle'], 'default')
->setComponent($field_name)
->save();
@@ -240,7 +240,7 @@ class FormTest extends FieldTestBase {
// $field_name = $this->field['field_name'];
// $this->instance['field_name'] = $field_name;
// FieldStorageConfig::create($this->field)->save();
-// entity_create('field_config', $this->instance)->save();
+// FieldConfig::create($this->instance)->save();
// }
function testFieldFormUnlimited() {
@@ -248,7 +248,7 @@ class FormTest extends FieldTestBase {
$field_name = $field_storage['field_name'];
$this->field['field_name'] = $field_name;
FieldStorageConfig::create($field_storage)->save();
- entity_create('field_config', $this->field)->save();
+ FieldConfig::create($this->field)->save();
entity_get_form_display($this->field['entity_type'], $this->field['bundle'], 'default')
->setComponent($field_name)
->save();
@@ -359,7 +359,7 @@ class FormTest extends FieldTestBase {
$field_name = $field_storage['field_name'];
$this->field['field_name'] = $field_name;
FieldStorageConfig::create($field_storage)->save();
- entity_create('field_config', $this->field)->save();
+ FieldConfig::create($this->field)->save();
entity_get_form_display($this->field['entity_type'], $this->field['bundle'], 'default')
->setComponent($field_name)
->save();
@@ -379,7 +379,7 @@ class FormTest extends FieldTestBase {
'bundle' => 'entity_test',
'required' => TRUE,
);
- entity_create('field_config', $field)->save();
+ FieldConfig::create($field)->save();
entity_get_form_display($field['entity_type'], $field['bundle'], 'default')
->setComponent($field['field_name'], array(
'type' => 'options_buttons',
@@ -406,7 +406,7 @@ class FormTest extends FieldTestBase {
$field_name = $field_storage['field_name'];
$this->field['field_name'] = $field_name;
FieldStorageConfig::create($field_storage)->save();
- entity_create('field_config', $this->field)->save();
+ FieldConfig::create($this->field)->save();
entity_get_form_display($this->field['entity_type'], $this->field['bundle'], 'default')
->setComponent($field_name)
->save();
@@ -467,7 +467,7 @@ class FormTest extends FieldTestBase {
$field_name = $field_storage['field_name'];
$this->field['field_name'] = $field_name;
FieldStorageConfig::create($field_storage)->save();
- entity_create('field_config', $this->field)->save();
+ FieldConfig::create($this->field)->save();
entity_get_form_display($this->field['entity_type'], $this->field['bundle'], 'default')
->setComponent($field_name, array(
'type' => 'test_field_widget_multiple',
@@ -516,7 +516,7 @@ class FormTest extends FieldTestBase {
$field['entity_type'] = $entity_type;
$field['bundle'] = $entity_type;
FieldStorageConfig::create($field_storage)->save();
- entity_create('field_config', $field)->save();
+ FieldConfig::create($field)->save();
entity_get_form_display($entity_type, $entity_type, 'default')
->setComponent($field_name)
->save();
@@ -536,7 +536,7 @@ class FormTest extends FieldTestBase {
'default_value' => array(0 => array('value' => 99)),
);
FieldStorageConfig::create($field_storage_no_access)->save();
- entity_create('field_config', $field_no_access)->save();
+ FieldConfig::create($field_no_access)->save();
entity_get_form_display($field_no_access['entity_type'], $field_no_access['bundle'], 'default')
->setComponent($field_name_no_access)
->save();
@@ -601,7 +601,7 @@ class FormTest extends FieldTestBase {
$this->field['entity_type'] = $entity_type;
$this->field['bundle'] = $entity_type;
FieldStorageConfig::create($field_storage)->save();
- $this->field = entity_create('field_config', $this->field);
+ $this->field = FieldConfig::create($this->field);
$this->field->save();
// We explicitly do not assign a widget in a form display, so the field
// stays hidden in forms.
diff --git a/core/modules/field/src/Tests/NestedFormTest.php b/core/modules/field/src/Tests/NestedFormTest.php
index cc21fab..ac5dca4 100644
--- a/core/modules/field/src/Tests/NestedFormTest.php
+++ b/core/modules/field/src/Tests/NestedFormTest.php
@@ -7,6 +7,7 @@
namespace Drupal\field\Tests;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
@@ -62,13 +63,13 @@ class NestedFormTest extends FieldTestBase {
FieldStorageConfig::create($this->fieldStorageUnlimited)->save();
$this->field['field_name'] = 'field_single';
$this->field['label'] = 'Single field';
- entity_create('field_config', $this->field)->save();
+ FieldConfig::create($this->field)->save();
entity_get_form_display($this->field['entity_type'], $this->field['bundle'], 'default')
->setComponent($this->field['field_name'])
->save();
$this->field['field_name'] = 'field_unlimited';
$this->field['label'] = 'Unlimited field';
- entity_create('field_config', $this->field)->save();
+ FieldConfig::create($this->field)->save();
entity_get_form_display($this->field['entity_type'], $this->field['bundle'], 'default')
->setComponent($this->field['field_name'])
->save();
diff --git a/core/modules/field/src/Tests/Number/NumberFieldTest.php b/core/modules/field/src/Tests/Number/NumberFieldTest.php
index 1e75068..894c92c 100644
--- a/core/modules/field/src/Tests/Number/NumberFieldTest.php
+++ b/core/modules/field/src/Tests/Number/NumberFieldTest.php
@@ -8,6 +8,7 @@
namespace Drupal\field\Tests\Number;
use Drupal\Component\Utility\Unicode;
+use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -52,11 +53,11 @@ class NumberFieldTest extends WebTestBase {
'precision' => 8, 'scale' => 4,
)
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($field_name, array(
@@ -141,14 +142,14 @@ class NumberFieldTest extends WebTestBase {
));
$storage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
'settings' => array(
'min' => $minimum, 'max' => $maximum, 'prefix' => 'ThePrefix',
)
- ))->save();
+ ])->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($field_name, array(
@@ -283,11 +284,11 @@ class NumberFieldTest extends WebTestBase {
'type' => 'float',
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($field_name, array(
@@ -390,7 +391,7 @@ class NumberFieldTest extends WebTestBase {
'type' => 'integer',
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $float_field,
'entity_type' => 'node',
'bundle' => $type,
@@ -398,9 +399,9 @@ class NumberFieldTest extends WebTestBase {
'prefix' => $prefix,
'suffix' => $suffix
),
- ))->save();
+ ])->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $integer_field,
'entity_type' => 'node',
'bundle' => $type,
@@ -408,7 +409,7 @@ class NumberFieldTest extends WebTestBase {
'prefix' => $prefix,
'suffix' => $suffix
),
- ))->save();
+ ])->save();
entity_get_form_display('node', $type, 'default')
->setComponent($float_field, array(
@@ -508,11 +509,11 @@ class NumberFieldTest extends WebTestBase {
'type' => 'float',
))->save();
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
- ));
+ ]);
$field->save();
// Set the minimum value to a float value.
@@ -533,11 +534,11 @@ class NumberFieldTest extends WebTestBase {
'type' => 'decimal',
))->save();
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
- ));
+ ]);
$field->save();
// Set the minimum value to a decimal value.
diff --git a/core/modules/field/src/Tests/Number/NumberItemTest.php b/core/modules/field/src/Tests/Number/NumberItemTest.php
index 0e80428..3f65fe2 100644
--- a/core/modules/field/src/Tests/Number/NumberItemTest.php
+++ b/core/modules/field/src/Tests/Number/NumberItemTest.php
@@ -9,6 +9,7 @@ namespace Drupal\field\Tests\Number;
use Drupal\Core\Field\FieldItemInterface;
use Drupal\Core\Field\FieldItemListInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\FieldUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -36,11 +37,11 @@ class NumberItemTest extends FieldUnitTestBase {
'field_name' => 'field_' . $type,
'type' => $type,
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_' . $type,
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
}
}
diff --git a/core/modules/field/src/Tests/ShapeItemTest.php b/core/modules/field/src/Tests/ShapeItemTest.php
index 0e20aab..20bb4e0 100644
--- a/core/modules/field/src/Tests/ShapeItemTest.php
+++ b/core/modules/field/src/Tests/ShapeItemTest.php
@@ -9,6 +9,7 @@ namespace Drupal\field\Tests;
use Drupal\Core\Field\FieldItemInterface;
use Drupal\Core\Field\FieldItemListInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
@@ -41,11 +42,11 @@ class ShapeItemTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => 'shape',
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => $this->fieldName,
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
}
/**
diff --git a/core/modules/field/src/Tests/String/StringFieldTest.php b/core/modules/field/src/Tests/String/StringFieldTest.php
index cb8e26a..80cb1fe 100644
--- a/core/modules/field/src/Tests/String/StringFieldTest.php
+++ b/core/modules/field/src/Tests/String/StringFieldTest.php
@@ -8,6 +8,7 @@
namespace Drupal\field\Tests\String;
use Drupal\Component\Utility\Unicode;
+use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -61,11 +62,11 @@ class StringFieldTest extends WebTestBase {
'type' => $field_type
));
$field_storage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
'label' => $this->randomMachineName() . '_label',
- ))->save();
+ ])->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($field_name, array(
'type' => $widget_type,
diff --git a/core/modules/field/src/Tests/TestItemTest.php b/core/modules/field/src/Tests/TestItemTest.php
index 3743967..b4bf7ca 100644
--- a/core/modules/field/src/Tests/TestItemTest.php
+++ b/core/modules/field/src/Tests/TestItemTest.php
@@ -10,6 +10,7 @@ namespace Drupal\field\Tests;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Field\FieldItemInterface;
use Drupal\Core\Field\FieldItemListInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
@@ -42,11 +43,11 @@ class TestItemTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => 'test_field',
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => $this->fieldName,
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
}
/**
diff --git a/core/modules/field/src/Tests/TestItemWithDependenciesTest.php b/core/modules/field/src/Tests/TestItemWithDependenciesTest.php
index 48adb75..16d5a78 100644
--- a/core/modules/field/src/Tests/TestItemWithDependenciesTest.php
+++ b/core/modules/field/src/Tests/TestItemWithDependenciesTest.php
@@ -7,6 +7,7 @@
namespace Drupal\field\Tests;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
@@ -40,11 +41,11 @@ class TestItemWithDependenciesTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => 'test_field_with_dependencies',
))->save();
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => $this->fieldName,
'bundle' => 'entity_test',
- ));
+ ]);
$field->save();
// Validate that the field configuration entity has the expected
diff --git a/core/modules/field/src/Tests/TranslationTest.php b/core/modules/field/src/Tests/TranslationTest.php
index 9f3d698..359ef7d 100644
--- a/core/modules/field/src/Tests/TranslationTest.php
+++ b/core/modules/field/src/Tests/TranslationTest.php
@@ -8,6 +8,7 @@
namespace Drupal\field\Tests;
use Drupal\Component\Utility\Unicode;
+use Drupal\field\Entity\FieldConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\field\Entity\FieldStorageConfig;
@@ -96,7 +97,7 @@ class TranslationTest extends FieldUnitTestBase {
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
);
- $this->field = entity_create('field_config', $this->fieldDefinition);
+ $this->field = FieldConfig::create($this->fieldDefinition);
$this->field->save();
for ($i = 0; $i < 3; ++$i) {
@@ -151,7 +152,7 @@ class TranslationTest extends FieldUnitTestBase {
$field_definition = $this->fieldDefinition;
$field_definition['field_storage'] = $field_storage;
$field_definition['default_value'] = array(array('value' => rand(1, 127)));
- $field = entity_create('field_config', $field_definition);
+ $field = FieldConfig::create($field_definition);
$field->save();
$translation_langcodes = array_slice($available_langcodes, 0, 2);
diff --git a/core/modules/field/src/Tests/TranslationWebTest.php b/core/modules/field/src/Tests/TranslationWebTest.php
index a24dda1..78530c0 100644
--- a/core/modules/field/src/Tests/TranslationWebTest.php
+++ b/core/modules/field/src/Tests/TranslationWebTest.php
@@ -72,7 +72,7 @@ class TranslationWebTest extends FieldTestBase {
'field_storage' => $this->fieldStorage,
'bundle' => $this->entityTypeId,
);
- entity_create('field_config', $field)->save();
+ FieldConfig::create($field)->save();
$this->field = FieldConfig::load($this->entityTypeId . '.' . $field['bundle'] . '.' . $this->fieldName);
entity_get_form_display($this->entityTypeId, $this->entityTypeId, 'default')
diff --git a/core/modules/field/src/Tests/Views/FieldTestBase.php b/core/modules/field/src/Tests/Views/FieldTestBase.php
index 9019f03..5e3063d 100644
--- a/core/modules/field/src/Tests/Views/FieldTestBase.php
+++ b/core/modules/field/src/Tests/Views/FieldTestBase.php
@@ -19,6 +19,7 @@
namespace Drupal\field\Tests\Views;
+use Drupal\field\Entity\FieldConfig;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\field\Entity\FieldStorageConfig;
@@ -79,10 +80,10 @@ abstract class FieldTestBase extends ViewTestBase {
function setUpFields($bundle = 'page') {
foreach ($this->fieldStorages as $key => $field_storage) {
- $this->fields[$key] = entity_create('field_config', array(
+ $this->fields[$key] = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $bundle,
- ));
+ ]);
$this->fields[$key]->save();
}
}
diff --git a/core/modules/field/src/Tests/reEnableModuleFieldTest.php b/core/modules/field/src/Tests/reEnableModuleFieldTest.php
index 9046350..c8040ff 100644
--- a/core/modules/field/src/Tests/reEnableModuleFieldTest.php
+++ b/core/modules/field/src/Tests/reEnableModuleFieldTest.php
@@ -7,6 +7,7 @@
namespace Drupal\field\Tests;
+use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -54,11 +55,11 @@ class reEnableModuleFieldTest extends WebTestBase {
'type' => 'telephone',
));
$field_storage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'article',
'label' => 'Telephone Number',
- ))->save();
+ ])->save();
entity_get_form_display('node', 'article', 'default')
->setComponent('field_telephone', array(
@@ -105,11 +106,11 @@ class reEnableModuleFieldTest extends WebTestBase {
'type' => 'telephone',
));
$field_storage2->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage2,
'bundle' => 'user',
'label' => 'User Telephone Number',
- ))->save();
+ ])->save();
$this->drupalGet('admin/modules/uninstall');
$this->assertText("The Telephone number field type is used in the following fields: node.field_telephone, user.field_telephone_2");
diff --git a/core/modules/file/src/Tests/FileFieldTestBase.php b/core/modules/file/src/Tests/FileFieldTestBase.php
index ae1507c..903c200 100644
--- a/core/modules/file/src/Tests/FileFieldTestBase.php
+++ b/core/modules/file/src/Tests/FileFieldTestBase.php
@@ -113,7 +113,7 @@ abstract class FileFieldTestBase extends WebTestBase {
'required' => !empty($field_settings['required']),
'settings' => $field_settings,
);
- entity_create('field_config', $field)->save();
+ FieldConfig::create($field)->save();
entity_get_form_display($entity_type, $bundle, 'default')
->setComponent($name, array(
diff --git a/core/modules/file/src/Tests/FileItemTest.php b/core/modules/file/src/Tests/FileItemTest.php
index 2279fa2..3440535 100644
--- a/core/modules/file/src/Tests/FileItemTest.php
+++ b/core/modules/file/src/Tests/FileItemTest.php
@@ -55,12 +55,12 @@ class FileItemTest extends FieldUnitTestBase {
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
$this->directory = $this->getRandomGenerator()->name(8);
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'file_test',
'bundle' => 'entity_test',
'settings' => array('file_directory' => $this->directory),
- ))->save();
+ ])->save();
file_put_contents('public://example.txt', $this->randomMachineName());
$this->file = entity_create('file', array(
'uri' => 'public://example.txt',
diff --git a/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php b/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php
index 0045f59..fc795d9 100644
--- a/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php
+++ b/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php
@@ -7,6 +7,7 @@
namespace Drupal\file\Tests\Views;
+use Drupal\field\Entity\FieldConfig;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestData;
@@ -43,14 +44,14 @@ class RelationshipUserFileDataTest extends ViewTestBase {
'type' => 'file',
'translatable' => '0',
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'label' => 'User File',
'description' => '',
'field_name' => 'user_file',
'entity_type' => 'user',
'bundle' => 'user',
'required' => 0,
- ))->save();
+ ])->save();
ViewTestData::createTestViews(get_class($this), array('file_test_views'));
}
diff --git a/core/modules/hal/src/Tests/NormalizerTestBase.php b/core/modules/hal/src/Tests/NormalizerTestBase.php
index 7aed3cf..bcdde40 100644
--- a/core/modules/hal/src/Tests/NormalizerTestBase.php
+++ b/core/modules/hal/src/Tests/NormalizerTestBase.php
@@ -8,6 +8,7 @@
namespace Drupal\hal\Tests;
use Drupal\Core\Cache\MemoryBackend;
+use Drupal\field\Entity\FieldConfig;
use Drupal\hal\Encoder\JsonEncoder;
use Drupal\hal\Normalizer\ContentEntityNormalizer;
use Drupal\hal\Normalizer\EntityReferenceItemNormalizer;
@@ -99,12 +100,12 @@ abstract class NormalizerTestBase extends KernelTestBase {
'entity_type' => 'entity_test',
'type' => 'text',
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_test_text',
'bundle' => 'entity_test',
'translatable' => FALSE,
- ))->save();
+ ])->save();
// Create the test translatable field.
FieldStorageConfig::create(array(
@@ -112,12 +113,12 @@ abstract class NormalizerTestBase extends KernelTestBase {
'entity_type' => 'entity_test',
'type' => 'text',
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_test_translatable_text',
'bundle' => 'entity_test',
'translatable' => TRUE,
- ))->save();
+ ])->save();
// Create the test entity reference field.
FieldStorageConfig::create(array(
@@ -128,12 +129,12 @@ abstract class NormalizerTestBase extends KernelTestBase {
'target_type' => 'entity_test',
),
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_test_entity_reference',
'bundle' => 'entity_test',
'translatable' => TRUE,
- ))->save();
+ ])->save();
$entity_manager = \Drupal::entityManager();
$link_manager = new LinkManager(new TypeLinkManager(new MemoryBackend('default'), \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack')), new RelationLinkManager(new MemoryBackend('default'), $entity_manager, \Drupal::moduleHandler(), \Drupal::service('config.factory'), \Drupal::service('request_stack')));
diff --git a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
index 30a22fe..07e7575 100644
--- a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
+++ b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
@@ -8,6 +8,7 @@
namespace Drupal\image\Tests;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
+use Drupal\field\Entity\FieldConfig;
use Drupal\file\Entity\File;
use Drupal\field\Entity\FieldStorageConfig;
@@ -83,7 +84,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$this->assertEqual($field_storage->getSettings()['default_image']['uuid'], $default_images['field']->uuid());
// Add another field with another default image to the page content type.
- $field2 = entity_create('field_config', array(
+ $field2 = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'page',
'label' => $field->label(),
@@ -97,7 +98,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
'height' => 0,
),
),
- ));
+ ]);
$field2->save();
$widget_settings = entity_get_form_display('node', $field->getTargetBundle(), 'default')->getComponent($field_name);
@@ -335,7 +336,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
// The non-existent default image should not be saved.
$this->assertNull($settings['default_image']['uuid']);
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'page',
'label' => $this->randomMachineName(),
@@ -344,7 +345,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
'uuid' => 100000,
)
),
- ));
+ ]);
$field->save();
$settings = $field->getSettings();
// The non-existent default image should not be saved.
diff --git a/core/modules/image/src/Tests/ImageFieldTestBase.php b/core/modules/image/src/Tests/ImageFieldTestBase.php
index 13b569d..68c9aae 100644
--- a/core/modules/image/src/Tests/ImageFieldTestBase.php
+++ b/core/modules/image/src/Tests/ImageFieldTestBase.php
@@ -7,6 +7,7 @@
namespace Drupal\image\Tests;
+use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -82,7 +83,7 @@ abstract class ImageFieldTestBase extends WebTestBase {
'cardinality' => !empty($storage_settings['cardinality']) ? $storage_settings['cardinality'] : 1,
))->save();
- $field_config = entity_create('field_config', array(
+ $field_config = FieldConfig::create([
'field_name' => $name,
'label' => $name,
'entity_type' => 'node',
@@ -90,7 +91,7 @@ abstract class ImageFieldTestBase extends WebTestBase {
'required' => !empty($field_settings['required']),
'settings' => $field_settings,
'description' => $description,
- ));
+ ]);
$field_config->save();
entity_get_form_display('node', $type_name, 'default')
diff --git a/core/modules/image/src/Tests/ImageItemTest.php b/core/modules/image/src/Tests/ImageItemTest.php
index c5ee594..5969c41 100644
--- a/core/modules/image/src/Tests/ImageItemTest.php
+++ b/core/modules/image/src/Tests/ImageItemTest.php
@@ -10,6 +10,7 @@ namespace Drupal\image\Tests;
use Drupal\Core\Field\FieldItemInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\FieldUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -51,11 +52,11 @@ class ImageItemTest extends FieldUnitTestBase {
'type' => 'image',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'image_test',
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', 'public://example.jpg');
$this->image = entity_create('file', array(
'uri' => 'public://example.jpg',
diff --git a/core/modules/image/src/Tests/ImageThemeFunctionTest.php b/core/modules/image/src/Tests/ImageThemeFunctionTest.php
index d64899b..e4f7b17 100644
--- a/core/modules/image/src/Tests/ImageThemeFunctionTest.php
+++ b/core/modules/image/src/Tests/ImageThemeFunctionTest.php
@@ -9,6 +9,7 @@ namespace Drupal\image\Tests;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Url;
+use Drupal\field\Entity\FieldConfig;
use Drupal\image\Entity\ImageStyle;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -48,11 +49,11 @@ class ImageThemeFunctionTest extends WebTestBase {
'type' => 'image',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'image_test',
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', 'public://example.jpg');
$this->image = entity_create('file', array(
'uri' => 'public://example.jpg',
diff --git a/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php b/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php
index 3df5e1f..8970a97 100644
--- a/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php
+++ b/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php
@@ -7,6 +7,7 @@
namespace Drupal\image\Tests\Views;
+use Drupal\field\Entity\FieldConfig;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestData;
@@ -43,14 +44,14 @@ class RelationshipUserImageDataTest extends ViewTestBase {
'type' => 'image',
'translatable' => '0',
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'label' => 'User Picture',
'description' => '',
'field_name' => 'user_picture',
'entity_type' => 'user',
'bundle' => 'user',
'required' => 0,
- ))->save();
+ ])->save();
ViewTestData::createTestViews(get_class($this), array('image_test_views'));
}
diff --git a/core/modules/language/src/Entity/ContentLanguageSettings.php b/core/modules/language/src/Entity/ContentLanguageSettings.php
index 7501012..2d9cf28 100644
--- a/core/modules/language/src/Entity/ContentLanguageSettings.php
+++ b/core/modules/language/src/Entity/ContentLanguageSettings.php
@@ -67,7 +67,7 @@ class ContentLanguageSettings extends ConfigEntityBase implements ContentLanguag
* Constructs a ContentLanguageSettings object.
*
* In most cases, Field entities are created via
- * entity_create('field_config', $values), where $values is the same
+ * FieldConfig::create($values), where $values is the same
* parameter as in this constructor.
*
* @param array $values
diff --git a/core/modules/link/src/Tests/LinkFieldTest.php b/core/modules/link/src/Tests/LinkFieldTest.php
index c225686..7fa960c 100644
--- a/core/modules/link/src/Tests/LinkFieldTest.php
+++ b/core/modules/link/src/Tests/LinkFieldTest.php
@@ -10,6 +10,7 @@ namespace Drupal\link\Tests;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Url;
+use Drupal\field\Entity\FieldConfig;
use Drupal\link\LinkItemInterface;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -64,14 +65,14 @@ class LinkFieldTest extends WebTestBase {
'type' => 'link',
));
$this->fieldStorage->save();
- $this->field = entity_create('field_config', array(
+ $this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
'settings' => array(
'title' => DRUPAL_DISABLED,
'link_type' => LinkItemInterface::LINK_GENERIC,
),
- ));
+ ]);
$this->field->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($field_name, array(
@@ -229,7 +230,7 @@ class LinkFieldTest extends WebTestBase {
'type' => 'link',
));
$this->fieldStorage->save();
- $this->field = entity_create('field_config', array(
+ $this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
'label' => 'Read more about this entity',
@@ -237,7 +238,7 @@ class LinkFieldTest extends WebTestBase {
'title' => DRUPAL_OPTIONAL,
'link_type' => LinkItemInterface::LINK_GENERIC,
),
- ));
+ ]);
$this->field->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($field_name, array(
@@ -344,7 +345,7 @@ class LinkFieldTest extends WebTestBase {
'cardinality' => 2,
));
$this->fieldStorage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $this->fieldStorage,
'label' => 'Read more about this entity',
'bundle' => 'entity_test',
@@ -352,7 +353,7 @@ class LinkFieldTest extends WebTestBase {
'title' => DRUPAL_OPTIONAL,
'link_type' => LinkItemInterface::LINK_GENERIC,
),
- ))->save();
+ ])->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($field_name, array(
'type' => 'link_default',
@@ -484,14 +485,14 @@ class LinkFieldTest extends WebTestBase {
'cardinality' => 2,
));
$this->fieldStorage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
'settings' => array(
'title' => DRUPAL_OPTIONAL,
'link_type' => LinkItemInterface::LINK_GENERIC,
),
- ))->save();
+ ])->save();
$display_options = array(
'type' => 'link_separate',
'label' => 'hidden',
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 112e9df..5d7ef4b 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -324,12 +324,12 @@ function node_add_body_field(NodeTypeInterface $type, $label = 'Body') {
$field_storage = FieldStorageConfig::loadByName('node', 'body');
$field = FieldConfig::loadByName('node', $type->id(), 'body');
if (empty($field)) {
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $type->id(),
'label' => $label,
'settings' => array('display_summary' => TRUE),
- ));
+ ]);
$field->save();
// Assign widget settings for the 'default' form mode.
diff --git a/core/modules/node/src/Tests/MultiStepNodeFormBasicOptionsTest.php b/core/modules/node/src/Tests/MultiStepNodeFormBasicOptionsTest.php
index 496994b..9e3803f 100644
--- a/core/modules/node/src/Tests/MultiStepNodeFormBasicOptionsTest.php
+++ b/core/modules/node/src/Tests/MultiStepNodeFormBasicOptionsTest.php
@@ -7,6 +7,7 @@
namespace Drupal\node\Tests;
use Drupal\Component\Utility\Unicode;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
@@ -41,12 +42,12 @@ class MultiStepNodeFormBasicOptionsTest extends NodeTestBase {
))->save();
// Attach an instance of the field to the page content type.
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'node',
'bundle' => 'page',
'label' => $this->randomMachineName() . '_label',
- ))->save();
+ ])->save();
entity_get_form_display('node', 'page', 'default')
->setComponent($this->fieldName, array(
'type' => 'text_textfield',
diff --git a/core/modules/node/src/Tests/NodeAccessFieldTest.php b/core/modules/node/src/Tests/NodeAccessFieldTest.php
index 02ef26f..d9f39b4 100644
--- a/core/modules/node/src/Tests/NodeAccessFieldTest.php
+++ b/core/modules/node/src/Tests/NodeAccessFieldTest.php
@@ -7,6 +7,7 @@
namespace Drupal\node\Tests;
use Drupal\Component\Utility\Unicode;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
@@ -60,11 +61,11 @@ class NodeAccessFieldTest extends NodeTestBase {
'entity_type' => 'node',
'type' => 'text'
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'node',
'bundle' => 'page',
- ))->save();
+ ])->save();
entity_get_display('node', 'page', 'default')
->setComponent($this->fieldName)
->save();
diff --git a/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php b/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php
index 25cba88..3d52bc7 100644
--- a/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php
+++ b/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php
@@ -8,6 +8,7 @@
namespace Drupal\node\Tests;
use Drupal\Core\Language\LanguageInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\node\Entity\NodeType;
use Drupal\user\Entity\User;
@@ -64,7 +65,7 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase {
));
$field_storage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'page',
'widget' => array(
@@ -74,7 +75,7 @@ class NodeAccessLanguageAwareCombinationTest extends NodeTestBase {
'on_label' => 'Private',
'off_label' => 'Not private',
),
- ))->save();
+ ])->save();
// After enabling a node access module, the access table has to be rebuild.
node_access_rebuild();
diff --git a/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php b/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php
index a72f62b..6715cc0 100644
--- a/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php
+++ b/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php
@@ -8,6 +8,7 @@
namespace Drupal\node\Tests;
use Drupal\Core\Language\LanguageInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\user\Entity\User;
use Drupal\field\Entity\FieldStorageConfig;
@@ -61,7 +62,7 @@ class NodeAccessLanguageAwareTest extends NodeTestBase {
));
$field_storage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'page',
'widget' => array(
@@ -71,7 +72,7 @@ class NodeAccessLanguageAwareTest extends NodeTestBase {
'on_label' => 'Private',
'off_label' => 'Not private',
),
- ))->save();
+ ])->save();
// After enabling a node access module, the access table has to be rebuild.
node_access_rebuild();
diff --git a/core/modules/options/src/Tests/OptionsDynamicValuesTestBase.php b/core/modules/options/src/Tests/OptionsDynamicValuesTestBase.php
index 16451d5..c54466d 100644
--- a/core/modules/options/src/Tests/OptionsDynamicValuesTestBase.php
+++ b/core/modules/options/src/Tests/OptionsDynamicValuesTestBase.php
@@ -7,6 +7,7 @@
namespace Drupal\options\Tests;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\FieldTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -51,7 +52,7 @@ abstract class OptionsDynamicValuesTestBase extends FieldTestBase {
]);
$this->fieldStorage->save();
- $this->field = entity_create('field_config', [
+ $this->field = FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test_rev',
'bundle' => 'entity_test_rev',
diff --git a/core/modules/options/src/Tests/OptionsFieldTest.php b/core/modules/options/src/Tests/OptionsFieldTest.php
index fdf1f6d..98d9d09 100644
--- a/core/modules/options/src/Tests/OptionsFieldTest.php
+++ b/core/modules/options/src/Tests/OptionsFieldTest.php
@@ -8,6 +8,7 @@
namespace Drupal\options\Tests;
use Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
@@ -77,12 +78,12 @@ class OptionsFieldTest extends OptionsFieldUnitTestBase {
// Options are reset when a new field with the same name is created.
$this->fieldStorage->delete();
FieldStorageConfig::create($this->fieldStorageDefinition)->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
'required' => TRUE,
- ))->save();
+ ])->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($this->fieldName, array(
'type' => 'options_buttons',
diff --git a/core/modules/options/src/Tests/OptionsFieldUITest.php b/core/modules/options/src/Tests/OptionsFieldUITest.php
index 48a5b9a..360f548 100644
--- a/core/modules/options/src/Tests/OptionsFieldUITest.php
+++ b/core/modules/options/src/Tests/OptionsFieldUITest.php
@@ -7,6 +7,7 @@
namespace Drupal\options\Tests;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Tests\FieldTestBase;
@@ -272,11 +273,11 @@ class OptionsFieldUITest extends FieldTestBase {
'entity_type' => 'node',
'type' => $type,
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $this->fieldName,
'entity_type' => 'node',
'bundle' => $this->type,
- ))->save();
+ ])->save();
entity_get_form_display('node', $this->type, 'default')->setComponent($this->fieldName)->save();
diff --git a/core/modules/options/src/Tests/OptionsFieldUnitTestBase.php b/core/modules/options/src/Tests/OptionsFieldUnitTestBase.php
index 2ce3054..14d4b8d 100644
--- a/core/modules/options/src/Tests/OptionsFieldUnitTestBase.php
+++ b/core/modules/options/src/Tests/OptionsFieldUnitTestBase.php
@@ -7,6 +7,7 @@
namespace Drupal\options\Tests;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\FieldUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -69,10 +70,10 @@ abstract class OptionsFieldUnitTestBase extends FieldUnitTestBase {
$this->fieldStorage = FieldStorageConfig::create($this->fieldStorageDefinition);
$this->fieldStorage->save();
- $this->field = entity_create('field_config', array(
+ $this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
- ));
+ ]);
$this->field->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
diff --git a/core/modules/options/src/Tests/OptionsWidgetsTest.php b/core/modules/options/src/Tests/OptionsWidgetsTest.php
index d162442..679fdb6 100644
--- a/core/modules/options/src/Tests/OptionsWidgetsTest.php
+++ b/core/modules/options/src/Tests/OptionsWidgetsTest.php
@@ -7,6 +7,7 @@
namespace Drupal\options\Tests;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\FieldTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -89,7 +90,7 @@ class OptionsWidgetsTest extends FieldTestBase {
*/
function testRadioButtons() {
// Create an instance of the 'single value' field.
- $field = entity_create('field_config', [
+ $field = FieldConfig::create([
'field_storage' => $this->card1,
'bundle' => 'entity_test',
]);
@@ -146,10 +147,10 @@ class OptionsWidgetsTest extends FieldTestBase {
*/
function testCheckBoxes() {
// Create an instance of the 'multiple values' field.
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'field_storage' => $this->card2,
'bundle' => 'entity_test',
- ));
+ ]);
$field->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($this->card2->getName(), array(
@@ -235,11 +236,11 @@ class OptionsWidgetsTest extends FieldTestBase {
*/
function testSelectListSingle() {
// Create an instance of the 'single value' field.
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'field_storage' => $this->card1,
'bundle' => 'entity_test',
'required' => TRUE,
- ));
+ ]);
$field->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($this->card1->getName(), array(
@@ -335,10 +336,10 @@ class OptionsWidgetsTest extends FieldTestBase {
*/
function testSelectListMultiple() {
// Create an instance of the 'multiple values' field.
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'field_storage' => $this->card2,
'bundle' => 'entity_test',
- ));
+ ]);
$field->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($this->card2->getName(), array(
@@ -456,7 +457,7 @@ class OptionsWidgetsTest extends FieldTestBase {
*/
function testEmptyValue() {
// Create an instance of the 'single value' field.
- $field = entity_create('field_config', [
+ $field = FieldConfig::create([
'field_storage' => $this->card1,
'bundle' => 'entity_test',
]);
diff --git a/core/modules/options/src/Tests/Views/ViewsDataTest.php b/core/modules/options/src/Tests/Views/ViewsDataTest.php
index eb81496..3d17470 100644
--- a/core/modules/options/src/Tests/Views/ViewsDataTest.php
+++ b/core/modules/options/src/Tests/Views/ViewsDataTest.php
@@ -6,6 +6,7 @@
namespace Drupal\options\Tests\Views;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
@@ -45,7 +46,7 @@ class ViewsDataTest extends OptionsTestBase {
]);
$this->fieldStorage->save();
- $this->field = entity_create('field_config', [
+ $this->field = FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
diff --git a/core/modules/quickedit/src/Tests/QuickEditTestBase.php b/core/modules/quickedit/src/Tests/QuickEditTestBase.php
index 1b75bd3..85884ff 100644
--- a/core/modules/quickedit/src/Tests/QuickEditTestBase.php
+++ b/core/modules/quickedit/src/Tests/QuickEditTestBase.php
@@ -7,6 +7,7 @@
namespace Drupal\quickedit\Tests;
+use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\KernelTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -80,14 +81,14 @@ abstract class QuickEditTestBase extends KernelTestBase {
$this->fields->$field_storage->save();
$field = $field_name . '_field';
- $this->fields->$field = entity_create('field_config', array(
+ $this->fields->$field = FieldConfig::create([
'field_storage' => $this->fields->$field_storage,
'bundle' => 'entity_test',
'label' => $label,
'description' => $label,
'weight' => mt_rand(0, 127),
'settings' => $field_settings,
- ));
+ ]);
$this->fields->$field->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
diff --git a/core/modules/rdf/src/Tests/Field/FieldRdfaTestBase.php b/core/modules/rdf/src/Tests/Field/FieldRdfaTestBase.php
index 2696d17..f4d2240 100644
--- a/core/modules/rdf/src/Tests/Field/FieldRdfaTestBase.php
+++ b/core/modules/rdf/src/Tests/Field/FieldRdfaTestBase.php
@@ -6,6 +6,7 @@
namespace Drupal\rdf\Tests\Field;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\FieldUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -120,12 +121,12 @@ abstract class FieldRdfaTestBase extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => $this->fieldType,
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => $this->fieldName,
'bundle' => 'entity_test',
'settings' => $field_settings,
- ))->save();
+ ])->save();
}
/**
diff --git a/core/modules/serialization/src/Tests/EntityResolverTest.php b/core/modules/serialization/src/Tests/EntityResolverTest.php
index 6bc9fb8..481afc3 100644
--- a/core/modules/serialization/src/Tests/EntityResolverTest.php
+++ b/core/modules/serialization/src/Tests/EntityResolverTest.php
@@ -8,6 +8,7 @@ namespace Drupal\serialization\Tests;
use Drupal\Core\Url;
use Drupal\entity_test\Entity\EntityTestMulRev;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
@@ -47,11 +48,11 @@ class EntityResolverTest extends NormalizerTestBase {
))->save();
// Create the test field.
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => 'entity_test_mulrev',
'field_name' => 'field_test_entity_reference',
'bundle' => 'entity_test_mulrev',
- ))->save();
+ ])->save();
}
/**
diff --git a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php
index 4cf47c3..5bcd5d3 100644
--- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php
+++ b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php
@@ -8,6 +8,7 @@
namespace Drupal\simpletest\Tests;
use Drupal\Core\Database\Database;
+use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\KernelTestBase;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
@@ -285,10 +286,10 @@ EOS;
'type' => 'test_field'
));
$field_storage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
}
/**
diff --git a/core/modules/system/src/Tests/Ajax/MultiFormTest.php b/core/modules/system/src/Tests/Ajax/MultiFormTest.php
index c9bfa1e..3d16bca 100644
--- a/core/modules/system/src/Tests/Ajax/MultiFormTest.php
+++ b/core/modules/system/src/Tests/Ajax/MultiFormTest.php
@@ -8,6 +8,7 @@
namespace Drupal\system\Tests\Ajax;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
@@ -38,11 +39,11 @@ class MultiFormTest extends AjaxTestBase {
'type' => 'text',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => 'page',
- ))->save();
+ ])->save();
entity_get_form_display('node', 'page', 'default')
->setComponent($field_name, array('type' => 'text_textfield'))
->save();
diff --git a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
index 07d82ac..53df175 100644
--- a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
+++ b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
@@ -79,13 +79,13 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
'type' => 'test_field',
'settings' => array(),
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => $this->entity->getEntityTypeId(),
'bundle' => $this->entity->bundle(),
'field_name' => 'configurable_field',
'label' => 'Configurable field',
'settings' => array(),
- ))->save();
+ ])->save();
// Reload the entity now that a new field has been added to it.
$storage = $this->container
@@ -255,7 +255,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
'target_type' => $referenced_entity->getEntityTypeId(),
),
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $field_name,
'entity_type' => $entity_type,
'bundle' => $bundle,
@@ -269,7 +269,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
'auto_create' => FALSE,
),
),
- ))->save();
+ ])->save();
if (!$this->entity->getEntityType()->hasHandlerClass('view_builder')) {
entity_get_display($entity_type, $bundle, 'full')
->setComponent($field_name, array(
diff --git a/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php b/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php
index 33a0845..27ad447 100644
--- a/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php
+++ b/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php
@@ -82,12 +82,12 @@ abstract class EntityLanguageTestBase extends EntityUnitTestBase {
'type' => 'text',
'cardinality' => 4,
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $this->fieldName,
'entity_type' => $entity_type,
'bundle' => $entity_type,
'translatable' => TRUE,
- ))->save();
+ ])->save();
$this->field[$entity_type] = FieldConfig::load($entity_type . '.' . $entity_type . '.' . $this->fieldName);
FieldStorageConfig::create(array(
@@ -96,12 +96,12 @@ abstract class EntityLanguageTestBase extends EntityUnitTestBase {
'type' => 'text',
'cardinality' => 4,
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $this->untranslatableFieldName,
'entity_type' => $entity_type,
'bundle' => $entity_type,
'translatable' => FALSE,
- ))->save();
+ ])->save();
}
// Create the default languages.
diff --git a/core/modules/system/src/Tests/Entity/EntityQueryAggregateTest.php b/core/modules/system/src/Tests/Entity/EntityQueryAggregateTest.php
index cc6713d..57fe7c5 100644
--- a/core/modules/system/src/Tests/Entity/EntityQueryAggregateTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityQueryAggregateTest.php
@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Entity;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
@@ -60,11 +61,11 @@ class EntityQueryAggregateTest extends EntityUnitTestBase {
'type' => 'integer',
'cardinality' => 2,
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
}
$entity = $this->entityStorage->create(array(
diff --git a/core/modules/system/src/Tests/Entity/EntityQueryTest.php b/core/modules/system/src/Tests/Entity/EntityQueryTest.php
index 0d4b641..a368298 100644
--- a/core/modules/system/src/Tests/Entity/EntityQueryTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityQueryTest.php
@@ -89,10 +89,10 @@ class EntityQueryTest extends EntityUnitTestBase {
} while ($bundles && strtolower($bundles[0]) >= strtolower($bundle));
entity_test_create_bundle($bundle);
foreach ($field_storages as $field_storage) {
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $bundle,
- ))->save();
+ ])->save();
}
$bundles[] = $bundle;
}
@@ -467,10 +467,10 @@ class EntityQueryTest extends EntityUnitTestBase {
));
$field_storage->save();
$bundle = $this->randomMachineName();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $bundle,
- ))->save();
+ ])->save();
$entity = entity_create('entity_test', array(
'id' => 1,
diff --git a/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php b/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php
index 80b56e5..76992f1 100644
--- a/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php
@@ -8,6 +8,7 @@
namespace Drupal\system\Tests\Entity\EntityReferenceSelection;
use Drupal\Component\Utility\Html;
+use Drupal\field\Entity\FieldConfig;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
@@ -53,14 +54,14 @@ class EntityReferenceSelectionSortTest extends EntityUnitTestBase {
'entity_types' => array('node'),
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'label' => 'Text Field',
'field_name' => 'field_text',
'entity_type' => 'node',
'bundle' => 'article',
'settings' => array(),
'required' => FALSE,
- ))->save();
+ ])->save();
// Build a set of test data.
$node_values = array(
diff --git a/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php b/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php
index 582bf87..9f5028f 100644
--- a/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php
+++ b/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php
@@ -10,6 +10,7 @@ namespace Drupal\system\Tests\Entity;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Database\Database;
use Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
@@ -91,10 +92,10 @@ class FieldSqlStorageTest extends EntityUnitTestBase {
'cardinality' => $this->fieldCardinality,
));
$this->fieldStorage->save();
- $this->field = entity_create('field_config', array(
+ $this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => $entity_type
- ));
+ ]);
$this->field->save();
/** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
@@ -287,11 +288,11 @@ class FieldSqlStorageTest extends EntityUnitTestBase {
'entity_type' => $entity_type,
'type' => 'test_field',
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $field_names[$i],
'entity_type' => $entity_type,
'bundle' => $bundle,
- ))->save();
+ ])->save();
$values[$field_names[$i]] = mt_rand(1, 127);
}
@@ -319,10 +320,10 @@ class FieldSqlStorageTest extends EntityUnitTestBase {
'settings' => array('precision' => 5, 'scale' => 2),
));
$field_storage->save();
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $entity_type,
- ));
+ ]);
$field->save();
$entity = entity_create($entity_type, array(
'id' => 0,
@@ -393,10 +394,10 @@ class FieldSqlStorageTest extends EntityUnitTestBase {
'type' => 'text',
));
$field_storage->save();
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $entity_type,
- ));
+ ]);
$field->save();
$tables = array($this->tableMapping->getDedicatedDataTableName($field_storage), $this->tableMapping->getDedicatedRevisionTableName($field_storage));
diff --git a/core/modules/system/src/Tests/Form/ArbitraryRebuildTest.php b/core/modules/system/src/Tests/Form/ArbitraryRebuildTest.php
index da8d812..7cee618 100644
--- a/core/modules/system/src/Tests/Form/ArbitraryRebuildTest.php
+++ b/core/modules/system/src/Tests/Form/ArbitraryRebuildTest.php
@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Form;
+use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -35,12 +36,12 @@ class ArbitraryRebuildTest extends WebTestBase {
'cardinality' => -1,
'translatable' => FALSE,
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => 'user',
'field_name' => 'test_multiple',
'bundle' => 'user',
'label' => 'Test a multiple valued field',
- ))->save();
+ ])->save();
entity_get_form_display('user', 'user', 'register')
->setComponent('test_multiple', array(
'type' => 'text_textfield',
diff --git a/core/modules/system/src/Tests/Form/RebuildTest.php b/core/modules/system/src/Tests/Form/RebuildTest.php
index 161b1b7..277b477 100644
--- a/core/modules/system/src/Tests/Form/RebuildTest.php
+++ b/core/modules/system/src/Tests/Form/RebuildTest.php
@@ -9,6 +9,7 @@ namespace Drupal\system\Tests\Form;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Url;
+use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -80,11 +81,11 @@ class RebuildTest extends WebTestBase {
'type' => 'text',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => 'page',
- ))->save();
+ ])->save();
entity_get_form_display('node', 'page', 'default')
->setComponent($field_name, array('type' => 'text_textfield'))
->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 b6369da..5e3bcaa 100644
--- a/core/modules/system/tests/modules/entity_test/entity_test.install
+++ b/core/modules/system/tests/modules/entity_test/entity_test.install
@@ -7,6 +7,7 @@
use Drupal\system\Tests\Update\DbUpdatesTrait;
use Drupal\field\Entity\FieldStorageConfig;
+use Drupal\field\Entity\FieldConfig;
/**
* Implements hook_install().
@@ -20,13 +21,13 @@ function entity_test_install() {
'type' => 'text',
'cardinality' => 1,
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => $entity_type,
'field_name' => 'field_test_text',
'bundle' => $entity_type,
'label' => 'Test text-field',
'translatable' => FALSE,
- ))->save();
+ ])->save();
entity_get_form_display($entity_type, $entity_type, 'default')
->setComponent('field_test_text', array('type' => 'text_textfield'))
diff --git a/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php b/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php
index b4c9d78..faceca2 100644
--- a/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php
+++ b/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php
@@ -7,6 +7,7 @@
namespace Drupal\taxonomy\Tests;
+use Drupal\field\Entity\FieldConfig;
use Drupal\user\RoleInterface;
use Drupal\file\Entity\File;
use Drupal\field\Entity\FieldStorageConfig;
@@ -50,12 +51,12 @@ class TaxonomyImageTest extends TaxonomyTestBase {
'uri_scheme' => 'private',
),
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $name,
'entity_type' => $entity_type,
'bundle' => $this->vocabulary->id(),
'settings' => array(),
- ))->save();
+ ])->save();
entity_get_display($entity_type, $this->vocabulary->id(), 'default')
->setComponent($name, array(
'type' => 'image',
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php
index 446b2f0..23474b4 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php
+++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php
@@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Tests\Views;
use Drupal\Core\Language\LanguageInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
@@ -75,12 +76,12 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
'type' => 'text',
));
$field->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => 'field_foo',
'entity_type' => 'taxonomy_term',
'label' => 'Foo',
'bundle' => 'views_testing_tags',
- ))->save();
+ ])->save();
// Create term with translations.
$taxonomy = $this->createTermWithProperties(array('name' => $this->termNames['en'], 'langcode' => 'en', 'description' => $this->termNames['en'], 'field_foo' => $this->termNames['en']));
diff --git a/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php
index cb967f0..d30bc3f 100644
--- a/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php
+++ b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php
@@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Tests;
use Drupal\Component\Utility\Unicode;
+use Drupal\field\Entity\FieldConfig;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\field\Entity\FieldStorageConfig;
@@ -162,7 +163,7 @@ class VocabularyCrudTest extends TaxonomyTestBase {
'bundle' => $this->vocabulary->id(),
'label' => $this->randomMachineName() . '_label',
);
- entity_create('field_config', $field_definition)->save();
+ FieldConfig::create($field_definition)->save();
// Remove the third party setting from the memory copy of the vocabulary.
// We keep this invalid copy around while the taxonomy module is not even
@@ -180,6 +181,6 @@ class VocabularyCrudTest extends TaxonomyTestBase {
$this->vocabulary->enforceIsNew();
$this->vocabulary->save();
FieldStorageConfig::create($storage_definition)->save();
- entity_create('field_config', $field_definition)->save();
+ FieldConfig::create($field_definition)->save();
}
}
diff --git a/core/modules/telephone/src/Tests/TelephoneFieldTest.php b/core/modules/telephone/src/Tests/TelephoneFieldTest.php
index 2942d1a..8928e8d 100644
--- a/core/modules/telephone/src/Tests/TelephoneFieldTest.php
+++ b/core/modules/telephone/src/Tests/TelephoneFieldTest.php
@@ -7,6 +7,7 @@
namespace Drupal\telephone\Tests;
+use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -56,12 +57,12 @@ class TelephoneFieldTest extends WebTestBase {
'entity_type' => 'node',
'type' => 'telephone',
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => 'field_telephone',
'label' => 'Telephone Number',
'entity_type' => 'node',
'bundle' => 'article',
- ))->save();
+ ])->save();
entity_get_form_display('node', 'article', 'default')
->setComponent('field_telephone', array(
diff --git a/core/modules/telephone/src/Tests/TelephoneItemTest.php b/core/modules/telephone/src/Tests/TelephoneItemTest.php
index d6b6549..be0163f 100644
--- a/core/modules/telephone/src/Tests/TelephoneItemTest.php
+++ b/core/modules/telephone/src/Tests/TelephoneItemTest.php
@@ -9,6 +9,7 @@ namespace Drupal\telephone\Tests;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldItemInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\FieldUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -35,11 +36,11 @@ class TelephoneItemTest extends FieldUnitTestBase {
'entity_type' => 'entity_test',
'type' => 'telephone',
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_test',
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
}
/**
diff --git a/core/modules/text/src/Tests/Formatter/TextFormatterTest.php b/core/modules/text/src/Tests/Formatter/TextFormatterTest.php
index cd4a86c..eb141cb 100644
--- a/core/modules/text/src/Tests/Formatter/TextFormatterTest.php
+++ b/core/modules/text/src/Tests/Formatter/TextFormatterTest.php
@@ -7,6 +7,7 @@
namespace Drupal\text\Tests\Formatter;
+use Drupal\field\Entity\FieldConfig;
use Drupal\filter\Entity\FilterFormat;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -62,12 +63,12 @@ class TextFormatterTest extends EntityUnitTestBase {
'type' => 'text',
'settings' => array(),
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'entity_type' => $this->entityType,
'bundle' => $this->bundle,
'field_name' => 'formatted_text',
'label' => 'Filtered text',
- ))->save();
+ ])->save();
}
/**
diff --git a/core/modules/text/src/Tests/TextFieldTest.php b/core/modules/text/src/Tests/TextFieldTest.php
index cb46bea..13df966 100644
--- a/core/modules/text/src/Tests/TextFieldTest.php
+++ b/core/modules/text/src/Tests/TextFieldTest.php
@@ -8,6 +8,7 @@
namespace Drupal\text\Tests;
use Drupal\Component\Utility\Unicode;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\String\StringFieldTest;
use Drupal\field\Entity\FieldStorageConfig;
@@ -49,10 +50,10 @@ class TextFieldTest extends StringFieldTest {
)
));
$field_storage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
- ))->save();
+ ])->save();
// Test validation with valid and invalid values.
$entity = entity_create('entity_test');
@@ -80,12 +81,12 @@ class TextFieldTest extends StringFieldTest {
'type' => 'text_with_summary',
));
$field_storage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
'label' => $this->randomMachineName() . '_label',
'required' => TRUE,
- ))->save();
+ ])->save();
// Create a file field.
$file_field_name = 'file_field';
@@ -95,11 +96,11 @@ class TextFieldTest extends StringFieldTest {
'type' => 'file'
));
$field_storage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
'label' => $this->randomMachineName() . '_label',
- ))->save();
+ ])->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($text_field_name, array(
@@ -158,11 +159,11 @@ class TextFieldTest extends StringFieldTest {
'type' => $field_type
));
$field_storage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'entity_test',
'label' => $this->randomMachineName() . '_label',
- ))->save();
+ ])->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($field_name, array(
'type' => $widget_type,
diff --git a/core/modules/text/src/Tests/TextWithSummaryItemTest.php b/core/modules/text/src/Tests/TextWithSummaryItemTest.php
index 7e78980..1879919 100644
--- a/core/modules/text/src/Tests/TextWithSummaryItemTest.php
+++ b/core/modules/text/src/Tests/TextWithSummaryItemTest.php
@@ -9,6 +9,7 @@ namespace Drupal\text\Tests;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldItemInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\FieldUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -108,10 +109,10 @@ class TextWithSummaryItemTest extends FieldUnitTestBase {
)
));
$this->fieldStorage->save();
- $this->field = entity_create('field_config', array(
+ $this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => $entity_type,
- ));
+ ]);
$this->field->save();
}
diff --git a/core/modules/user/src/Tests/UserCreateTest.php b/core/modules/user/src/Tests/UserCreateTest.php
index 8ad3905..481c267 100644
--- a/core/modules/user/src/Tests/UserCreateTest.php
+++ b/core/modules/user/src/Tests/UserCreateTest.php
@@ -7,6 +7,7 @@
namespace Drupal\user\Tests;
+use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -50,7 +51,7 @@ class UserCreateTest extends WebTestBase {
),
))->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'user',
'label' => 'Picture',
@@ -66,7 +67,7 @@ class UserCreateTest extends WebTestBase {
'max_resolution' => '85x85',
'min_resolution' => '',
),
- ))->save();
+ ])->save();
// Test user creation page for valid fields.
$this->drupalGet('admin/people/create');
diff --git a/core/modules/user/src/Tests/UserRegistrationTest.php b/core/modules/user/src/Tests/UserRegistrationTest.php
index ad33d83..bb6bbd7 100644
--- a/core/modules/user/src/Tests/UserRegistrationTest.php
+++ b/core/modules/user/src/Tests/UserRegistrationTest.php
@@ -295,12 +295,12 @@ class UserRegistrationTest extends WebTestBase {
'cardinality' => 1,
));
$field_storage->save();
- $field = entity_create('field_config', array(
+ $field = FieldConfig::create([
'field_storage' => $field_storage,
'label' => 'Some user field',
'bundle' => 'user',
'required' => TRUE,
- ));
+ ]);
$field->save();
entity_get_form_display('user', 'user', 'default')
->setComponent('test_user_field', array('type' => 'test_field_widget'))
diff --git a/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php b/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php
index a46e509..128a259 100644
--- a/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php
+++ b/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php
@@ -8,6 +8,7 @@
namespace Drupal\views\Tests\Entity;
use Drupal\Component\Utility\Unicode;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\views\Tests\ViewTestData;
use Drupal\views\Tests\ViewKernelTestBase;
@@ -64,7 +65,7 @@ class ViewEntityDependenciesTest extends ViewKernelTestBase {
'type' => 'comment',
));
$field_storage->save();
- entity_create('field_config', array(
+ FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => $content_type->id(),
'label' => $this->randomMachineName() . '_label',
@@ -72,13 +73,13 @@ class ViewEntityDependenciesTest extends ViewKernelTestBase {
'settings' => array(
'comment_type' => $comment_type->id(),
),
- ))->save();
- entity_create('field_config', array(
+ ])->save();
+ FieldConfig::create([
'field_storage' => FieldStorageConfig::loadByName('node', 'body'),
'bundle' => $content_type->id(),
'label' => $this->randomMachineName() . '_body',
'settings' => array('display_summary' => TRUE),
- ))->save();
+ ])->save();
ViewTestData::createTestViews(get_class($this), array('views_test_config'));
}
diff --git a/core/modules/views/src/Tests/FieldApiDataTest.php b/core/modules/views/src/Tests/FieldApiDataTest.php
index 72ee0be..68e1250 100644
--- a/core/modules/views/src/Tests/FieldApiDataTest.php
+++ b/core/modules/views/src/Tests/FieldApiDataTest.php
@@ -30,7 +30,7 @@ class FieldApiDataTest extends FieldTestBase {
'bundle' => 'page',
'label' => 'GiraffeA" label'
);
- entity_create('field_config', $field)->save();
+ FieldConfig::create($field)->save();
// Attach the same field to a different bundle with a different label.
$this->drupalCreateContentType(['type' => 'article']);
diff --git a/core/modules/views/src/Tests/Handler/FieldGroupRowsTest.php b/core/modules/views/src/Tests/Handler/FieldGroupRowsTest.php
index a7d278b..fa1a6aa 100644
--- a/core/modules/views/src/Tests/Handler/FieldGroupRowsTest.php
+++ b/core/modules/views/src/Tests/Handler/FieldGroupRowsTest.php
@@ -9,6 +9,7 @@ namespace Drupal\views\Tests\Handler;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Render\RenderContext;
+use Drupal\field\Entity\FieldConfig;
use Drupal\views\Views;
use Drupal\field\Entity\FieldStorageConfig;
@@ -62,7 +63,7 @@ class FieldGroupRowsTest extends HandlerTestBase {
'field_storage' => $field_storage,
'bundle' => $node_type->id(),
);
- entity_create('field_config', $field)->save();
+ FieldConfig::create($field)->save();
}
/**
diff --git a/core/modules/views/src/Tests/Wizard/TaggedWithTest.php b/core/modules/views/src/Tests/Wizard/TaggedWithTest.php
index e62c1737..b259493 100644
--- a/core/modules/views/src/Tests/Wizard/TaggedWithTest.php
+++ b/core/modules/views/src/Tests/Wizard/TaggedWithTest.php
@@ -8,6 +8,7 @@
namespace Drupal\views\Tests\Wizard;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
/**
@@ -201,7 +202,7 @@ class TaggedWithTest extends WizardTestBase {
// If we add an instance of the tagging field to the second node type, the
// "tagged with" form element should not appear for it too.
- entity_create('field_config', array(
+ FieldConfig::create([
'field_name' => $this->tagFieldName,
'entity_type' => 'node',
'bundle' => $this->nodeTypeWithoutTags->id(),
@@ -214,7 +215,7 @@ class TaggedWithTest extends WizardTestBase {
'auto_create' => TRUE,
),
),
- ))->save();
+ ])->save();
entity_get_form_display('node', $this->nodeTypeWithoutTags->id(), 'default')
->setComponent($this->tagFieldName, array(
'type' => 'entity_reference_autocomplete_tags',