You are here

public function SimplenewsPersonalizationFormsTest::testDeleteAccount in Simplenews 8

Delete account, subscriptions deleted.

File

src/Tests/SimplenewsPersonalizationFormsTest.php, line 134

Class

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

Namespace

Drupal\simplenews\Tests

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", array(
    'user_cancel_method' => 'user_cancel_reassign',
  ), t('Cancel account'));

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