You are here

public function SimplenewsPersonalizationFormsTest::testDeleteAccount in Simplenews 8.2

Same name and namespace in other branches
  1. 3.x tests/src/Functional/SimplenewsPersonalizationFormsTest.php \Drupal\Tests\simplenews\Functional\SimplenewsPersonalizationFormsTest::testDeleteAccount()

Delete account, subscriptions deleted.

File

tests/src/Functional/SimplenewsPersonalizationFormsTest.php, line 135

Class

SimplenewsPersonalizationFormsTest
Tests crucial aspects of Subscriber fieldability and User field sync.

Namespace

Drupal\Tests\simplenews\Functional

Code

public function testDeleteAccount() {
  $email = $this
    ->randomEmail();

  // Register account.
  $uid = $this
    ->registerUser($email);

  // Subscribe.
  $this
    ->subscribe('default', $email);

  // Delete account.
  $this
    ->drupalLogin($this->admin);
  $this
    ->drupalPostForm("user/{$uid}/cancel", [
    'user_cancel_method' => 'user_cancel_reassign',
  ], t('Cancel account'));

  // Assert subscriptions are deleted.
  $subscriber = $this
    ->getLatestSubscriber();
  $this
    ->assertNull($subscriber, 'No subscriber found');
}