$storage = \Drupal::entityTypeManager()->getStorage('comment'); $storage->resetCache([$comment->id()]); $test_comment = $storage->load($comment->id()); $this->assertEquals(0, $test_comment->getOwnerId(), 'Comment of the user has been attributed to anonymous user.'); $this->assertTrue($test_comment->isPublished()); $this->assertEquals($anonymous_user->getDisplayName(), $test_comment->getAuthorName(), 'Comment of the user has been attributed to anonymous user name.');
// Confirm that the confirmation message made it through to the end user.
$this->assertSession()->pageTextContains("Account {$account->getAccountName()} has been deleted."); }
/**
* Delete account and anonymize all content using a batch process.
*/ publicfunctiontestUserAnonymizeBatch(){ $node_storage = $this->container->get('entity_type.manager')->getStorage('node'); $this->config('user.settings')->set('cancel_method', 'user_cancel_reassign')->save();
// Checks the new values of node comment statistics with comment #3.
// The node needs to be reloaded with the cache reset.
$node_storage->resetCache([$this->node->id()]); $node = $node_storage->load($this->node->id()); $this->assertEquals($comment_loaded->getAuthorName(), $node->get('comment')->last_comment_name, 'The value of node last_comment_name is the name of the anonymous user.'); $this->assertEquals(0, $node->get('comment')->last_comment_uid, 'The value of node last_comment_uid is zero.'); $this->assertEquals(2, $node->get('comment')->comment_count, 'The value of node comment_count is 2.'); }
// The comment gets built and modules add to or modify
// $comment->rss_elements and $comment->rss_namespaces.
$build = $this->entityTypeManager->getViewBuilder('comment')->view($comment, 'rss');