public function SimplenewsPersonalizationFormsTest::testSynchronizeSubscribeRegister in Simplenews 8.2
Same name and namespace in other branches
- 3.x tests/src/Functional/SimplenewsPersonalizationFormsTest.php \Drupal\Tests\simplenews\Functional\SimplenewsPersonalizationFormsTest::testSynchronizeSubscribeRegister()
Subscribe then register: fields updated, subscription remains unconfirmed.
File
- tests/
src/ Functional/ SimplenewsPersonalizationFormsTest.php, line 46
Class
- SimplenewsPersonalizationFormsTest
- Tests crucial aspects of Subscriber fieldability and User field sync.
Namespace
Drupal\Tests\simplenews\FunctionalCode
public function testSynchronizeSubscribeRegister() {
$email = $this
->randomEmail();
// Subscribe.
$this
->subscribe('default', $email, [
'field_shared[0][value]' => $this
->randomString(10),
]);
// Register.
$new_value = $this
->randomString(20);
$uid = $this
->registerUser($email, [
'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);
}