You are here

public function SimplenewsPersonalizationFormsTest::testSynchronizeSubscribeRegister in Simplenews 8

Subscribe then register: fields updated, subscription remains unconfirmed.

File

src/Tests/SimplenewsPersonalizationFormsTest.php, line 45

Class

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

Namespace

Drupal\simplenews\Tests

Code

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

  // Subscribe.
  $this
    ->subscribe('default', $email, array(
    'field_shared[0][value]' => $this
      ->randomString(10),
  ));

  // Register.
  $new_value = $this
    ->randomString(20);
  $uid = $this
    ->registerUser($email, array(
    'field_shared[0][value]' => $new_value,
  ));

  // Assert fields are updated.
  $this
    ->drupalGet("user/{$uid}");
  $this
    ->assertText(Html::escape($new_value));

  // Assert subscription remains unconfirmed.
  $subscriber = $this
    ->getLatestSubscriber();
  $this
    ->assertEqual($subscriber->subscriptions
    ->get(0)->status, SIMPLENEWS_SUBSCRIPTION_STATUS_UNCONFIRMED);
}