| @@ 89-112 (lines=24) @@ | ||
| 86 | } | |
| 87 | ||
| 88 | /** @test */ | |
| 89 | public function it_can_subscribe_or_update_someone() | |
| 90 |     { | |
| 91 | $email = '[email protected]'; | |
| 92 | ||
| 93 | $url = 'lists/123/members'; | |
| 94 | ||
| 95 | $subscriberHash = 'abc123'; | |
| 96 | ||
| 97 |         $this->mailChimpApi->shouldReceive('subscriberHash') | |
| 98 | ->once() | |
| 99 | ->withArgs([$email]) | |
| 100 | ->andReturn($subscriberHash); | |
| 101 | ||
| 102 |         $this->mailChimpApi->shouldReceive('put')->withArgs([ | |
| 103 |             "{$url}/{$subscriberHash}", | |
| 104 | [ | |
| 105 | 'email_address' => $email, | |
| 106 | 'status' => 'subscribed', | |
| 107 | 'email_type' => 'html', | |
| 108 | ], | |
| 109 | ]); | |
| 110 | ||
| 111 | $this->newsletter->subscribeOrUpdate($email); | |
| 112 | } | |
| 113 | ||
| 114 | /** @test */ | |
| 115 | public function it_can_subscribe_someone_with_merge_fields() | |
| @@ 191-216 (lines=26) @@ | ||
| 188 | } | |
| 189 | ||
| 190 | /** @test */ | |
| 191 | public function it_can_subscribe_or_update_someone_to_an_alternative_list() | |
| 192 |     { | |
| 193 | $email = '[email protected]'; | |
| 194 | ||
| 195 | $url = 'lists/456/members'; | |
| 196 | ||
| 197 | $subscriberHash = 'abc123'; | |
| 198 | ||
| 199 |         $this->mailChimpApi->shouldReceive('subscriberHash') | |
| 200 | ->once() | |
| 201 | ->withArgs([$email]) | |
| 202 | ->andReturn($subscriberHash); | |
| 203 | ||
| 204 |         $this->mailChimpApi->shouldReceive('put') | |
| 205 | ->once() | |
| 206 | ->withArgs([ | |
| 207 |                 "{$url}/{$subscriberHash}", | |
| 208 | [ | |
| 209 | 'email_address' => $email, | |
| 210 | 'status' => 'subscribed', | |
| 211 | 'email_type' => 'html', | |
| 212 | ], | |
| 213 | ]); | |
| 214 | ||
| 215 | $this->newsletter->subscribeOrUpdate($email, [], 'list2'); | |
| 216 | } | |
| 217 | ||
| 218 | /** @test */ | |
| 219 | public function it_can_override_the_defaults_when_subscribing_someone() | |