You are here

public function SimplenewsPersonalizationFormsTest::testDisableAccount in Simplenews 3.x

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

Disable account, subscriptions inactive.

File

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

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, [], $uid);
  $this
    ->drupalLogout();

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

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