Commit 35372e59 authored by catch's avatar catch

Issue #2491009 by trwad: Replace deprecated usage of entity_create with a...

Issue #2491009 by trwad: Replace deprecated usage of entity_create with a direct call to the entity type class in Field UI module
parent ae4a224e
......@@ -7,7 +7,11 @@
namespace Drupal\field_ui\Tests;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\Core\Entity\Entity\EntityViewMode;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\node\Entity\NodeType;
use Drupal\simpletest\KernelTestBase;
/**
......@@ -34,7 +38,7 @@ protected function setUp() {
* Tests basic CRUD operations on entity display objects.
*/
public function testEntityDisplayCRUD() {
$display = entity_create('entity_view_display', array(
$display = EntityViewDisplay::create(array(
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
......@@ -108,7 +112,7 @@ public function testEntityDisplayCRUD() {
* Test sorting of components by name on basic CRUD operations
*/
public function testEntityDisplayCRUDSort() {
$display = entity_create('entity_view_display', array(
$display = EntityViewDisplay::create(array(
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
......@@ -148,7 +152,7 @@ public function testEntityGetDisplay() {
*/
public function testExtraFieldComponent() {
entity_test_create_bundle('bundle_with_extra_fields');
$display = entity_create('entity_view_display', array(
$display = EntityViewDisplay::create(array(
'targetEntityType' => 'entity_test',
'bundle' => 'bundle_with_extra_fields',
'mode' => 'default',
......@@ -172,19 +176,19 @@ public function testExtraFieldComponent() {
public function testFieldComponent() {
$field_name = 'test_field';
// Create a field storage and a field.
$field_storage = entity_create('field_storage_config', array(
$field_storage = FieldStorageConfig::create(array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field'
));
$field_storage->save();
$field = entity_create('field_config', array(
$field = FieldConfig::create(array(
'field_storage' => $field_storage,
'bundle' => 'entity_test',
));
$field->save();
$display = entity_create('entity_view_display', array(
$display = EntityViewDisplay::create(array(
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
......@@ -234,7 +238,7 @@ public function testFieldComponent() {
* Tests the behavior of a field component for a base field.
*/
public function testBaseFieldComponent() {
$display = entity_create('entity_view_display', array(
$display = EntityViewDisplay::create(array(
'targetEntityType' => 'entity_test_base_field_display',
'bundle' => 'entity_test_base_field_display',
'mode' => 'default',
......@@ -296,7 +300,7 @@ public function testBaseFieldComponent() {
*/
public function testRenameDeleteBundle() {
// Create a node bundle, display and form display object.
$type = entity_create('node_type', array('type' => 'article'));
$type = NodeType::create(array('type' => 'article'));
$type->save();
node_add_body_field($type);
entity_get_display('node', 'article', 'default')->save();
......@@ -349,13 +353,13 @@ public function testRenameDeleteBundle() {
public function testDeleteField() {
$field_name = 'test_field';
// Create a field storage and a field.
$field_storage = entity_create('field_storage_config', array(
$field_storage = FieldStorageConfig::create(array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field'
));
$field_storage->save();
$field = entity_create('field_config', array(
$field = FieldConfig::create(array(
'field_storage' => $field_storage,
'bundle' => 'entity_test',
));
......@@ -363,12 +367,12 @@ public function testDeleteField() {
// Create default and teaser entity display.
EntityViewMode::create(array('id' => 'entity_test.teaser', 'targetEntityType' => 'entity_test'))->save();
entity_create('entity_view_display', array(
EntityViewDisplay::create(array(
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
))->setComponent($field_name)->save();
entity_create('entity_view_display', array(
EntityViewDisplay::create(array(
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'teaser',
......@@ -398,19 +402,19 @@ public function testOnDependencyRemoval() {
$field_name = 'test_field';
// Create a field.
$field_storage = entity_create('field_storage_config', array(
$field_storage = FieldStorageConfig::create(array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'text'
));
$field_storage->save();
$field = entity_create('field_config', array(
$field = FieldConfig::create(array(
'field_storage' => $field_storage,
'bundle' => 'entity_test',
));
$field->save();
entity_create('entity_view_display', array(
EntityViewDisplay::create(array(
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
......
......@@ -7,7 +7,10 @@
namespace Drupal\field_ui\Tests;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Entity\Entity\EntityFormMode;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\simpletest\KernelTestBase;
/**
......@@ -54,19 +57,19 @@ public function testEntityGetFromDisplay() {
public function testFieldComponent() {
// Create a field storage and a field.
$field_name = 'test_field';
$field_storage = entity_create('field_storage_config', array(
$field_storage = FieldStorageConfig::create(array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field'
));
$field_storage->save();
$field = entity_create('field_config', array(
$field = FieldConfig::create(array(
'field_storage' => $field_storage,
'bundle' => 'entity_test',
));
$field->save();
$form_display = entity_create('entity_form_display', array(
$form_display = EntityFormDisplay::create(array(
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
......@@ -121,7 +124,7 @@ public function testFieldComponent() {
* Tests the behavior of a field component for a base field.
*/
public function testBaseFieldComponent() {
$display = entity_create('entity_form_display', array(
$display = EntityFormDisplay::create(array(
'targetEntityType' => 'entity_test_base_field_display',
'bundle' => 'entity_test_base_field_display',
'mode' => 'default',
......@@ -182,13 +185,13 @@ public function testBaseFieldComponent() {
public function testDeleteField() {
$field_name = 'test_field';
// Create a field storage and a field.
$field_storage = entity_create('field_storage_config', array(
$field_storage = FieldStorageConfig::create(array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field'
));
$field_storage->save();
$field = entity_create('field_config', array(
$field = FieldConfig::create(array(
'field_storage' => $field_storage,
'bundle' => 'entity_test',
));
......@@ -196,12 +199,12 @@ public function testDeleteField() {
// Create default and compact entity display.
EntityFormMode::create(array('id' => 'entity_test.compact', 'targetEntityType' => 'entity_test'))->save();
entity_create('entity_form_display', array(
EntityFormDisplay::create(array(
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
))->setComponent($field_name)->save();
entity_create('entity_form_display', array(
EntityFormDisplay::create(array(
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'compact',
......@@ -231,19 +234,19 @@ public function testOnDependencyRemoval() {
$field_name = 'test_field';
// Create a field.
$field_storage = entity_create('field_storage_config', array(
$field_storage = FieldStorageConfig::create(array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'text'
));
$field_storage->save();
$field = entity_create('field_config', array(
$field = FieldConfig::create(array(
'field_storage' => $field_storage,
'bundle' => 'entity_test',
));
$field->save();
entity_create('entity_form_display', array(
EntityFormDisplay::create(array(
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
......
......@@ -7,6 +7,8 @@
namespace Drupal\field_ui\Tests;
use Drupal\Core\Entity\Entity\EntityFormMode;
use Drupal\Core\Entity\Entity\EntityViewMode;
use Drupal\simpletest\WebTestBase;
/**
......@@ -75,7 +77,7 @@ public function testFieldUIRoutes() {
// Create new view mode and verify it's available on the Manage Display
// screen after enabling it.
entity_create('entity_view_mode' ,array(
EntityViewMode::create(array(
'id' => 'user.test',
'label' => 'Test',
'targetEntityType' => 'user',
......@@ -88,7 +90,7 @@ public function testFieldUIRoutes() {
// Create new form mode and verify it's available on the Manage Form
// Display screen after enabling it.
entity_create('entity_form_mode' ,array(
EntityFormMode::create(array(
'id' => 'user.test',
'label' => 'Test',
'targetEntityType' => 'user',
......
......@@ -10,7 +10,9 @@
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\node\Entity\NodeType;
use Drupal\simpletest\WebTestBase;
use Drupal\taxonomy\Entity\Vocabulary;
/**
* Tests the Field UI "Manage display" and "Manage form display" screens.
......@@ -45,7 +47,7 @@ protected function setUp() {
$this->type = $type->id();
// Create a default vocabulary.
$vocabulary = entity_create('taxonomy_vocabulary', array(
$vocabulary = Vocabulary::create(array(
'name' => $this->randomMachineName(),
'description' => $this->randomMachineName(),
'vid' => Unicode::strtolower($this->randomMachineName()),
......@@ -375,7 +377,7 @@ function testSingleViewMode() {
*/
function testNoFieldsDisplayOverview() {
// Create a fresh content type without any fields.
entity_create('node_type', array(
NodeType::create(array(
'type' => 'no_fields',
'name' => 'No fields',
))->save();
......
......@@ -14,6 +14,7 @@
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\taxonomy\Entity\Vocabulary;
/**
* Tests the Field UI "Manage fields" screen.
......@@ -86,7 +87,7 @@ protected function setUp() {
$this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
// Create a vocabulary named "Tags".
$vocabulary = entity_create('taxonomy_vocabulary', array(
$vocabulary = Vocabulary::create(array(
'name' => 'Tags',
'vid' => 'tags',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
......@@ -366,12 +367,12 @@ function testFieldPrefix() {
function testDefaultValue() {
// Create a test field storage and field.
$field_name = 'test';
entity_create('field_storage_config', array(
FieldStorageConfig::create(array(
'field_name' => $field_name,
'entity_type' => 'node',
'type' => 'test_field'
))->save();
$field = entity_create('field_config', array(
$field = FieldConfig::create(array(
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => $this->contentType,
......@@ -503,7 +504,7 @@ function testLockedField() {
// Create a locked field and attach it to a bundle. We need to do this
// programmatically as there's no way to create a locked field through UI.
$field_name = strtolower($this->randomMachineName(8));
$field_storage = entity_create('field_storage_config', array(
$field_storage = FieldStorageConfig::create(array(
'field_name' => $field_name,
'entity_type' => 'node',
'type' => 'test_field',
......@@ -511,7 +512,7 @@ function testLockedField() {
'locked' => TRUE
));
$field_storage->save();
entity_create('field_config', array(
FieldConfig::create(array(
'field_storage' => $field_storage,
'bundle' => $this->contentType,
))->save();
......@@ -544,7 +545,7 @@ function testHiddenFields() {
// Create a field storage and a field programmatically.
$field_name = 'hidden_test_field';
entity_create('field_storage_config', array(
FieldStorageConfig::create(array(
'field_name' => $field_name,
'entity_type' => 'node',
'type' => $field_name,
......@@ -555,7 +556,7 @@ function testHiddenFields() {
'entity_type' => 'node',
'label' => t('Hidden field'),
);
entity_create('field_config', $field)->save();
FieldConfig::create($field)->save();
entity_get_form_display('node', $this->contentType, 'default')
->setComponent($field_name)
->save();
......@@ -638,13 +639,13 @@ function testDeleteTaxonomyField() {
*/
function testHelpDescriptions() {
// Create an image field
entity_create('field_storage_config', array(
FieldStorageConfig::create(array(
'field_name' => 'field_image',
'entity_type' => 'node',
'type' => 'image',
))->save();
entity_create('field_config', array(
FieldConfig::create(array(
'field_name' => 'field_image',
'entity_type' => 'node',
'label' => 'Image',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment