File: DeleteMessageBatchResultTest.php

package info (click to toggle)
php-async-aws-sqs 2.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 664 kB
  • sloc: php: 4,040; makefile: 31
file content (40 lines) | stat: -rw-r--r-- 1,169 bytes parent folder | download | duplicates (2)
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
<?php

namespace AsyncAws\Sqs\Tests\Unit\Result;

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

class DeleteMessageBatchResultTest extends TestCase
{
    public function testDeleteMessageBatchResult(): void
    {
        // see https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_DeleteMessageBatch.html
        $response = new SimpleMockedResponse(<<<JSON
{
    "Failed": [],
    "Successful": [
        {
            "Id": "msg1"
        },
        {
            "Id": "msg2"
        }
    ]
}
JSON
        );

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

        self::assertCount(2, $result->getSuccessful());
        self::assertSame('msg1', $result->getSuccessful()[0]->getId());
        self::assertSame('msg2', $result->getSuccessful()[1]->getId());
        self::assertCount(0, $result->getFailed());
    }
}