Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes
This commit is contained in:
parent
b11a755ba8
commit
c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\user\Tests\UserCancelTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\user\Tests;
|
||||
|
||||
use Drupal\comment\Tests\CommentTestTrait;
|
||||
|
@ -249,7 +244,7 @@ class UserCancelTest extends WebTestBase {
|
|||
// 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 +311,7 @@ class UserCancelTest extends WebTestBase {
|
|||
// 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(),
|
||||
|
@ -373,6 +368,53 @@ class UserCancelTest extends WebTestBase {
|
|||
$this->assertRaw(t('%name has been deleted.', array('%name' => $account->getUsername())), "Confirmation message displayed to user.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete account and anonymize all content using a batch process.
|
||||
*/
|
||||
public function testUserAnonymizeBatch() {
|
||||
$node_storage = $this->container->get('entity.manager')->getStorage('node');
|
||||
$this->config('user.settings')->set('cancel_method', 'user_cancel_reassign')->save();
|
||||
$user_storage = $this->container->get('entity.manager')->getStorage('user');
|
||||
|
||||
// Create a user.
|
||||
$account = $this->drupalCreateUser(array('cancel account'));
|
||||
$this->drupalLogin($account);
|
||||
// Load a real user object.
|
||||
$user_storage->resetCache([$account->id()]);
|
||||
$account = $user_storage->load($account->id());
|
||||
|
||||
// Create 11 nodes in order to trigger batch processing in
|
||||
// node_mass_update().
|
||||
$nodes = [];
|
||||
for ($i = 0; $i < 11; $i++) {
|
||||
$node = $this->drupalCreateNode(['uid' => $account->id()]);
|
||||
$nodes[$node->id()] = $node;
|
||||
}
|
||||
|
||||
// Attempt to cancel account.
|
||||
$this->drupalGet('user/' . $account->id() . '/edit');
|
||||
$this->drupalPostForm(NULL, NULL, t('Cancel account'));
|
||||
$this->assertText(t('Are you sure you want to cancel your account?'), 'Confirmation form to cancel account displayed.');
|
||||
$this->assertRaw(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', array('%anonymous-name' => $this->config('user.settings')->get('anonymous'))), 'Informs that all content will be attributed to anonymous account.');
|
||||
|
||||
// Confirm account cancellation.
|
||||
$timestamp = time();
|
||||
$this->drupalPostForm(NULL, NULL, t('Cancel account'));
|
||||
$this->assertText(t('A confirmation request to cancel your account has been sent to your email address.'), 'Account cancellation request mailed message displayed.');
|
||||
|
||||
// Confirm account cancellation request.
|
||||
$this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account, $timestamp));
|
||||
$user_storage->resetCache([$account->id()]);
|
||||
$this->assertFalse($user_storage->load($account->id()), 'User is not found in the database.');
|
||||
|
||||
// Confirm that user's content has been attributed to anonymous user.
|
||||
$node_storage->resetCache(array_keys($nodes));
|
||||
$test_nodes = $node_storage->loadMultiple(array_keys($nodes));
|
||||
foreach ($test_nodes as $test_node) {
|
||||
$this->assertTrue(($test_node->getOwnerId() == 0 && $test_node->isPublished()), 'Node ' . $test_node->id() . ' of the user has been attributed to anonymous user.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete account and remove all content.
|
||||
*/
|
||||
|
|
Reference in a new issue