Commit a79891da authored by catch's avatar catch

Issue #2503411 by DuaelFr, Mac_Weber: Replace deprecated usage of...

Issue #2503411 by DuaelFr, Mac_Weber: Replace deprecated usage of entity_create('comment*') with a direct call to Comment/CommentType::create()
parent 3c4b6ab1
......@@ -8,6 +8,7 @@
namespace Drupal\comment\Tests;
use Drupal\user\RoleInterface;
use Drupal\comment\Entity\Comment;
/**
* Tests comment approval functionality.
......@@ -50,7 +51,7 @@ function testApprovalAdminInterface() {
// Get unapproved comment id.
$this->drupalLogin($this->adminUser);
$anonymous_comment4 = $this->getUnapprovedComment($subject);
$anonymous_comment4 = entity_create('comment', array(
$anonymous_comment4 = Comment::create(array(
'cid' => $anonymous_comment4,
'subject' => $subject,
'comment_body' => $body,
......@@ -127,7 +128,7 @@ function testApprovalNodeInterface() {
// Get unapproved comment id.
$this->drupalLogin($this->adminUser);
$anonymous_comment4 = $this->getUnapprovedComment($subject);
$anonymous_comment4 = entity_create('comment', array(
$anonymous_comment4 = Comment::create(array(
'cid' => $anonymous_comment4,
'subject' => $subject,
'comment_body' => $body,
......
......@@ -9,6 +9,7 @@
use Drupal\comment\CommentInterface;
use Drupal\simpletest\WebTestBase;
use Drupal\comment\Entity\Comment;
/**
* Tests visibility of comments on book pages.
......@@ -47,7 +48,7 @@ public function testBookCommentPrint() {
$comment_subject = $this->randomMachineName(8);
$comment_body = $this->randomMachineName(8);
$comment = entity_create('comment', array(
$comment = Comment::create(array(
'subject' => $comment_subject,
'comment_body' => $comment_body,
'entity_id' => $book_node->id(),
......
......@@ -10,6 +10,7 @@
use Drupal\Core\Language\LanguageInterface;
use Drupal\comment\CommentInterface;
use Drupal\user\RoleInterface;
use Drupal\comment\Entity\Comment;
/**
* Tests CSS classes on comments.
......@@ -47,7 +48,7 @@ function testCommentClasses() {
// Add a comment.
/** @var \Drupal\comment\CommentInterface $comment */
$comment = entity_create('comment', array(
$comment = Comment::create(array(
'entity_id' => $node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
......
......@@ -77,7 +77,7 @@ protected function createEntity() {
$this->entityTestCamelid->save();
// Create a "Llama" comment.
$comment = entity_create('comment', array(
$comment = Comment::create(array(
'subject' => 'Llama',
'comment_body' => array(
'value' => 'The name "llama" was adopted by European settlers from native Peruvians.',
......
......@@ -13,6 +13,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Session;
use Drupal\comment\Entity\Comment;
/**
* Tests the bubbling up of comment cache tags when using the Comment list
......@@ -98,7 +99,7 @@ public function testCacheTags() {
// also exists in the {users} table.
$user = $this->createUser();
$user->save();
$comment = entity_create('comment', array(
$comment = Comment::create(array(
'subject' => 'Llama',
'comment_body' => array(
'value' => 'Llamas are cool!',
......
......@@ -11,6 +11,7 @@
use Drupal\Core\Language\LanguageInterface;
use Drupal\comment\CommentInterface;
use Drupal\user\RoleInterface;
use Drupal\comment\Entity\Comment;
/**
* Basic comment links tests to ensure markup present.
......@@ -59,7 +60,7 @@ public function testCommentLinks() {
// Create a comment via CRUD API functionality, since
// $this->postComment() relies on actual user permissions.
$comment = entity_create('comment', array(
$comment = Comment::create(array(
'cid' => NULL,
'entity_id' => $this->node->id(),
'entity_type' => 'node',
......
......@@ -11,6 +11,7 @@
use Drupal\Core\Language\LanguageInterface;
use Drupal\comment\CommentInterface;
use Drupal\Core\Url;
use Drupal\comment\Entity\Comment;
/**
* Tests the 'new' indicator posted on comments.
......@@ -85,7 +86,7 @@ public function testCommentNewCommentsIndicator() {
// Create a new comment. This helper function may be run with different
// comment settings so use $comment->save() to avoid complex setup.
/** @var \Drupal\comment\CommentInterface $comment */
$comment = entity_create('comment', array(
$comment = Comment::create(array(
'cid' => NULL,
'entity_id' => $this->node->id(),
'entity_type' => 'node',
......
......@@ -54,7 +54,7 @@ protected function setUp() {
// Create a bundle for entity_test.
entity_test_create_bundle('entity_test', 'Entity Test', 'entity_test');
entity_create('comment_type', array(
CommentType::create(array(
'id' => 'comment',
'label' => 'Comment settings',
'description' => 'Comment settings',
......
......@@ -8,6 +8,7 @@
namespace Drupal\comment\Tests\Views;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\comment\Entity\Comment;
/**
* Tests comment field filters with translations.
......@@ -61,7 +62,7 @@ function setUp() {
'pid' => '',
'node_type' => '',
);
$this->comment = entity_create('comment', $comment);
$this->comment = Comment::create($comment);
// Add field values and translate the comment.
$this->comment->subject->value = $this->commentTitles['en'];
......
......@@ -8,6 +8,7 @@
namespace Drupal\comment\Tests\Views;
use Drupal\Component\Serialization\Json;
use Drupal\comment\Entity\Comment;
/**
* Tests a comment rest export view.
......@@ -43,7 +44,7 @@ protected function setUp() {
'name' => 'bobby tables',
'hostname' => 'public.example.com',
);
$this->comment = entity_create('comment', $comment);
$this->comment = Comment::create($comment);
$this->comment->save();
$user = $this->drupalCreateUser(['access comments']);
......
......@@ -10,6 +10,7 @@
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\comment\Entity\Comment;
/**
* Tests the argument_comment_user_uid handler.
......@@ -87,7 +88,7 @@ protected function setUp() {
'pid' => '',
'mail' => 'someone@example.com',
);
$this->comment = entity_create('comment', $comment);
$this->comment = Comment::create($comment);
$this->comment->save();
}
......
......@@ -84,7 +84,7 @@ protected function setUp() {
// Create some comments and attach them to the created node.
for ($i = 0; $i < $this->masterDisplayResults; $i++) {
/** @var \Drupal\comment\CommentInterface $comment */
$comment = entity_create('comment', array(
$comment = Comment::create(array(
'status' => CommentInterface::PUBLISHED,
'field_name' => 'comment',
'entity_type' => 'node',
......
......@@ -9,6 +9,7 @@
use Drupal\simpletest\WebTestBase;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\comment\Entity\Comment;
/**
* Tests the forum blocks.
......@@ -97,7 +98,7 @@ public function testActiveForumTopicsBlock() {
// Get the node from the topic title.
$node = $this->drupalGetNodeByTitle($topics[$index]);
$date->modify('+1 minute');
$comment = entity_create('comment', array(
$comment = Comment::create(array(
'entity_id' => $node->id(),
'field_name' => 'comment_forum',
'entity_type' => 'node',
......
......@@ -11,6 +11,7 @@
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\node\Entity\NodeType;
use Drupal\simpletest\WebTestBase;
use Drupal\comment\Entity\Comment;
/**
* Tests forum module uninstallation.
......@@ -54,7 +55,7 @@ public function testForumUninstallWithField() {
));
// Create at least one comment against the forum node.
$comment = entity_create('comment', array(
$comment = Comment::create(array(
'entity_id' => $node->nid->value,
'entity_type' => 'node',
'field_name' => 'comment_forum',
......
......@@ -8,6 +8,7 @@
namespace Drupal\hal\Tests;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\comment\Entity\Comment;
/**
* Tests that nodes and terms are correctly normalized and denormalized.
......@@ -167,7 +168,7 @@ public function testComment() {
));
$node->save();
$parent_comment = entity_create('comment', array(
$parent_comment = Comment::create(array(
'uid' => $account->id(),
'subject' => $this->randomMachineName(),
'comment_body' => [
......@@ -180,7 +181,7 @@ public function testComment() {
));
$parent_comment->save();
$comment = entity_create('comment', array(
$comment = Comment::create(array(
'uid' => $account->id(),
'subject' => $this->randomMachineName(),
'comment_body' => [
......
......@@ -10,6 +10,7 @@
use Drupal\comment\CommentInterface;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\simpletest\WebTestBase;
use Drupal\comment\Entity\Comment;
/**
* Tests access controlled node views have the right amount of comment pages.
......@@ -45,7 +46,7 @@ public function testCommentPager() {
// Create 60 comments.
for ($i = 0; $i < 60; $i++) {
$comment = entity_create('comment', array(
$comment = Comment::create(array(
'entity_id' => $node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
......
......@@ -11,6 +11,7 @@
use Drupal\comment\CommentManagerInterface;
use Drupal\comment\Tests\CommentTestBase;
use Drupal\user\RoleInterface;
use Drupal\comment\Entity\Comment;
/**
* Tests the RDFa markup of comments.
......@@ -372,7 +373,7 @@ function saveComment($nid, $uid, $contact = NULL, $pid = 0) {
$values += $contact;
}
$comment = entity_create('comment', $values);
$comment = Comment::create($values);
$comment->save();
return $comment;
}
......
......@@ -12,6 +12,7 @@
use Drupal\node\Entity\NodeType;
use Drupal\node\NodeInterface;
use Drupal\simpletest\WebTestBase;
use Drupal\comment\Entity\Comment;
/**
* Tests the RDF mappings and RDFa markup of the standard profile.
......@@ -515,7 +516,7 @@ protected function saveComment($nid, $uid, $contact = NULL, $pid = 0) {
$values += $contact;
}
$comment = entity_create('comment', $values);
$comment = Comment::create($values);
$comment->save();
return $comment;
}
......
......@@ -163,7 +163,7 @@ public function testCommentHooks() {
$nid = $node->id();
$GLOBALS['entity_crud_hook_test'] = array();
$comment = entity_create('comment', array(
$comment = Comment::create(array(
'cid' => NULL,
'pid' => 0,
'entity_id' => $nid,
......
......@@ -13,6 +13,7 @@
use Drupal\comment\CommentInterface;
use Drupal\simpletest\WebTestBase;
use Drupal\user\Entity\User;
use Drupal\comment\Entity\Comment;
/**
* Tests for the base handlers provided by Entity Reference.
......@@ -413,7 +414,7 @@ public function testCommentHandler() {
$comments = array();
$comment_labels = array();
foreach ($comment_values as $key => $values) {
$comment = entity_create('comment', $values);
$comment = Comment::create($values);
$comment->save();
$comments[$key] = $comment;
$comment_labels[$key] = Html::escape($comment->label());
......
......@@ -12,6 +12,7 @@
use Drupal\comment\CommentInterface;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\simpletest\WebTestBase;
use Drupal\comment\Entity\Comment;
/**
* Tests themed output for each entity type in all available themes to ensure
......@@ -110,7 +111,7 @@ protected function setUp() {
));
// Create a test comment on the test node.
$this->comment = entity_create('comment', array(
$this->comment = Comment::create(array(
'entity_id' => $this->node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
......
......@@ -11,6 +11,7 @@
use Drupal\Core\Language\LanguageInterface;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\comment\Entity\Comment;
/**
* Base class for all tracker tests.
......@@ -60,7 +61,7 @@ protected function setUp() {
'status' => 1,
));
$this->comment = entity_create('comment', array(
$this->comment = Comment::create(array(
'entity_id' => $this->node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
......
......@@ -249,7 +249,7 @@ function testUserBlockUnpublish() {
// Add a comment to the page.
$comment_subject = $this->randomMachineName(8);
$comment_body = $this->randomMachineName(8);
$comment = entity_create('comment', array(
$comment = Comment::create(array(
'subject' => $comment_subject,
'comment_body' => $comment_body,
'entity_id' => $node->id(),
......@@ -316,7 +316,7 @@ function testUserAnonymize() {
// Add a comment to the page.
$comment_subject = $this->randomMachineName(8);
$comment_body = $this->randomMachineName(8);
$comment = entity_create('comment', array(
$comment = Comment::create(array(
'subject' => $comment_subject,
'comment_body' => $comment_body,
'entity_id' => $node->id(),
......
......@@ -15,6 +15,7 @@
use Drupal\Core\Url;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
use Drupal\views\Views;
use Drupal\comment\Entity\Comment;
/**
* Tests the default views provided by views.
......@@ -101,7 +102,7 @@ protected function setUp() {
'entity_type' => 'node',
'field_name' => 'comment'
);
entity_create('comment', $comment)->save();
Comment::create($comment)->save();
}
// Some views, such as the "Who's Online" view, only return results if at
......
......@@ -11,6 +11,7 @@
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\views\Views;
use Drupal\comment\Entity\Comment;
/**
* Tests the field plugin base integration with the entity system.
......@@ -59,7 +60,7 @@ public function testGetEntity() {
$node = entity_create('node', array('uid' => $account->id(), 'type' => 'page', 'title' => $this->randomString()));
$node->save();
$comment = entity_create('comment', array(
$comment = Comment::create(array(
'uid' => $account->id(),
'entity_id' => $node->id(),
'entity_type' => 'node',
......
......@@ -12,6 +12,7 @@
use Drupal\views\Tests\ViewTestData;
use Drupal\views\Tests\ViewKernelTestBase;
use Drupal\views\Views;
use Drupal\comment\Entity\CommentType;
/**
* Tests the calculation of dependencies for views.
......@@ -44,7 +45,7 @@ protected function setUp() {
$this->installEntitySchema('node');
$this->installConfig(array('field', 'node'));
$comment_type = entity_create('comment_type', array(
$comment_type = CommentType::create(array(
'id' => 'comment',
'label' => 'Comment settings',
'description' => 'Comment settings',
......
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