Commit c3ae8b4c authored by catch's avatar catch

Issue #2641596 by Mac_Weber, heykarthikwithu: Replace deprecated usage of ...

Issue #2641596 by Mac_Weber, heykarthikwithu: Replace deprecated usage of  entity_create('node') with a direct call to Node::create()
parent 68e9f226
......@@ -7,6 +7,7 @@
namespace Drupal\node\Tests\Condition;
use Drupal\node\Entity\Node;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
/**
......@@ -38,11 +39,11 @@ function testConditions() {
$this->createUser();
// Get some nodes of various types to check against.
$page = entity_create('node', array('type' => 'page', 'title' => $this->randomMachineName(), 'uid' => 1));
$page = Node::create(['type' => 'page', 'title' => $this->randomMachineName(), 'uid' => 1]);
$page->save();
$article = entity_create('node', array('type' => 'article', 'title' => $this->randomMachineName(), 'uid' => 1));
$article = Node::create(['type' => 'article', 'title' => $this->randomMachineName(), 'uid' => 1]);
$article->save();
$test = entity_create('node', array('type' => 'test', 'title' => $this->randomMachineName(), 'uid' => 1));
$test = Node::create(['type' => 'test', 'title' => $this->randomMachineName(), 'uid' => 1]);
$test->save();
// Grab the node type condition and configure it to check against node type
......
......@@ -8,6 +8,7 @@
namespace Drupal\node\Tests;
use Drupal\Core\Entity\EntityInterface;
use Drupal\node\Entity\Node;
use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase;
/**
......@@ -33,7 +34,7 @@ protected function createEntity() {
))->save();
// Create a "Llama" node.
$node = entity_create('node', array('type' => 'camelids'));
$node = Node::create(['type' => 'camelids']);
$node->setTitle('Llama')
->setPublished(TRUE)
->save();
......
......@@ -9,6 +9,7 @@
use Drupal\Core\Database\Database;
use Drupal\Core\Language\LanguageInterface;
use Drupal\node\Entity\Node;
/**
* Create a node and test saving it.
......@@ -90,7 +91,7 @@ function testFailedPageCreation() {
try {
// An exception is generated by node_test_exception_node_insert() if the
// title is 'testing_transaction_exception'.
entity_create('node', $edit)->save();
Node::create($edit)->save();
$this->fail(t('Expected exception has not been thrown.'));
}
catch (\Exception $e) {
......
......@@ -64,7 +64,7 @@ function testImport() {
'nid' => $test_nid,
);
/** @var \Drupal\node\NodeInterface $node */
$node = entity_create('node', $node);
$node = Node::create($node);
$node->enforceIsNew();
$this->assertEqual($node->getOwnerId(), $this->webUser->id());
......@@ -89,7 +89,7 @@ function testTimestamps() {
'title' => $this->randomMachineName(8),
);
entity_create('node', $edit)->save();
Node::create($edit)->save();
$node = $this->drupalGetNodeByTitle($edit['title']);
$this->assertEqual($node->getCreatedTime(), REQUEST_TIME, 'Creating a node sets default "created" timestamp.');
$this->assertEqual($node->getChangedTime(), REQUEST_TIME, 'Creating a node sets default "changed" timestamp.');
......@@ -118,7 +118,7 @@ function testTimestamps() {
'changed' => 979534800, // Drupal 1.0 release.
);
entity_create('node', $edit)->save();
Node::create($edit)->save();
$node = $this->drupalGetNodeByTitle($edit['title']);
$this->assertEqual($node->getCreatedTime(), 280299600, 'Creating a node programmatically uses programmatically set "created" timestamp.');
$this->assertEqual($node->getChangedTime(), 979534800, 'Creating a node programmatically uses programmatically set "changed" timestamp.');
......@@ -144,11 +144,11 @@ function testTimestamps() {
*/
function testDeterminingChanges() {
// Initial creation.
$node = entity_create('node', array(
$node = Node::create([
'uid' => $this->webUser->id(),
'type' => 'article',
'title' => 'test_changes',
));
]);
$node->save();
// Update the node without applying changes.
......
......@@ -10,6 +10,7 @@
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Html;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\node\Entity\Node;
use Drupal\system\Tests\System\TokenReplaceUnitTestBase;
/**
......@@ -51,13 +52,13 @@ function testNodeTokenReplacement() {
// Create a user and a node.
$account = $this->createUser();
/* @var $node \Drupal\node\NodeInterface */
$node = entity_create('node', array(
$node = Node::create([
'type' => 'article',
'tnid' => 0,
'uid' => $account->id(),
'title' => '<blink>Blinking Text</blink>',
'body' => [['value' => 'Regular NODE body for the test.', 'summary' => 'Fancy NODE summary.', 'format' => 'plain_text']],
));
]);
$node->save();
// Generate and test tokens.
......@@ -110,12 +111,12 @@ function testNodeTokenReplacement() {
}
// Repeat for a node without a summary.
$node = entity_create('node', array(
$node = Node::create([
'type' => 'article',
'uid' => $account->id(),
'title' => '<blink>Blinking Text</blink>',
'body' => [['value' => 'A string that looks random like TR5c2I', 'format' => 'plain_text']],
));
]);
$node->save();
// Generate and test token - use full body as expected value.
......
......@@ -7,6 +7,7 @@
namespace Drupal\node\Tests;
use Drupal\node\Entity\Node;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
/**
......@@ -39,7 +40,7 @@ protected function setUp() {
*/
public function testValidation() {
$this->createUser();
$node = entity_create('node', array('type' => 'page', 'title' => 'test', 'uid' => 1));
$node = Node::create(['type' => 'page', 'title' => 'test', 'uid' => 1]);
$violations = $node->validate();
$this->assertEqual(count($violations), 0, 'No violations when validating a default node.');
......
......@@ -6,6 +6,7 @@
*/
namespace Drupal\node\Tests\Views;
use Drupal\node\Entity\Node;
/**
* Tests replacement of Views tokens supplied by the Node module.
......@@ -38,7 +39,7 @@ public function testViewsTokenReplacement() {
$summary = $this->randomMachineName(16);
/** @var $node \Drupal\node\NodeInterface */
$node = entity_create('node', [
$node = Node::create([
'type' => 'article',
'tnid' => 0,
'uid' => $account->id(),
......
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