-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from jeroendk/consistant_services
Changed service definition + fixed testcases
- Loading branch information
Showing
5 changed files
with
26 additions
and
25 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 |
---|---|---|
|
@@ -13,8 +13,8 @@ class ListRepositorySpec extends ObjectBehavior | |
public function let(MailChimp $mailchimp, Subscriber $subscriber) | ||
{ | ||
$this->prepareSubscriber($subscriber); | ||
$this->prepareMailchimpLists($mailchimp); | ||
|
||
$this->prepareMailchimpLists($mailchimp); | ||
$this->beConstructedWith($mailchimp); | ||
} | ||
|
||
|
@@ -73,14 +73,14 @@ public function it_clean_a_subscriber(MailChimp $mailchimp, $subscriber) | |
|
||
public function it_delete_a_subscriber(MailChimp $mailchimp, $subscriber) | ||
{ | ||
$mailchimp->delete("lists/ba039c6198/members/md5ofthesubscribermail")->willReturn('deleted'); | ||
$mailchimp->delete("lists/ba039c6198/members/b1a29fd58778c40c7f15f06a334dc691")->willReturn('deleted'); | ||
|
||
$this->delete('ba039c6198', $subscriber)->shouldReturn('deleted'); | ||
} | ||
|
||
public function it_update_a_subscriber(MailChimp $mailchimp, $subscriber) | ||
{ | ||
$mailchimp->patch("lists/ba039c6198/members/md5ofthesubscribermail", ["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html"])->willReturn('update'); | ||
$mailchimp->patch("lists/ba039c6198/members/b1a29fd58778c40c7f15f06a334dc691", ["email_address" => "[email protected]", "merge_fields" => ["FNAME" => "Charles", "LNAME" => "Terrasse"], "language" => "fr", "email_type" => "html"])->willReturn('update'); | ||
|
||
$this->update('ba039c6198', $subscriber)->shouldReturn('update'); | ||
} | ||
|
@@ -194,16 +194,14 @@ protected function prepareSubscriber(Subscriber $subscriber) | |
} | ||
|
||
protected function prepareMailchimpLists(MailChimp $mailchimp) | ||
{ | ||
// subscriber hash | ||
$mailchimp->subscriberHash('[email protected]')->willReturn('md5ofthesubscribermail'); | ||
{ | ||
// success | ||
$mailchimp->success()->willReturn(true); | ||
// get the list | ||
$mailchimp->get("lists/ba039c6198")->willReturn(['id' => 'ba039c6198', 'name' => 'myList']); | ||
$mailchimp->get("lists/notfound")->willReturn(null); | ||
// subscribe member | ||
$mailchimp->put("lists/ba039c6198/members/md5ofthesubscribermail", [ | ||
$mailchimp->put("lists/ba039c6198/members/b1a29fd58778c40c7f15f06a334dc691", [ | ||
'email_address' => '[email protected]', | ||
'merge_fields' => ['FNAME' => 'Charles', 'LNAME' => 'Terrasse'], | ||
'language' => 'fr', | ||
|
@@ -217,23 +215,23 @@ protected function prepareMailchimpLists(MailChimp $mailchimp) | |
'status' => 'subscribed' | ||
]); | ||
|
||
$mailchimp->put("lists/ba039c6198/members/md5ofthesubscribermail", [ | ||
$mailchimp->put("lists/ba039c6198/members/b1a29fd58778c40c7f15f06a334dc691", [ | ||
'email_address' => '[email protected]', | ||
'merge_fields' => ['FNAME' => 'Charles', 'LNAME' => 'Terrasse'], | ||
'language' => 'fr', | ||
'email_type' => 'html', | ||
'status' => 'unsubscribed' | ||
])->willReturn('unsubscribed'); | ||
|
||
$mailchimp->put("lists/ba039c6198/members/md5ofthesubscribermail", [ | ||
$mailchimp->put("lists/ba039c6198/members/b1a29fd58778c40c7f15f06a334dc691", [ | ||
'email_address' => '[email protected]', | ||
'merge_fields' => ['FNAME' => 'Charles', 'LNAME' => 'Terrasse'], | ||
'language' => 'fr', | ||
'email_type' => 'html', | ||
'status' => 'pending' | ||
])->willReturn('pending'); | ||
|
||
$mailchimp->put("lists/ba039c6198/members/md5ofthesubscribermail", [ | ||
$mailchimp->put("lists/ba039c6198/members/b1a29fd58778c40c7f15f06a334dc691", [ | ||
'email_address' => '[email protected]', | ||
'merge_fields' => ['FNAME' => 'Charles', 'LNAME' => 'Terrasse'], | ||
'language' => 'fr', | ||
|
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
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 |
---|---|---|
|
@@ -57,7 +57,7 @@ public function testDelete() | |
{ | ||
$subscriber = new Subscriber('[email protected]', ['FNAME' => 'Toto', 'LNAME' => 'TEST'], ['language' => 'fr']); | ||
$result = $this->listRepository->delete(self::LIST_ID, $subscriber); | ||
$this->assertEmpty($result); | ||
$this->assertTrue($result); | ||
} | ||
|
||
public function testBatchSubscribe() | ||
|
@@ -132,7 +132,7 @@ public function testMergeTags() | |
$this->assertNotEmpty($result2); | ||
$this->assertEquals($result2['tag'], 'SECONDTEST'); | ||
$result3 = $this->listRepository->deleteMergeField(self::LIST_ID, $result2['merge_id']); | ||
$this->assertEmpty($result3); | ||
$this->assertTrue($result3); | ||
} | ||
|
||
public function testWebhook() | ||
|