You are here

public function MailchimpListsTest::testAddSegment in Mailchimp 8

Tests library functionality for adding a list segment.

File

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

Class

MailchimpListsTest
Mailchimp Lists test library.

Namespace

Mailchimp\Tests

Code

public function testAddSegment() {
  $list_id = '57afe96172';
  $name = 'Test Segment';
  $mc = new MailchimpLists();
  $mc
    ->addSegment($list_id, $name);
  $this
    ->assertEquals('POST', $mc
    ->getClient()->method);
  $this
    ->assertEquals($mc
    ->getEndpoint() . '/lists/' . $list_id . '/segments', $mc
    ->getClient()->uri);
  $this
    ->assertNotEmpty($mc
    ->getClient()->options['json']);
  $request_body = $mc
    ->getClient()->options['json'];
  $this
    ->assertEquals($name, $request_body->name);
}