Issue #2641604 by Mac_Weber, lluvigne, heykarthikwithu: Replace deprecated usage of entity_create('node_type') with a direct call to NodeType::create()
parent
436ac08336
commit
a55d4651e0
|
@ -63,10 +63,10 @@ class ConfigImportRecreateTest extends KernelTestBase {
|
|||
|
||||
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 @@ class ConfigImportRecreateTest extends KernelTestBase {
|
|||
$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\Component\Uuid\Php;
|
|||
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 @@ class ConfigImportRenameValidationTest extends KernelTestBase {
|
|||
$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 @@ namespace Drupal\datetime\Tests\Views;
|
|||
|
||||
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 @@ abstract class DateTimeHandlerTestBase extends HandlerTestBase {
|
|||
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 @@ class EditorFileUsageTest extends EntityUnitTestBase {
|
|||
$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 @@ abstract class FieldTestBase extends ViewTestBase {
|
|||
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 @@ namespace Drupal\hal\Tests;
|
|||
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 @@ class EntityTest extends NormalizerTestBase {
|
|||
* 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 @@ class EntityTest extends NormalizerTestBase {
|
|||
* 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 @@ class NodeConditionTest extends EntityUnitTestBase {
|
|||
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 @@ namespace Drupal\node\Tests;
|
|||
|
||||
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\Render\FormattableMarkup;
|
|||
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 @@ class NodeTokenReplaceTest extends TokenReplaceUnitTestBase {
|
|||
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 @@ class NodeValidationTest extends EntityUnitTestBase {
|
|||
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\comment\Tests\CommentTestTrait;
|
|||
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 @@ class EntityCrudHookTest extends EntityUnitTestBase {
|
|||
*/
|
||||
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 @@ namespace Drupal\system\Tests\Module;
|
|||
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 @@ class UninstallTest extends WebTestBase {
|
|||
$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 @@ namespace Drupal\views\Tests\Entity;
|
|||
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 @@ class ViewEntityDependenciesTest extends ViewKernelTestBase {
|
|||
));
|
||||
$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 @@ namespace Drupal\views\Tests;
|
|||
|
||||
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 @@ class ViewExecutableTest extends ViewKernelTestBase {
|
|||
$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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue