Commit f2623d23 authored by alexpott's avatar alexpott

Issue #2297475 by marcingy: Remove calls to comment_load.

parent e2a239e8
......@@ -7,7 +7,7 @@
namespace Drupal\comment\Tests;
use Drupal\comment\CommentInterface;
use Drupal\comment\Entity\Comment;
/**
* Tests actions provided by the Comment module.
......@@ -70,7 +70,7 @@ function testCommentUnpublishByKeyword() {
$comment = $this->postComment($this->node, $keyword_2, $this->randomName());
// Load the full comment so that status is available.
$comment = comment_load($comment->id());
$comment = Comment::load($comment->id());
$this->assertTrue($comment->isPublished() === TRUE, 'The comment status was set to published.');
......
......@@ -7,8 +7,8 @@
namespace Drupal\comment\Tests;
use Drupal\comment\CommentInterface;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\comment\Entity\Comment;
/**
* Tests the comment module administrative and end-user-facing interfaces.
......@@ -109,7 +109,7 @@ function testCommentInterface() {
$this->assertText($subject_text, 'Individual comment-reply subject found.');
$this->assertText($comment_text, 'Individual comment-reply body found.');
$reply = $this->postComment(NULL, $this->randomName(), '', TRUE);
$reply_loaded = comment_load($reply->id());
$reply_loaded = Comment::load($reply->id());
$this->assertTrue($this->commentExists($reply, TRUE), 'Reply found.');
$this->assertEqual($comment->id(), $reply_loaded->getParentComment()->id(), 'Pid of a reply to a comment is set correctly.');
// Check the thread of reply grows correctly.
......@@ -120,7 +120,7 @@ function testCommentInterface() {
$this->assertText($comment->getSubject(), 'Individual comment-reply subject found.');
$this->assertText($comment->comment_body->value, 'Individual comment-reply body found.');
$reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
$reply_loaded = comment_load($reply->id());
$reply_loaded = Comment::load($reply->id());
$this->assertTrue($this->commentExists($reply, TRUE), 'Second reply found.');
// Check the thread of second reply grows correctly.
$this->assertEqual(rtrim($comment->getThread(), '/') . '.01/', $reply_loaded->getThread());
......@@ -130,7 +130,7 @@ function testCommentInterface() {
$this->assertText($reply_loaded->getSubject(), 'Individual comment-reply subject found.');
$this->assertText($reply_loaded->comment_body->value, 'Individual comment-reply body found.');
$reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
$reply_loaded = comment_load($reply->id());
$reply_loaded = Comment::load($reply->id());
$this->assertTrue($this->commentExists($reply, TRUE), 'Second reply found.');
// Check the thread of reply to second reply grows correctly.
$this->assertEqual(rtrim($comment->getThread(), '/') . '.01.00/', $reply_loaded->getThread());
......
......@@ -7,6 +7,7 @@
namespace Drupal\comment\Tests;
use Drupal\comment\Entity\Comment;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
......@@ -126,7 +127,7 @@ function testCommentLanguage() {
->range(0, 1)
->execute()
->fetchField();
$comment = comment_load($cid);
$comment = Comment::load($cid);
$args = array('%node_language' => $node_langcode, '%comment_language' => $comment->langcode->value, '%langcode' => $langcode);
$this->assertEqual($comment->langcode->value, $langcode, format_string('The comment posted with content language %langcode and belonging to the node with language %node_language has language %comment_language', $args));
$this->assertEqual($comment->comment_body->value, $comment_values[$node_langcode][$langcode], 'Comment body correctly stored.');
......
......@@ -7,6 +7,8 @@
namespace Drupal\comment\Tests;
use Drupal\comment\Entity\Comment;
/**
* Tests that comments behave correctly when the node is changed.
*/
......@@ -28,7 +30,7 @@ function testNodeDeletion() {
$comment = $this->postComment($this->node, $this->randomName(), $this->randomName());
$this->assertTrue($comment->id(), 'The comment could be loaded.');
$this->node->delete();
$this->assertFalse(comment_load($comment->id()), 'The comment could not be loaded after the node was deleted.');
$this->assertFalse(Comment::load($comment->id()), 'The comment could not be loaded after the node was deleted.');
// Make sure the comment field and all its instances are deleted when node
// type is deleted.
$this->assertNotNull(entity_load('field_config', 'node.comment'), 'Comment field exists');
......
......@@ -8,6 +8,7 @@
namespace Drupal\comment\Tests;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\comment\Entity\Comment;
/**
* Tests previewing comments.
......@@ -135,7 +136,9 @@ function testCommentEditPreviewSave() {
$this->drupalPostForm('comment/' . $comment->id() . '/edit', $displayed, t('Save'));
// Check that the saved comment is still correct.
$comment_loaded = comment_load($comment->id(), TRUE);
$comment_storage = \Drupal::entityManager()->getStorage('comment');
$comment_storage->resetCache(array($comment->id()));
$comment_loaded = Comment::load($comment->id());
$this->assertEqual($comment_loaded->getSubject(), $edit['subject'], 'Subject loaded.');
$this->assertEqual($comment_loaded->comment_body->value, $edit['comment_body[0][value]'], 'Comment body loaded.');
$this->assertEqual($comment_loaded->getAuthorName(), $edit['name'], 'Name loaded.');
......@@ -148,7 +151,8 @@ function testCommentEditPreviewSave() {
$expected_created_time = $comment_loaded->getCreatedTime();
$this->drupalLogin($web_user);
$this->drupalPostForm('comment/' . $comment->id() . '/edit', $user_edit, t('Save'));
$comment_loaded = comment_load($comment->id(), TRUE);
$comment_storage->resetCache(array($comment->id()));
$comment_loaded = Comment::load($comment->id());
$this->assertEqual($comment_loaded->getCreatedTime(), $expected_created_time, 'Expected date and time for comment edited.');
$this->drupalLogout();
}
......
......@@ -7,6 +7,8 @@
namespace Drupal\comment\Tests;
use Drupal\comment\Entity\Comment;
/**
* Tests the comment module administrative and end-user-facing interfaces.
*/
......@@ -101,7 +103,7 @@ function testCommentNodeCommentStatistics() {
// Post comment #3 as anonymous.
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
$anonymous_comment = $this->postComment($this->node, $this->randomName(), '', array('name' => $this->randomName()));
$comment_loaded = comment_load($anonymous_comment->id());
$comment_loaded = Comment::load($anonymous_comment->id());
// Checks the new values of node comment statistics with comment #3.
// The node needs to be reloaded with a node_load_multiple cache reset.
......
......@@ -8,6 +8,7 @@
namespace Drupal\comment\Tests;
use Drupal\comment\Entity\CommentType;
use Drupal\comment\Entity\Comment;
use Drupal\comment\CommentInterface;
use Drupal\field\Entity\FieldInstanceConfig;
use Drupal\simpletest\WebTestBase;
......@@ -163,7 +164,8 @@ public function postComment($entity, $comment, $subject = '', $contact = NULL, $
}
if (isset($match[1])) {
return comment_load($match[1], TRUE);
\Drupal::entityManager()->getStorage('comment')->resetCache(array($match[1]));
return Comment::load($match[1]);
}
}
......
......@@ -9,6 +9,7 @@
use Drupal\Component\Utility\String;
use Drupal\Component\Utility\Xss;
use Drupal\comment\Entity\Comment;
/**
* Tests comment token replacement in strings.
......@@ -45,7 +46,7 @@ function testCommentTokenReplacement() {
// Post a reply to the comment.
$this->drupalGet('comment/reply/node/' . $node->id() . '/comment/' . $parent_comment->id());
$child_comment = $this->postComment(NULL, $this->randomName(), $this->randomName());
$comment = comment_load($child_comment->id());
$comment = Comment::load($child_comment->id());
$comment->setHomepage('http://example.org/');
// Add HTML to ensure that sanitation of some fields tested directly.
......
......@@ -6,6 +6,8 @@
*/
namespace Drupal\file\Tests;
use Drupal\comment\Entity\Comment;
use Drupal\field\Entity\FieldInstanceConfig;
/**
......@@ -288,7 +290,7 @@ function testPrivateFileComment() {
// Log in as normal user.
$this->drupalLogin($user);
$comment = comment_load($cid);
$comment = Comment::load($cid);
$comment_file = $comment->{'field_' . $name}->entity;
$this->assertFileExists($comment_file, 'New file saved to disk on node creation.');
// Test authenticated file download.
......
......@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Entity;
use Drupal\comment\Entity\Comment;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Database\Database;
use Drupal\Core\Language\LanguageInterface;
......@@ -191,7 +192,7 @@ public function testCommentHooks() {
));
$_SESSION['entity_crud_hook_test'] = array();
$comment = comment_load($comment->id());
$comment = Comment::load($comment->id());
$this->assertHookMessageOrder(array(
'entity_crud_hook_test_entity_load called for type comment',
......
......@@ -9,6 +9,7 @@
use Drupal\simpletest\WebTestBase;
use Drupal\comment\CommentInterface;
use Drupal\comment\Entity\Comment;
/**
* Test cancelling a user.
......@@ -357,7 +358,8 @@ function testUserDelete() {
$this->assertFalse(node_load($node->id(), TRUE), 'Node of the user has been deleted.');
$this->assertFalse(node_revision_load($revision), 'Node revision of the user has been deleted.');
$this->assertTrue(node_load($revision_node->id(), TRUE), "Current revision of the user's node was not deleted.");
$this->assertFalse(comment_load($comment->id(), TRUE), 'Comment of the user has been deleted.');
\Drupal::entityManager()->getStorage('comment')->resetCache(array($comment->id()));
$this->assertFalse(Comment::load($comment->id()), 'Comment of the user has been deleted.');
// Confirm that the confirmation message made it through to the end user.
$this->assertRaw(t('%name has been deleted.', array('%name' => $account->getUsername())), "Confirmation message displayed to user.");
......
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