File: SendMessageResultTest.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 (35 lines) | stat: -rw-r--r-- 1,239 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
<?php

declare(strict_types=1);

namespace AsyncAws\Sqs\Tests\Unit\Result;

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

class SendMessageResultTest extends TestCase
{
    public function testSendMessageResult()
    {
        // see https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html
        $response = new SimpleMockedResponse(<<<JSON
{
    "MD5OfMessageAttributes": "3ae8f24a165a8cedc005670c81a27295",
    "MD5OfMessageBody": "fafb00f5732ab283681e124bf8747ed1",
    "MessageId": "5fea7756-0ea4-451a-a703-a558b933e274"
}
JSON
        );

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

        self::assertEquals('5fea7756-0ea4-451a-a703-a558b933e274', $result->getMessageId());
        self::assertEquals('fafb00f5732ab283681e124bf8747ed1', $result->getMD5OfMessageBody());
        self::assertEquals('3ae8f24a165a8cedc005670c81a27295', $result->getMD5OfMessageAttributes());
    }
}