You are here

public function MailchimpListsTest::testAddMember in Mailchimp 8

Tests library functionality for adding a list member.

File

lib/mailchimp-api-php/tests/MailchimpListsTest.php, line 142

Class

MailchimpListsTest
Mailchimp Lists test library.

Namespace

Mailchimp\Tests

Code

public function testAddMember() {
  $list_id = '57afe96172';
  $email = 'test@example.com';
  $mc = new MailchimpLists();
  $mc
    ->addMember($list_id, $email);
  $this
    ->assertEquals('POST', $mc
    ->getClient()->method);
  $this
    ->assertEquals($mc
    ->getEndpoint() . '/lists/' . $list_id . '/members', $mc
    ->getClient()->uri);
  $this
    ->assertNotEmpty($mc
    ->getClient()->options['json']);
  $request_body = $mc
    ->getClient()->options['json'];
  $this
    ->assertEquals($email, $request_body->email_address);
}