Commit a79891da authored by catch's avatar catch
Browse files

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