diff --git a/src/Tests/TokenFieldUiTest.php b/src/Tests/TokenFieldUiTest.php index f7983e7..07f5ffe 100644 --- a/src/Tests/TokenFieldUiTest.php +++ b/src/Tests/TokenFieldUiTest.php @@ -41,50 +41,50 @@ class TokenFieldUiTest extends TokenTestBase { ]); $node_type->save(); - entity_create('field_storage_config', array( + \Drupal::entityTypeManager()->getStorage('field_storage_config')->create([ 'field_name' => 'field_body', 'entity_type' => 'node', 'type' => 'text_with_summary', - ))->save(); - entity_create('field_config', array( + ])->save(); + \Drupal::entityTypeManager()->getStorage('field_config')->create([ 'field_name' => 'field_body', 'label' => 'Body', 'entity_type' => 'node', 'bundle' => 'article', - ))->save(); - entity_create('field_storage_config', array( + ])->save(); + \Drupal::entityTypeManager()->getStorage('field_storage_config')->create([ 'field_name' => 'field_image', 'entity_type' => 'node', 'type' => 'image', - ))->save(); - entity_create('field_config', array( + ])->save(); + \Drupal::entityTypeManager()->getStorage('field_config')->create([ 'field_name' => 'field_image', 'label' => 'Image', 'entity_type' => 'node', 'bundle' => 'article', - ))->save(); - entity_create('field_storage_config', array( + ])->save(); + \Drupal::entityTypeManager()->getStorage('field_storage_config')->create([ 'field_name' => 'field_image_2', 'entity_type' => 'node', 'type' => 'image', - ))->save(); - entity_create('field_config', array( + ])->save(); + \Drupal::entityTypeManager()->getStorage('field_config')->create([ 'field_name' => 'field_image_2', 'label' => 'Image 2', 'entity_type' => 'node', 'bundle' => 'article', - ))->save(); - entity_create('field_storage_config', array( + ])->save(); + \Drupal::entityTypeManager()->getStorage('field_storage_config')->create([ 'field_name' => 'multivalued_field_image', 'entity_type' => 'node', 'type' => 'image', - ))->save(); - entity_create('field_config', array( + ])->save(); + \Drupal::entityTypeManager()->getStorage('field_config')->create([ 'field_name' => 'multivalued_field_image', 'label' => 'Multivalued field image', 'entity_type' => 'node', 'bundle' => 'article', - ))->save(); + ])->save(); entity_get_form_display('node', 'article', 'default') ->setComponent('field_body', [ diff --git a/src/Tests/TokenMenuTest.php b/src/Tests/TokenMenuTest.php index b9eb920..1a520d2 100644 --- a/src/Tests/TokenMenuTest.php +++ b/src/Tests/TokenMenuTest.php @@ -35,11 +35,11 @@ class TokenMenuTest extends TokenTestBase { // Make sure we have a body field on the node type. $this->drupalCreateContentType(['type' => 'page']); // Add a menu. - $menu = entity_create('menu', array( + $menu = \Drupal::entityTypeManager()->getStorage('menu')->create([ 'id' => 'main-menu', 'label' => 'Main menu', 'description' => 'The Main menu is used on many sites to show the major sections of the site, often in a top navigation bar.', - )); + ]); $menu->save(); // Place the menu block. @@ -47,21 +47,21 @@ class TokenMenuTest extends TokenTestBase { // Add a root link. /** @var \Drupal\menu_link_content\Plugin\Menu\MenuLinkContent $root_link */ - $root_link = entity_create('menu_link_content', array( + $root_link = \Drupal::entityTypeManager()->getStorage('menu_link_content')->create([ 'link' => ['uri' => 'internal:/admin'], 'title' => 'Administration', 'menu_name' => 'main-menu', - )); + ]); $root_link->save(); // Add another link with the root link as the parent. /** @var \Drupal\menu_link_content\Plugin\Menu\MenuLinkContent $parent_link */ - $parent_link = entity_create('menu_link_content', array( + $parent_link = \Drupal::entityTypeManager()->getStorage('menu_link_content')->create([ 'link' => ['uri' => 'internal:/admin/config'], 'title' => 'Configuration', 'menu_name' => 'main-menu', 'parent' => $root_link->getPluginId(), - )); + ]); $parent_link->save(); // Test menu link tokens. @@ -103,12 +103,12 @@ class TokenMenuTest extends TokenTestBase { // Add a node menu link. /** @var \Drupal\menu_link_content\Plugin\Menu\MenuLinkContent $node_link */ - $node_link = entity_create('menu_link_content', array( + $node_link = \Drupal::entityTypeManager()->getStorage('menu_link_content')->create([ 'link' => ['uri' =>'entity:node/' . $node->id()], 'title' => 'Node link', 'parent' => $parent_link->getPluginId(), 'menu_name' => 'main-menu', - )); + ]); $node_link->save(); // Test [node:menu] tokens. @@ -264,14 +264,14 @@ class TokenMenuTest extends TokenTestBase { $this->assertText('page ' . $node_title . ' has been created'); $node = $this->drupalGetNodeByTitle($node_title); - $menu_ui_link1 = entity_create('menu_link_content', [ + $menu_ui_link1 = \Drupal::entityTypeManager()->getStorage('menu_link_content')->create([ 'link' => ['uri' => 'entity:node/' . $node->id()], 'title' => 'menu link 1 provided by menu ui', 'menu_name' => 'main-menu', ]); $menu_ui_link1->save(); - $menu_ui_link2 = entity_create('menu_link_content', [ + $menu_ui_link2 = \Drupal::entityTypeManager()->getStorage('menu_link_content')->create([ 'link' => ['uri' => 'entity:node/' . $node->id()], 'title' => 'menu link 2 provided by menu ui', 'menu_name' => 'main-menu', diff --git a/tests/src/Kernel/EntityTest.php b/tests/src/Kernel/EntityTest.php index 7ff471d..dddf976 100644 --- a/tests/src/Kernel/EntityTest.php +++ b/tests/src/Kernel/EntityTest.php @@ -68,7 +68,7 @@ class EntityTest extends KernelTestBase { 'name' => Unicode::strtolower($this->randomMachineName(5)), 'vid' => $vocabulary->id(), ); - $term = entity_create('taxonomy_term', $term); + $term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->create($term); $term->save(); return $term; } diff --git a/tests/src/Kernel/FileTest.php b/tests/src/Kernel/FileTest.php index 3a6a7fd..c86f11b 100644 --- a/tests/src/Kernel/FileTest.php +++ b/tests/src/Kernel/FileTest.php @@ -26,13 +26,13 @@ class FileTest extends KernelTestBase { function testFileTokens() { // Create a test file object. - $file = entity_create('file', array( + $file = \Drupal::entityTypeManager()->getStorage('file')->create([ 'fid' => 1, 'filename' => 'test.png', 'filesize' => 100, 'uri' => 'public://images/test.png', 'filemime' => 'image/png', - )); + ]); $tokens = array( 'basename' => 'test.png', diff --git a/tests/src/Kernel/TaxonomyTest.php b/tests/src/Kernel/TaxonomyTest.php index 73274df..403e054 100644 --- a/tests/src/Kernel/TaxonomyTest.php +++ b/tests/src/Kernel/TaxonomyTest.php @@ -104,7 +104,10 @@ class TaxonomyTest extends KernelTestBase { 'name' => Unicode::strtolower($this->randomMachineName(5)), 'nodes' => array('article' => 'article'), ); - $vocabulary = entity_create('taxonomy_vocabulary', $vocabulary)->save(); + $vocabulary = \Drupal::entityTypeManager() + ->getStorage('taxonomy_vocabulary') + ->create($vocabulary) + ->save(); return $vocabulary; } @@ -113,7 +116,7 @@ class TaxonomyTest extends KernelTestBase { 'name' => Unicode::strtolower($this->randomMachineName(5)), 'vid' => $vocabulary->id(), ); - $term = entity_create('taxonomy_term', $term); + $term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->create($term); $term->save(); return $term; }