File: JsonRpcAwsErrorFactoryTest.php

package info (click to toggle)
php-async-aws-core 1.27.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 988 kB
  • sloc: php: 6,837; makefile: 32
file content (33 lines) | stat: -rw-r--r-- 1,107 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
<?php

declare(strict_types=1);

namespace AsyncAws\Core\Tests\Unit\AwsError;

use AsyncAws\Core\AwsError\JsonRpcAwsErrorFactory;
use PHPUnit\Framework\TestCase;

class JsonRpcAwsErrorFactoryTest extends TestCase
{
    public function testDynamoDbError()
    {
        $content = '{"__type":"com.amazonaws.dynamodb.v20120810#ResourceNotFoundException","message":"Requested resource not found: Table: tablename not found"}';

        $factory = new JsonRpcAwsErrorFactory();
        $awsError = $factory->createFromContent($content, []);

        self::assertSame('ResourceNotFoundException', $awsError->getCode());
        self::assertSame('Requested resource not found: Table: tablename not found', $awsError->getMessage());
    }

    public function testCreateFromContent()
    {
        $content = '{"__type":"foo","Message":"capitaliazed message"}';

        $factory = new JsonRpcAwsErrorFactory();
        $awsError = $factory->createFromContent($content, []);

        self::assertSame('foo', $awsError->getCode());
        self::assertSame('capitaliazed message', $awsError->getMessage());
    }
}