summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcatch2014-03-30 12:55:20 (GMT)
committercatch2014-03-30 12:55:20 (GMT)
commit669b898b86e4209f7d6e8e0b191ef4ddf2313dcf (patch)
tree5f54b64ca037379e45ed0668f6cb1a4a07a12f9c
parent766586b804a3d305f8c715aa39bb9d31010ecc3b (diff)
Issue #2227465 by gremy, rbmboogie: comment_user_cancel() uses COMMENT_NOT_PUBLISHED.
-rw-r--r--core/modules/comment/comment.module2
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php24
2 files changed, 24 insertions, 2 deletions
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index e353501..d9d86d4 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -1001,7 +1001,7 @@ function comment_user_cancel($edit, $account, $method) {
case 'user_cancel_block_unpublish':
$comments = entity_load_multiple_by_properties('comment', array('uid' => $account->id()));
foreach ($comments as $comment) {
- $comment->setPublished(COMMENT_NOT_PUBLISHED);
+ $comment->setPublished(CommentInterface::NOT_PUBLISHED);
$comment->save();
}
break;
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
index cc8f652..edd4ea1 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
@@ -8,6 +8,7 @@
namespace Drupal\user\Tests;
use Drupal\simpletest\WebTestBase;
+use Drupal\comment\CommentInterface;
/**
* Test cancelling a user.
@@ -19,7 +20,7 @@ class UserCancelTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node');
+ public static $modules = array('node', 'comment');
public static function getInfo() {
return array(
@@ -187,6 +188,8 @@ class UserCancelTest extends WebTestBase {
*/
function testUserBlockUnpublish() {
\Drupal::config('user.settings')->set('cancel_method', 'user_cancel_block_unpublish')->save();
+ // Create comment field on page.
+ \Drupal::service('comment.manager')->addDefaultField('node', 'page');
// Create a user.
$account = $this->drupalCreateUser(array('cancel account'));
@@ -200,6 +203,20 @@ class UserCancelTest extends WebTestBase {
$settings['revision'] = 1;
$node = $this->drupalCreateNode($settings);
+ // Add a comment to the page.
+ $comment_subject = $this->randomName(8);
+ $comment_body = $this->randomName(8);
+ $comment = entity_create('comment', array(
+ 'subject' => $comment_subject,
+ 'comment_body' => $comment_body,
+ 'entity_id' => $node->id(),
+ 'entity_type' => 'node',
+ 'field_name' => 'comment',
+ 'status' => CommentInterface::PUBLISHED,
+ 'uid' => $account->id(),
+ ));
+ $comment->save();
+
// Attempt to cancel account.
$this->drupalGet('user/' . $account->id() . '/edit');
$this->drupalPostForm(NULL, NULL, t('Cancel account'));
@@ -222,6 +239,11 @@ class UserCancelTest extends WebTestBase {
$test_node = node_revision_load($node->getRevisionId());
$this->assertFalse($test_node->isPublished(), 'Node revision of the user has been unpublished.');
+ $storage = \Drupal::entityManager()->getStorage('comment');
+ $storage->resetCache(array($comment->id()));
+ $comment = $storage->load($comment->id());
+ $this->assertFalse($comment->isPublished(), 'Comment of the user has been unpublished.');
+
// Confirm that the confirmation message made it through to the end user.
$this->assertRaw(t('%name has been disabled.', array('%name' => $account->getUsername())), "Confirmation message displayed to user.");
}