From 9b2d4cc09d3fbb6cd50f4ce628e923d13837712e Mon Sep 17 00:00:00 2001
From: Mac_Weber <Mac_Weber@789986.no-reply.drupal.org>
Date: Mon, 28 Dec 2015 18:45:00 -0200
Subject: [PATCH] Issue #2641604 by Mac_Weber: Replace deprecated usage of
 entity_create('node_type') with a direct call to NodeType::create()

---
 core/modules/config/src/Tests/ConfigImportRecreateTest.php         | 5 +++--
 core/modules/config/src/Tests/ConfigImportRenameValidationTest.php | 3 ++-
 core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php  | 3 ++-
 core/modules/editor/src/Tests/EditorFileUsageTest.php              | 3 ++-
 core/modules/field/src/Tests/Views/FieldTestBase.php               | 3 ++-
 core/modules/hal/src/Tests/EntityTest.php                          | 5 +++--
 core/modules/node/src/Tests/Condition/NodeConditionTest.php        | 7 ++++---
 core/modules/node/src/Tests/NodeCacheTagsTest.php                  | 3 ++-
 core/modules/node/src/Tests/NodeTokenReplaceTest.php               | 3 ++-
 core/modules/node/src/Tests/NodeValidationTest.php                 | 3 ++-
 core/modules/node/src/Tests/Views/NodeFieldTokensTest.php          | 4 +++-
 core/modules/simpletest/src/WebTestBase.php                        | 4 +++-
 core/modules/system/src/Tests/Entity/EntityCrudHookTest.php        | 3 ++-
 core/modules/system/src/Tests/Module/UninstallTest.php             | 3 ++-
 core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php | 3 ++-
 core/modules/views/src/Tests/ViewExecutableTest.php                | 4 +++-
 16 files changed, 39 insertions(+), 20 deletions(-)

diff --git a/core/modules/config/src/Tests/ConfigImportRecreateTest.php b/core/modules/config/src/Tests/ConfigImportRecreateTest.php
index 34aa441..ded1d33 100644
--- a/core/modules/config/src/Tests/ConfigImportRecreateTest.php
+++ b/core/modules/config/src/Tests/ConfigImportRecreateTest.php
@@ -12,6 +12,7 @@
 use Drupal\Core\Config\StorageComparer;
 use Drupal\node\Entity\NodeType;
 use Drupal\simpletest\KernelTestBase;
+use Drupal\Core\Entity\Entity\NodeType;
 
 /**
  * Tests importing recreated configuration entities.
@@ -63,7 +64,7 @@ protected function setUp() {
 
   public function testRecreateEntity() {
     $type_name = Unicode::strtolower($this->randomMachineName(16));
-    $content_type = entity_create('node_type', array(
+    $content_type = NodeType::create(array(
       'type' => $type_name,
       'name' => 'Node type one',
     ));
@@ -82,7 +83,7 @@ public function testRecreateEntity() {
     $content_type->delete();
     $this->assertFalse($active->exists($config_name), 'Content type\'s old name does not exist active store.');
     // Recreate with the same type - this will have a different UUID.
-    $content_type = entity_create('node_type', array(
+    $content_type = NodeType::create(array(
       'type' => $type_name,
       'name' => 'Node type two',
     ));
diff --git a/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php b/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php
index c461f30..8caec50 100644
--- a/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php
+++ b/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php
@@ -14,6 +14,7 @@
 use Drupal\Core\Config\ConfigImporterException;
 use Drupal\Core\Config\StorageComparer;
 use Drupal\simpletest\KernelTestBase;
+use Drupal\Core\Entity\Entity\NodeType;
 
 /**
  * Tests validating renamed configuration in a configuration import.
@@ -85,7 +86,7 @@ public function testRenameValidation() {
     $test_entity->delete();
 
     // Create a content type with a matching UUID in the active storage.
-    $content_type = entity_create('node_type', array(
+    $content_type = NodeType::create(array(
       'type' => Unicode::strtolower($this->randomMachineName(16)),
       'name' => $this->randomMachineName(),
       'uuid' => $uuid,
diff --git a/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php b/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php
index b9a4699..0114240 100644
--- a/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php
+++ b/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php
@@ -10,6 +10,7 @@
 use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem;
 use Drupal\views\Tests\Handler\HandlerTestBase;
 use Drupal\views\Tests\ViewTestData;
+use Drupal\Core\Entity\Entity\NodeType;
 
 /**
  * Base class for testing datetime handlers.
@@ -44,7 +45,7 @@ public function setUp() {
     parent::setUp();
 
     // Add a date field to page nodes.
-    $node_type = entity_create('node_type', [
+    $node_type = NodeType::create([
       'type' => 'page',
       'name' => 'page'
     ]);
diff --git a/core/modules/editor/src/Tests/EditorFileUsageTest.php b/core/modules/editor/src/Tests/EditorFileUsageTest.php
index 6e291d4..e24f10d 100644
--- a/core/modules/editor/src/Tests/EditorFileUsageTest.php
+++ b/core/modules/editor/src/Tests/EditorFileUsageTest.php
@@ -10,6 +10,7 @@
 use Drupal\system\Tests\Entity\EntityUnitTestBase;
 use Drupal\field\Entity\FieldStorageConfig;
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\Core\Entity\Entity\NodeType;
 
 /**
  * Tests tracking of file usage by the Text Editor module.
@@ -54,7 +55,7 @@ protected function setUp() {
     $editor->save();
 
     // Create a node type for testing.
-    $type = entity_create('node_type', array('type' => 'page', 'name' => 'page'));
+    $type = NodeType::create(array('type' => 'page', 'name' => 'page'));
     $type->save();
     node_add_body_field($type);
   }
diff --git a/core/modules/field/src/Tests/Views/FieldTestBase.php b/core/modules/field/src/Tests/Views/FieldTestBase.php
index 0425c29..1b3c206 100644
--- a/core/modules/field/src/Tests/Views/FieldTestBase.php
+++ b/core/modules/field/src/Tests/Views/FieldTestBase.php
@@ -21,6 +21,7 @@
 
 use Drupal\views\Tests\ViewTestBase;
 use Drupal\views\Tests\ViewTestData;
+use Drupal\Core\Entity\Entity\NodeType;
 
 /**
  * Provides some helper methods for testing fieldapi integration into views.
@@ -53,7 +54,7 @@ protected function setUp() {
     parent::setUp();
 
     // Ensure the page node type exists.
-    entity_create('node_type', array(
+    NodeType::create(array(
       'type' => 'page',
       'name' => 'page',
     ))->save();
diff --git a/core/modules/hal/src/Tests/EntityTest.php b/core/modules/hal/src/Tests/EntityTest.php
index 6301fb0..ed5b96f 100644
--- a/core/modules/hal/src/Tests/EntityTest.php
+++ b/core/modules/hal/src/Tests/EntityTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\hal\Tests;
 
 use Drupal\comment\Tests\CommentTestTrait;
+use Drupal\Core\Entity\Entity\NodeType;
 
 /**
  * Tests that nodes and terms are correctly normalized and denormalized.
@@ -42,7 +43,7 @@ protected function setUp() {
    * Tests the normalization of nodes.
    */
   public function testNode() {
-    $node_type = entity_create('node_type', array('type' => 'example_type'));
+    $node_type = NodeType::create(array('type' => 'example_type'));
     $node_type->save();
 
     $user = entity_create('user', array('name' => $this->randomMachineName()));
@@ -138,7 +139,7 @@ public function testTerm() {
    * Tests the normalization of comments.
    */
   public function testComment() {
-    $node_type = entity_create('node_type', array('type' => 'example_type'));
+    $node_type = NodeType::create(array('type' => 'example_type'));
     $node_type->save();
 
     $account = entity_create('user', array('name' => $this->randomMachineName()));
diff --git a/core/modules/node/src/Tests/Condition/NodeConditionTest.php b/core/modules/node/src/Tests/Condition/NodeConditionTest.php
index d739751..6b0d5b5 100644
--- a/core/modules/node/src/Tests/Condition/NodeConditionTest.php
+++ b/core/modules/node/src/Tests/Condition/NodeConditionTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\node\Tests\Condition;
 
 use Drupal\system\Tests\Entity\EntityUnitTestBase;
+use Drupal\Core\Entity\Entity\NodeType;
 
 /**
  * Tests that conditions, provided by the node module, are working properly.
@@ -22,11 +23,11 @@ protected function setUp() {
     parent::setUp();
 
     // Create the node bundles required for testing.
-    $type = entity_create('node_type', array('type' => 'page', 'name' => 'page'));
+    $type = NodeType::create(array('type' => 'page', 'name' => 'page'));
     $type->save();
-    $type = entity_create('node_type', array('type' => 'article', 'name' => 'article'));
+    $type = NodeType::create(array('type' => 'article', 'name' => 'article'));
     $type->save();
-    $type = entity_create('node_type', array('type' => 'test', 'name' => 'test'));
+    $type = NodeType::create(array('type' => 'test', 'name' => 'test'));
     $type->save();
   }
 
diff --git a/core/modules/node/src/Tests/NodeCacheTagsTest.php b/core/modules/node/src/Tests/NodeCacheTagsTest.php
index 5940d4c..9931050 100644
--- a/core/modules/node/src/Tests/NodeCacheTagsTest.php
+++ b/core/modules/node/src/Tests/NodeCacheTagsTest.php
@@ -9,6 +9,7 @@
 
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase;
+use Drupal\Core\Entity\Entity\NodeType;
 
 /**
  * Tests the Node entity's cache tags.
@@ -27,7 +28,7 @@ class NodeCacheTagsTest extends EntityWithUriCacheTagsTestBase {
    */
   protected function createEntity() {
     // Create a "Camelids" node type.
-    entity_create('node_type', array(
+    NodeType::create(array(
       'name' => 'Camelids',
       'type' => 'camelids',
     ))->save();
diff --git a/core/modules/node/src/Tests/NodeTokenReplaceTest.php b/core/modules/node/src/Tests/NodeTokenReplaceTest.php
index bc6a049..ab0ac7f 100644
--- a/core/modules/node/src/Tests/NodeTokenReplaceTest.php
+++ b/core/modules/node/src/Tests/NodeTokenReplaceTest.php
@@ -11,6 +11,7 @@
 use Drupal\Component\Utility\Html;
 use Drupal\Core\Render\BubbleableMetadata;
 use Drupal\system\Tests\System\TokenReplaceUnitTestBase;
+use Drupal\Core\Entity\Entity\NodeType;
 
 /**
  * Generates text using placeholders for dummy content to check node token
@@ -34,7 +35,7 @@ protected function setUp() {
     parent::setUp();
     $this->installConfig(array('filter', 'node'));
 
-    $node_type = entity_create('node_type', array('type' => 'article', 'name' => 'Article'));
+    $node_type = NodeType::create(array('type' => 'article', 'name' => 'Article'));
     $node_type->save();
     node_add_body_field($node_type);
   }
diff --git a/core/modules/node/src/Tests/NodeValidationTest.php b/core/modules/node/src/Tests/NodeValidationTest.php
index 9f6bccc..00c52dc 100644
--- a/core/modules/node/src/Tests/NodeValidationTest.php
+++ b/core/modules/node/src/Tests/NodeValidationTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\node\Tests;
 
 use Drupal\system\Tests\Entity\EntityUnitTestBase;
+use Drupal\Core\Entity\Entity\NodeType;
 
 /**
  * Tests node validation constraints.
@@ -30,7 +31,7 @@ protected function setUp() {
     parent::setUp();
 
     // Create a node type for testing.
-    $type = entity_create('node_type', array('type' => 'page', 'name' => 'page'));
+    $type = NodeType::create(array('type' => 'page', 'name' => 'page'));
     $type->save();
   }
 
diff --git a/core/modules/node/src/Tests/Views/NodeFieldTokensTest.php b/core/modules/node/src/Tests/Views/NodeFieldTokensTest.php
index 5cc96c7..7eeb72c 100644
--- a/core/modules/node/src/Tests/Views/NodeFieldTokensTest.php
+++ b/core/modules/node/src/Tests/Views/NodeFieldTokensTest.php
@@ -7,6 +7,8 @@
 
 namespace Drupal\node\Tests\Views;
 
+use Drupal\Core\Entity\Entity\NodeType;
+
 /**
  * Tests replacement of Views tokens supplied by the Node module.
  *
@@ -28,7 +30,7 @@ class NodeFieldTokensTest extends NodeTestBase {
   public function testViewsTokenReplacement() {
     // Create the Article content type with a standard body field.
     /* @var $node_type \Drupal\node\NodeTypeInterface */
-    $node_type = entity_create('node_type', ['type' => 'article', 'name' => 'Article']);
+    $node_type = NodeType::create(['type' => 'article', 'name' => 'Article']);
     $node_type->save();
     node_add_body_field($node_type);
 
diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php
index 1e3bfdb..38dd2fc 100644
--- a/core/modules/simpletest/src/WebTestBase.php
+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -7,6 +7,8 @@
 
 namespace Drupal\simpletest;
 
+use Drupal\Core\Entity\Entity\NodeType;
+
 use Drupal\block\Entity\Block;
 use Drupal\Component\FileCache\FileCacheFactory;
 use Drupal\Component\Serialization\Json;
@@ -322,7 +324,7 @@ protected function drupalCreateContentType(array $values = array()) {
       'type' => $id,
       'name' => $id,
     );
-    $type = entity_create('node_type', $values);
+    $type = NodeType::create($values);
     $status = $type->save();
     node_add_body_field($type);
     \Drupal::service('router.builder')->rebuild();
diff --git a/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php b/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php
index 2885d47..e266251 100644
--- a/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php
@@ -18,6 +18,7 @@
 use Drupal\taxonomy\Entity\Vocabulary;
 use Drupal\user\Entity\User;
 use Drupal\file\Entity\File;
+use Drupal\Core\Entity\Entity\NodeType;
 
 /**
  * Tests the invocation of hooks when creating, inserting, loading, updating or
@@ -142,7 +143,7 @@ public function testBlockHooks() {
    */
   public function testCommentHooks() {
     $account = $this->createUser();
-    entity_create('node_type', array(
+    NodeType::create(array(
       'type' => 'article',
       'name' => 'Article',
     ))->save();
diff --git a/core/modules/system/src/Tests/Module/UninstallTest.php b/core/modules/system/src/Tests/Module/UninstallTest.php
index 253ea18..bcd5000 100644
--- a/core/modules/system/src/Tests/Module/UninstallTest.php
+++ b/core/modules/system/src/Tests/Module/UninstallTest.php
@@ -11,6 +11,7 @@
 use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Entity\EntityMalformedException;
 use Drupal\simpletest\WebTestBase;
+use Drupal\Core\Entity\Entity\NodeType;
 
 /**
  * Tests the uninstallation of modules.
@@ -46,7 +47,7 @@ function testUninstallPage() {
     $this->drupalLogin($account);
 
     // Create a node type.
-    $node_type = entity_create('node_type', array('type' => 'uninstall_blocker', 'name' => 'Uninstall blocker'));
+    $node_type = NodeType::create(array('type' => 'uninstall_blocker', 'name' => 'Uninstall blocker'));
     // Create a dependency that can be fixed.
     $node_type->setThirdPartySetting('module_test', 'key', 'value');
     $node_type->save();
diff --git a/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php b/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php
index 632be6a..96b8eff 100644
--- a/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php
+++ b/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php
@@ -12,6 +12,7 @@
 use Drupal\views\Tests\ViewTestData;
 use Drupal\views\Tests\ViewKernelTestBase;
 use Drupal\views\Views;
+use Drupal\Core\Entity\Entity\NodeType;
 
 /**
  * Tests the calculation of dependencies for views.
@@ -52,7 +53,7 @@ protected function setUp() {
     ));
     $comment_type->save();
 
-    $content_type = entity_create('node_type', array(
+    $content_type = NodeType::create(array(
       'type' => $this->randomMachineName(),
       'name' => $this->randomString(),
     ));
diff --git a/core/modules/views/src/Tests/ViewExecutableTest.php b/core/modules/views/src/Tests/ViewExecutableTest.php
index e4f17b5..f6949a1 100644
--- a/core/modules/views/src/Tests/ViewExecutableTest.php
+++ b/core/modules/views/src/Tests/ViewExecutableTest.php
@@ -7,6 +7,8 @@
 
 namespace Drupal\views\Tests;
 
+use Drupal\Core\Entity\Entity\NodeType;
+
 use Drupal\comment\Tests\CommentTestTrait;
 use Drupal\Component\Utility\Xss;
 use Drupal\views\Entity\View;
@@ -87,7 +89,7 @@ protected function setUpFixtures() {
     $this->installSchema('comment', array('comment_entity_statistics'));
     $this->installConfig(array('system', 'field', 'node', 'comment'));
 
-    entity_create('node_type', array(
+    NodeType::create(array(
       'type' => 'page',
       'name' => 'Page',
     ))->save();
-- 
2.1.4

