| @@ 144-168 (lines=25) @@ | ||
| 141 | }  | 
                                |
| 142 | ||
| 143 | /** @test */  | 
                                |
| 144 | public function it_can_subscribe_or_update_someone()  | 
                                |
| 145 |     { | 
                                |
| 146 | $email = '[email protected]';  | 
                                |
| 147 | ||
| 148 | $url = 'lists/123/members';  | 
                                |
| 149 | ||
| 150 | $subscriberHash = 'abc123';  | 
                                |
| 151 | ||
| 152 |         $this->mailChimpApi->shouldReceive('success')->andReturn(true); | 
                                |
| 153 |         $this->mailChimpApi->shouldReceive('subscriberHash') | 
                                |
| 154 | ->once()  | 
                                |
| 155 | ->withArgs([$email])  | 
                                |
| 156 | ->andReturn($subscriberHash);  | 
                                |
| 157 | ||
| 158 |         $this->mailChimpApi->shouldReceive('put')->withArgs([ | 
                                |
| 159 |             "{$url}/{$subscriberHash}", | 
                                |
| 160 | [  | 
                                |
| 161 | 'email_address' => $email,  | 
                                |
| 162 | 'status' => 'subscribed',  | 
                                |
| 163 | 'email_type' => 'html',  | 
                                |
| 164 | ],  | 
                                |
| 165 | ]);  | 
                                |
| 166 | ||
| 167 | $this->newsletter->subscribeOrUpdate($email);  | 
                                |
| 168 | }  | 
                                |
| 169 | ||
| 170 | /** @test */  | 
                                |
| 171 | public function it_throws_an_exception_if_subscribing_or_updating_someone_fails()  | 
                                |
| @@ 284-310 (lines=27) @@ | ||
| 281 | }  | 
                                |
| 282 | ||
| 283 | /** @test */  | 
                                |
| 284 | public function it_can_subscribe_or_update_someone_to_an_alternative_list()  | 
                                |
| 285 |     { | 
                                |
| 286 | $email = '[email protected]';  | 
                                |
| 287 | ||
| 288 | $url = 'lists/456/members';  | 
                                |
| 289 | ||
| 290 | $subscriberHash = 'abc123';  | 
                                |
| 291 | ||
| 292 |         $this->mailChimpApi->shouldReceive('success')->andReturn(true); | 
                                |
| 293 |         $this->mailChimpApi->shouldReceive('subscriberHash') | 
                                |
| 294 | ->once()  | 
                                |
| 295 | ->withArgs([$email])  | 
                                |
| 296 | ->andReturn($subscriberHash);  | 
                                |
| 297 | ||
| 298 |         $this->mailChimpApi->shouldReceive('put') | 
                                |
| 299 | ->once()  | 
                                |
| 300 | ->withArgs([  | 
                                |
| 301 |                 "{$url}/{$subscriberHash}", | 
                                |
| 302 | [  | 
                                |
| 303 | 'email_address' => $email,  | 
                                |
| 304 | 'status' => 'subscribed',  | 
                                |
| 305 | 'email_type' => 'html',  | 
                                |
| 306 | ],  | 
                                |
| 307 | ]);  | 
                                |
| 308 | ||
| 309 | $this->newsletter->subscribeOrUpdate($email, [], 'list2');  | 
                                |
| 310 | }  | 
                                |
| 311 | ||
| 312 | /** @test */  | 
                                |
| 313 | public function it_can_override_the_defaults_when_subscribing_someone()  | 
                                |