function StatisticsAdminTest::testDeleteUser

Tests that accesslog reflects when a user is deleted.

File

drupal/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php, line 138
Definition of Drupal\statistics\Tests\StatisticsAdminTest.

Class

StatisticsAdminTest
Tests the statistics administration screen.

Namespace

Drupal\statistics\Tests

Code

function testDeleteUser() {
  config('statistics.settings')
    ->set('access_log.enabled', 1)
    ->save();
  config('user.settings')
    ->set('cancel_method', 'user_cancel_delete')
    ->save();
  $this
    ->drupalLogout($this->privileged_user);
  $account = $this
    ->drupalCreateUser(array(
    'access content',
    'cancel account',
  ));
  $this
    ->drupalLogin($account);
  $this
    ->drupalGet('node/' . $this->test_node->nid);
  $account = user_load($account->uid, TRUE);
  $this
    ->drupalGet('user/' . $account->uid . '/edit');
  $this
    ->drupalPost(NULL, NULL, t('Cancel account'));
  $timestamp = time();
  $this
    ->drupalPost(NULL, NULL, t('Cancel account'));

  // Confirm account cancellation request.
  $mails = $this
    ->drupalGetMails();
  $mail = end($mails);
  preg_match('@http.+?(user/\\d+/cancel/confirm/\\d+/[^\\s]+)@', $mail['body'], $matches);
  $path = $matches[1];
  $this
    ->drupalGet($path);
  $this
    ->assertFalse(user_load($account->uid, TRUE), 'User is not found in the database.');
  $this
    ->drupalGet('admin/reports/visitors');
  $this
    ->assertNoText($account->name, 'Did not find user in visitor statistics.');
}