File: ClientExceptionTest.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 (28 lines) | stat: -rw-r--r-- 1,087 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
<?php

declare(strict_types=1);

namespace AsyncAws\Core\Tests\Unit\Exception\Http;

use AsyncAws\Core\AwsError\AwsError;
use AsyncAws\Core\Exception\Http\ClientException;
use AsyncAws\Core\Test\Http\SimpleMockedResponse;
use PHPUnit\Framework\TestCase;

class ClientExceptionTest extends TestCase
{
    public function testException()
    {
        $response = new SimpleMockedResponse('content', ['content-type' => 'application/json'], 400);
        $awsError = new AwsError('code', 'message', 'type', 'detail');
        $exception = new ClientException($response, $awsError);

        self::assertEquals(400, $exception->getCode());
        self::assertEquals('message', $exception->getAwsMessage());
        self::assertEquals('code', $exception->getAwsCode());
        self::assertEquals('type', $exception->getAwsType());
        self::assertEquals('detail', $exception->getAwsDetail());
        self::assertStringContainsString('HTTP 400 returned for "".', $exception->getMessage());
        self::assertStringContainsString('Message: message', $exception->getMessage());
    }
}