You are here

public function CommentNotifyUserPreferencesTest::testUserCancelAccount in Comment Notify 8

Tests that when a user is canceled all the notifications are deleted.

File

tests/src/Functional/CommentNotifyUserPreferencesTest.php, line 257

Class

CommentNotifyUserPreferencesTest
Tests the Comment Notify users preferences.

Namespace

Drupal\Tests\comment_notify\Functional

Code

public function testUserCancelAccount() {
  $cancel_method_options = [
    'user_cancel_block',
    'user_cancel_block_unpublish',
    'user_cancel_reassign',
  ];
  foreach ($cancel_method_options as $cancel_method_option) {
    $user = $this
      ->drupalCreateUser($this->permissions);
    $this->container
      ->get('comment_notify.user_settings')
      ->saveSettings($user
      ->id(), COMMENT_NOTIFY_ENTITY, COMMENT_NOTIFY_COMMENT);
    user_cancel([], $user
      ->id(), $cancel_method_option);
    $this
      ->assertTrue(is_null($this->container
      ->get('comment_notify.user_settings')
      ->getSettings($user
      ->id())));
  }

  // Delete Account.
  $user = $this
    ->drupalCreateUser($this->permissions);
  $this->container
    ->get('comment_notify.user_settings')
    ->saveSettings($user
    ->id(), COMMENT_NOTIFY_ENTITY, COMMENT_NOTIFY_COMMENT);
  $user
    ->delete();
  $this
    ->assertTrue(is_null($this->container
    ->get('comment_notify.user_settings')
    ->getSettings($user
    ->id())));
}