You are here

public function SimplenewsPersonalizationFormsTest::testBlockedSubscribe in Simplenews 8.2

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

Blocked account subscribes, display message.

File

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

Class

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

Namespace

Drupal\Tests\simplenews\Functional

Code

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

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

  // Block account.
  $this
    ->drupalLogin($this->admin);
  $this
    ->drupalPostForm("user/{$uid}/edit", [
    'status' => 0,
  ], t('Save'));
  $this
    ->drupalLogout();

  // Attempt subscribe and assert "blocked" message.
  $this
    ->subscribe('default', $email);
  $this
    ->assertRaw(t('The email address %mail belongs to a blocked user.', [
    '%mail' => $email,
  ]));
}