-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/MegaChriz/lists_add_tags_member'
- Loading branch information
Showing
2 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -316,4 +316,64 @@ public function testRemoveSegmentMember() { | |
$this->assertEquals($mc->getEndpoint() . '/lists/' . $list_id . '/segments/' . $segment_id . '/members/' . md5($email), $mc->getClient()->uri); | ||
} | ||
|
||
/** | ||
* Tests library functionality for adding tags to a member. | ||
*/ | ||
public function testAddTagsMember() { | ||
$list_id = '205d96e6b4'; | ||
$tags = ['Foo', 'Bar']; | ||
$email = '[email protected]'; | ||
$mc = new MailchimpLists(); | ||
$mc->addTagsMember($list_id, $tags, $email); | ||
|
||
$this->assertEquals('POST', $mc->getClient()->method); | ||
$this->assertEquals($mc->getEndpoint() . '/lists/' . $list_id . '/members/' . md5($email) . '/tags', $mc->getClient()->uri); | ||
|
||
$this->assertNotEmpty($mc->getClient()->options['json']); | ||
|
||
$request_body = $mc->getClient()->options['json']; | ||
|
||
$expected = [ | ||
[ | ||
'name' => 'Foo', | ||
'status' => 'active', | ||
], | ||
[ | ||
'name' => 'Bar', | ||
'status' => 'active', | ||
], | ||
]; | ||
$this->assertEquals($expected, $request_body->tags); | ||
} | ||
|
||
/** | ||
* Tests library functionality for removing tags from a member. | ||
*/ | ||
public function testRemoveTagsMember() { | ||
$list_id = '205d96e6b4'; | ||
$tags = ['Foo', 'Bar']; | ||
$email = '[email protected]'; | ||
$mc = new MailchimpLists(); | ||
$mc->removeTagsMember($list_id, $tags, $email); | ||
|
||
$this->assertEquals('POST', $mc->getClient()->method); | ||
$this->assertEquals($mc->getEndpoint() . '/lists/' . $list_id . '/members/' . md5($email) . '/tags', $mc->getClient()->uri); | ||
|
||
$this->assertNotEmpty($mc->getClient()->options['json']); | ||
|
||
$request_body = $mc->getClient()->options['json']; | ||
|
||
$expected = [ | ||
[ | ||
'name' => 'Foo', | ||
'status' => 'inactive', | ||
], | ||
[ | ||
'name' => 'Bar', | ||
'status' => 'inactive', | ||
], | ||
]; | ||
$this->assertEquals($expected, $request_body->tags); | ||
} | ||
|
||
} |