You are here

public function SimplenewsPersonalizationFormsTest::testDisableAccount in Simplenews 8.2

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

Disable account, subscriptions inactive.

File

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

Class

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

Namespace

Drupal\Tests\simplenews\Functional

Code

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

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

  // Subscribe.
  $this
    ->resetPassLogin(User::load($uid));
  $this
    ->subscribe('default', NULL, [], t('Update'));
  $this
    ->drupalLogout();

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

  // Assert subscriber is inactive.
  $subscriber = $this
    ->getLatestSubscriber();
  $this
    ->assertFalse($subscriber
    ->getStatus());
}