diff --git a/core/modules/field_ui/src/Tests/EntityDisplayTest.php b/core/modules/field_ui/src/Tests/EntityDisplayTest.php index 926f1c9b24fb1d31de997793456fd99c250d72e2..82dc8ab72b57e656e46cac71a71bdeb1f60d8a6f 100644 --- a/core/modules/field_ui/src/Tests/EntityDisplayTest.php +++ b/core/modules/field_ui/src/Tests/EntityDisplayTest.php @@ -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', diff --git a/core/modules/field_ui/src/Tests/EntityFormDisplayTest.php b/core/modules/field_ui/src/Tests/EntityFormDisplayTest.php index 1e5ac237b4c1574b2030f7a1205738f58385e06c..0f8cc6b3dba07034df6496c0255fedb6baca5694 100644 --- a/core/modules/field_ui/src/Tests/EntityFormDisplayTest.php +++ b/core/modules/field_ui/src/Tests/EntityFormDisplayTest.php @@ -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', diff --git a/core/modules/field_ui/src/Tests/FieldUIRouteTest.php b/core/modules/field_ui/src/Tests/FieldUIRouteTest.php index 5fd8ec0cf14def85d63bde27c4188cad50a87d17..332a87d86c035bc421faad41f40470c904fe66f2 100644 --- a/core/modules/field_ui/src/Tests/FieldUIRouteTest.php +++ b/core/modules/field_ui/src/Tests/FieldUIRouteTest.php @@ -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', diff --git a/core/modules/field_ui/src/Tests/ManageDisplayTest.php b/core/modules/field_ui/src/Tests/ManageDisplayTest.php index 5beae64df5e1a943992bc1b22c2dfede3664127d..25294c46dfb2cc35597ddcfecee4999d8df7dc87 100644 --- a/core/modules/field_ui/src/Tests/ManageDisplayTest.php +++ b/core/modules/field_ui/src/Tests/ManageDisplayTest.php @@ -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(); diff --git a/core/modules/field_ui/src/Tests/ManageFieldsTest.php b/core/modules/field_ui/src/Tests/ManageFieldsTest.php index 0d365aa77cd44ba10b5aed040d618302ad5ed8a6..58684a04f3acf72fdfa03c5d57ddfb0c5b419c9c 100644 --- a/core/modules/field_ui/src/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/src/Tests/ManageFieldsTest.php @@ -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',