Commit a55d4651 authored by catch's avatar catch

Issue #2641604 by Mac_Weber, lluvigne, heykarthikwithu: Replace deprecated...

Issue #2641604 by Mac_Weber, lluvigne, heykarthikwithu: Replace deprecated usage of  entity_create('node_type') with a direct call to NodeType::create()
parent 436ac083
......@@ -63,10 +63,10 @@ protected function setUp() {
public function testRecreateEntity() {
$type_name = Unicode::strtolower($this->randomMachineName(16));
$content_type = entity_create('node_type', array(
$content_type = NodeType::create([
'type' => $type_name,
'name' => 'Node type one',
));
]);
$content_type->save();
node_add_body_field($content_type);
/** @var \Drupal\Core\Config\StorageInterface $active */
......@@ -82,10 +82,10 @@ 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([
'type' => $type_name,
'name' => 'Node type two',
));
]);
$content_type->save();
node_add_body_field($content_type);
......
......@@ -13,6 +13,7 @@
use Drupal\Core\Config\ConfigImporter;
use Drupal\Core\Config\ConfigImporterException;
use Drupal\Core\Config\StorageComparer;
use Drupal\node\Entity\NodeType;
use Drupal\simpletest\KernelTestBase;
/**
......@@ -85,11 +86,11 @@ 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([
'type' => Unicode::strtolower($this->randomMachineName(16)),
'name' => $this->randomMachineName(),
'uuid' => $uuid,
));
]);
$content_type->save();
// Confirm that the staged configuration is detected as a rename since the
......
......@@ -9,6 +9,7 @@
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem;
use Drupal\field\Entity\FieldConfig;
use Drupal\node\Entity\NodeType;
use Drupal\views\Tests\Handler\HandlerTestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\field\Entity\FieldStorageConfig;
......@@ -46,7 +47,7 @@ protected 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'
]);
......
......@@ -8,6 +8,7 @@
namespace Drupal\editor\Tests;
use Drupal\editor\Entity\Editor;
use Drupal\node\Entity\NodeType;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
......@@ -55,7 +56,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(['type' => 'page', 'name' => 'page']);
$type->save();
node_add_body_field($type);
}
......
......@@ -20,6 +20,7 @@
namespace Drupal\field\Tests\Views;
use Drupal\field\Entity\FieldConfig;
use Drupal\node\Entity\NodeType;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\field\Entity\FieldStorageConfig;
......@@ -55,10 +56,10 @@ protected function setUp() {
parent::setUp();
// Ensure the page node type exists.
entity_create('node_type', array(
NodeType::create([
'type' => 'page',
'name' => 'page',
))->save();
])->save();
ViewTestData::createTestViews(get_class($this), array('field_test_views'));
}
......
......@@ -10,6 +10,7 @@
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\comment\Entity\Comment;
use Drupal\user\Entity\User;
use Drupal\node\Entity\NodeType;
/**
* Tests that nodes and terms are correctly normalized and denormalized.
......@@ -44,7 +45,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(['type' => 'example_type']);
$node_type->save();
$user = User::create(['name' => $this->randomMachineName()]);
......@@ -140,7 +141,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(['type' => 'example_type']);
$node_type->save();
$account = User::create(['name' => $this->randomMachineName()]);
......
......@@ -8,6 +8,7 @@
namespace Drupal\node\Tests\Condition;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
/**
......@@ -23,11 +24,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(['type' => 'page', 'name' => 'page']);
$type->save();
$type = entity_create('node_type', array('type' => 'article', 'name' => 'article'));
$type = NodeType::create(['type' => 'article', 'name' => 'article']);
$type->save();
$type = entity_create('node_type', array('type' => 'test', 'name' => 'test'));
$type = NodeType::create(['type' => 'test', 'name' => 'test']);
$type->save();
}
......
......@@ -9,6 +9,7 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase;
/**
......@@ -28,10 +29,10 @@ class NodeCacheTagsTest extends EntityWithUriCacheTagsTestBase {
*/
protected function createEntity() {
// Create a "Camelids" node type.
entity_create('node_type', array(
NodeType::create([
'name' => 'Camelids',
'type' => 'camelids',
))->save();
])->save();
// Create a "Llama" node.
$node = Node::create(['type' => 'camelids']);
......
......@@ -11,6 +11,7 @@
use Drupal\Component\Utility\Html;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\system\Tests\System\TokenReplaceUnitTestBase;
/**
......@@ -35,7 +36,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(['type' => 'article', 'name' => 'Article']);
$node_type->save();
node_add_body_field($node_type);
}
......
......@@ -8,6 +8,7 @@
namespace Drupal\node\Tests;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
/**
......@@ -31,7 +32,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(['type' => 'page', 'name' => 'page']);
$type->save();
}
......
......@@ -7,6 +7,7 @@
namespace Drupal\node\Tests\Views;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
/**
* Tests replacement of Views tokens supplied by the Node module.
......@@ -29,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);
......
......@@ -13,6 +13,7 @@
use Drupal\Core\Database\Database;
use Drupal\Core\Language\LanguageInterface;
use Drupal\block\Entity\Block;
use Drupal\node\Entity\NodeType;
use Drupal\taxonomy\Entity\Term;
use Drupal\node\Entity\Node;
use Drupal\taxonomy\Entity\Vocabulary;
......@@ -142,10 +143,10 @@ public function testBlockHooks() {
*/
public function testCommentHooks() {
$account = $this->createUser();
entity_create('node_type', array(
NodeType::create([
'type' => 'article',
'name' => 'Article',
))->save();
])->save();
$this->addDefaultCommentField('node', 'article', 'comment', CommentItemInterface::OPEN);
$node = entity_create('node', array(
......
......@@ -10,6 +10,7 @@
use Drupal\Core\Cache\Cache;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Entity\EntityMalformedException;
use Drupal\node\Entity\NodeType;
use Drupal\simpletest\WebTestBase;
/**
......@@ -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(['type' => 'uninstall_blocker', 'name' => 'Uninstall blocker']);
// Create a dependency that can be fixed.
$node_type->setThirdPartySetting('module_test', 'key', 'value');
$node_type->save();
......
......@@ -10,6 +10,7 @@
use Drupal\Component\Utility\Unicode;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\node\Entity\NodeType;
use Drupal\views\Tests\ViewTestData;
use Drupal\views\Tests\ViewKernelTestBase;
use Drupal\views\Views;
......@@ -54,10 +55,10 @@ protected function setUp() {
));
$comment_type->save();
$content_type = entity_create('node_type', array(
$content_type = NodeType::create([
'type' => $this->randomMachineName(),
'name' => $this->randomString(),
));
]);
$content_type->save();
$field_storage = FieldStorageConfig::create(array(
'field_name' => Unicode::strtolower($this->randomMachineName()),
......
......@@ -9,6 +9,7 @@
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\Component\Utility\Xss;
use Drupal\node\Entity\NodeType;
use Drupal\views\Entity\View;
use Drupal\views\Views;
use Drupal\views\ViewExecutable;
......@@ -87,10 +88,10 @@ protected function setUpFixtures() {
$this->installSchema('comment', array('comment_entity_statistics'));
$this->installConfig(array('system', 'field', 'node', 'comment'));
entity_create('node_type', array(
NodeType::create([
'type' => 'page',
'name' => 'Page',
))->save();
])->save();
$this->addDefaultCommentField('node', 'page');
parent::setUpFixtures();
......
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