File: PublishBatchResponseTest.php

package info (click to toggle)
php-async-aws-sns 1.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 516 kB
  • sloc: php: 2,567; makefile: 33
file content (43 lines) | stat: -rw-r--r-- 1,523 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

namespace AsyncAws\Sns\Tests\Unit\Result;

use AsyncAws\Core\Response;
use AsyncAws\Core\Test\Http\SimpleMockedResponse;
use AsyncAws\Core\Test\TestCase;
use AsyncAws\Sns\Result\PublishBatchResponse;
use Psr\Log\NullLogger;
use Symfony\Component\HttpClient\MockHttpClient;

class PublishBatchResponseTest extends TestCase
{
    /**
     * @see https://docs.aws.amazon.com/sns/latest/api/API_PublishBatch.html
     */
    public function testPublishBatchResponse(): void
    {
        $response = new SimpleMockedResponse('<PublishBatchResponse xmlns="https://sns.amazonaws.com/doc/2010-03-31/">
    <PublishBatchResult>
        <Failed>
        </Failed>
        <Successful>
            <member>
                <Id>qwertyuiop</Id>
                <MessageId>567910cd-659e-55d4-8ccb-5aaf14679dc0</MessageId>
            </member>
        </Successful>        
    </PublishBatchResult>
    <ResponseMetadata>
        <RequestId>d74b8436-ae13-5ab4-a9ff-ce54dfea72a0</RequestId>
    </ResponseMetadata>
</PublishBatchResponse>');

        $client = new MockHttpClient($response);
        $result = new PublishBatchResponse(new Response($client->request('POST', 'http://localhost'), $client, new NullLogger()));

        self::assertCount(0, $result->getFailed());
        self::assertCount(1, $result->getSuccessful());
        self::assertSame('qwertyuiop', $result->getSuccessful()[0]->getId());
        self::assertSame('567910cd-659e-55d4-8ccb-5aaf14679dc0', $result->getSuccessful()[0]->getMessageId());
    }
}