| @@ 278-301 (lines=24) @@ | ||
| 275 | } |
|
| 276 | ||
| 277 | /** @test */ |
|
| 278 | public function it_can_check_if_member_is_subscribed() |
|
| 279 | { |
|
| 280 | $this->response->shouldReceive('success')->andReturn(true); |
|
| 281 | ||
| 282 | $response = Mockery::mock(Response::class); |
|
| 283 | $response->shouldReceive('success')->andReturn(true); |
|
| 284 | $response->shouldReceive('getData')->andReturn([ |
|
| 285 | [ |
|
| 286 | 'ListID' => '123', |
|
| 287 | 'IsUnsub' => false |
|
| 288 | ] |
|
| 289 | ]); |
|
| 290 | ||
| 291 | $this->client->shouldReceive('get')->withArgs([ |
|
| 292 | Resources::$ContactGetcontactslists, |
|
| 293 | [ |
|
| 294 | 'id' => '[email protected]' |
|
| 295 | ] |
|
| 296 | ])->andReturn($response); |
|
| 297 | ||
| 298 | ||
| 299 | $response = $this->newsletter->isSubscribed('[email protected]'); |
|
| 300 | $this->assertTrue($response); |
|
| 301 | } |
|
| 302 | ||
| 303 | /** @test */ |
|
| 304 | public function it_can_check_if_member_is_not_subscribed() |
|
| @@ 304-327 (lines=24) @@ | ||
| 301 | } |
|
| 302 | ||
| 303 | /** @test */ |
|
| 304 | public function it_can_check_if_member_is_not_subscribed() |
|
| 305 | { |
|
| 306 | $this->response->shouldReceive('success')->andReturn(true); |
|
| 307 | ||
| 308 | $response = Mockery::mock(Response::class); |
|
| 309 | $response->shouldReceive('success')->andReturn(true); |
|
| 310 | $response->shouldReceive('getData')->andReturn([ |
|
| 311 | [ |
|
| 312 | 'ListID' => '124', |
|
| 313 | 'IsUnsub' => false |
|
| 314 | ] |
|
| 315 | ]); |
|
| 316 | ||
| 317 | $this->client->shouldReceive('get')->withArgs([ |
|
| 318 | Resources::$ContactGetcontactslists, |
|
| 319 | [ |
|
| 320 | 'id' => '[email protected]' |
|
| 321 | ] |
|
| 322 | ])->andReturn($response); |
|
| 323 | ||
| 324 | ||
| 325 | $response = $this->newsletter->isSubscribed('[email protected]'); |
|
| 326 | $this->assertFalse($response); |
|
| 327 | } |
|
| 328 | ||
| 329 | /** @test */ |
|
| 330 | public function it_will_trow_an_exception_when_check_if_member_is_subscribed() |
|
| @@ 346-367 (lines=22) @@ | ||
| 343 | } |
|
| 344 | ||
| 345 | /** @test */ |
|
| 346 | public function it_can_check_if_list_has_member() |
|
| 347 | { |
|
| 348 | $this->response->shouldReceive('success')->andReturn(true); |
|
| 349 | ||
| 350 | $response = Mockery::mock(Response::class); |
|
| 351 | $response->shouldReceive('success')->andReturn(true); |
|
| 352 | $response->shouldReceive('getData')->andReturn([ |
|
| 353 | [ |
|
| 354 | 'Email' => '[email protected]', |
|
| 355 | ] |
|
| 356 | ]); |
|
| 357 | ||
| 358 | $this->client->shouldReceive('get')->withArgs([ |
|
| 359 | Resources::$Contact, |
|
| 360 | [ |
|
| 361 | 'ContactsList' => '123' |
|
| 362 | ] |
|
| 363 | ])->andReturn($response); |
|
| 364 | ||
| 365 | $response = $this->newsletter->hasMember('[email protected]'); |
|
| 366 | $this->assertTrue($response); |
|
| 367 | } |
|
| 368 | ||
| 369 | ||
| 370 | /** @test */ |
|