You are here

public function MailchimpListsTestCase::testAddSegmentBatchSubscribers in Mailchimp 7.3

Same name and namespace in other branches
  1. 7.5 modules/mailchimp_lists/tests/mailchimp_lists.test \MailchimpListsTestCase::testAddSegmentBatchSubscribers()
  2. 7.4 modules/mailchimp_lists/tests/mailchimp_lists.test \MailchimpListsTestCase::testAddSegmentBatchSubscribers()

Tests adding batch subscribers to a list segment.

File

modules/mailchimp_lists/tests/mailchimp_lists.test, line 274
Test class and methods for the Mailchimp Lists module.

Class

MailchimpListsTestCase
@file Test class and methods for the Mailchimp Lists module.

Code

public function testAddSegmentBatchSubscribers() {
  $list_id = MAILCHIMP_LISTS_TEST_LIST_A;
  $segment_id = MAILCHIMP_LISTS_TEST_SEGMENT_A;
  $batch = array(
    array(
      'email' => 'user1@example.org',
    ),
    array(
      'email' => 'user2@example.org',
    ),
    array(
      'email' => 'user3@example.org',
    ),
  );
  foreach ($batch as $batch_email) {
    $subscribed = mailchimp_subscribe($list_id, $batch_email['email']);
    $this
      ->assertTrue($subscribed, 'Tested new user subscription.');
  }
  $batch_subscribers = mailchimp_segment_batch_add_subscribers($list_id, $segment_id, $batch);
  $this
    ->assertEqual($batch_subscribers, count($batch), 'Tested correct number of subscribers.');
}