protected function SimplenewsTestBase::subscribe in Simplenews 8.2
Same name and namespace in other branches
- 3.x tests/src/Functional/SimplenewsTestBase.php \Drupal\Tests\simplenews\Functional\SimplenewsTestBase::subscribe()
Visits and submits a newsletter management form.
Parameters
string|string[] $newsletter_ids: An ID or an array of IDs of the newsletters to subscribe to.
string $email: The email to subscribe.
array $edit: (optional) Additional form field values, keyed by form field names.
string $submit: (optional) The value of the form submit button. Defaults to t('Subscribe').
string $path: (optional) The path where to expect the form, defaults to 'newsletter/subscriptions'.
int $response: (optional) Expected response, defaults to 200.
6 calls to SimplenewsTestBase::subscribe()
- SimplenewsPersonalizationFormsTest::testBlockedSubscribe in tests/
src/ Functional/ SimplenewsPersonalizationFormsTest.php - Blocked account subscribes, display message.
- SimplenewsPersonalizationFormsTest::testDeleteAccount in tests/
src/ Functional/ SimplenewsPersonalizationFormsTest.php - Delete account, subscriptions deleted.
- SimplenewsPersonalizationFormsTest::testDisableAccount in tests/
src/ Functional/ SimplenewsPersonalizationFormsTest.php - Disable account, subscriptions inactive.
- SimplenewsPersonalizationFormsTest::testSubscribeRequestPassword in tests/
src/ Functional/ SimplenewsPersonalizationFormsTest.php - Subscribe, request password: "name is not recognized".
- SimplenewsPersonalizationFormsTest::testSynchronizeRegisterSubscribe in tests/
src/ Functional/ SimplenewsPersonalizationFormsTest.php - Register then subscribe: require login, fields updated.
File
- tests/
src/ Functional/ SimplenewsTestBase.php, line 195
Class
- SimplenewsTestBase
- Base class for simplenews web tests.
Namespace
Drupal\Tests\simplenews\FunctionalCode
protected function subscribe($newsletter_ids, $email = NULL, array $edit = [], $submit = NULL, $path = 'newsletter/subscriptions', $response = 200) {
if (isset($email)) {
$edit += [
'mail[0][value]' => $email,
];
}
if (!is_array($newsletter_ids)) {
$newsletter_ids = [
$newsletter_ids,
];
}
foreach ($newsletter_ids as $newsletter_id) {
$edit["subscriptions[{$newsletter_id}]"] = $newsletter_id;
}
$this
->drupalPostForm($path, $edit, $submit ?: t('Subscribe'));
$this
->assertResponse($response);
}