public function MailchimpListsSubscriptionTest::testSubscribe in Mailchimp 2.x
Same name and namespace in other branches
- 8 modules/mailchimp_lists/src/Tests/MailchimpListsSubscriptionTest.php \Drupal\Tests\mailchimp_lists\Functional\MailchimpListsSubscriptionTest::testSubscribe()
Tests subscribing a member to a list.
File
- modules/
mailchimp_lists/ tests/ src/ Functional/ MailchimpListsSubscriptionTest.php, line 47
Class
- MailchimpListsSubscriptionTest
- Tests list subscription functionality.
Namespace
Drupal\Tests\mailchimp_lists\FunctionalCode
public function testSubscribe() {
$list_id = '57afe96172';
$email = 'test@example.org';
$interest_category_id = 'a1e9f4b7f6';
$interest_ids = [
'9143cf3bd1',
'3a2a927344',
];
$merge_vars = [
'EMAIL' => $email,
];
$interests = [];
$interests[$interest_category_id] = [
$interest_ids[0] => 1,
$interest_ids[1] => 0,
];
$member_info = mailchimp_subscribe($list_id, $email, $merge_vars, $interests);
$this
->assertSame($member_info->id, md5($email), 'Tested new user subscription.');
$this
->assertSame($member_info->merge_fields->EMAIL, $email);
$this
->assertTrue($member_info->interests->{$interest_ids[0]});
$this
->assertFalse($member_info->interests->{$interest_ids[1]});
}