|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace PhpList\RestApiClient\Tests\Endpoint; |
| 6 | + |
| 7 | +use PhpList\RestApiClient\Client; |
| 8 | +use PhpList\RestApiClient\Endpoint\BouncesClient; |
| 9 | +use PhpList\RestApiClient\Response\Bounces\BounceCollection; |
| 10 | +use PHPUnit\Framework\TestCase; |
| 11 | + |
| 12 | +class BouncesClientMethodTest extends TestCase |
| 13 | +{ |
| 14 | + public function testListReturnsBounceCollection(): void |
| 15 | + { |
| 16 | + $mockClient = $this->createMock(Client::class); |
| 17 | + $mockClient->expects($this->once()) |
| 18 | + ->method('get') |
| 19 | + ->with('bounces') |
| 20 | + ->willReturn([ |
| 21 | + [ |
| 22 | + 'id' => 10, |
| 23 | + 'status' => 'not processed', |
| 24 | + 'date' => '2023-01-01T12:00:00Z', |
| 25 | + 'message_id' => 123, |
| 26 | + 'message_subject' => 'Newsletter', |
| 27 | + 'subscriber_id' => 456, |
| 28 | + 'subscriber_email' => 'user@example.com', |
| 29 | + 'comment' => 'Soft bounce', |
| 30 | + ], |
| 31 | + ]); |
| 32 | + |
| 33 | + $bouncesClient = new BouncesClient($mockClient); |
| 34 | + $result = $bouncesClient->list(); |
| 35 | + |
| 36 | + $this->assertInstanceOf(BounceCollection::class, $result); |
| 37 | + $this->assertCount(1, $result->items); |
| 38 | + $this->assertSame(10, $result->items[0]->id); |
| 39 | + $this->assertSame(123, $result->items[0]->messageId); |
| 40 | + $this->assertSame('user@example.com', $result->items[0]->subscriberEmail); |
| 41 | + } |
| 42 | +} |
0 commit comments