You are here

public function SimplenewsPersonalizationFormsTest::testDeleteAccount in Simplenews 3.x

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

Delete account, subscriptions deleted.

File

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

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([], $email);

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

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