RemoteExceptionTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
dl 0
loc 28
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testExceptionWithCustomMessage() 0 12 1
A testException() 0 12 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\OpenIDClientTest\Exception;
6
7
use Facile\OpenIDClient\Exception\ExceptionInterface;
8
use Facile\OpenIDClient\Exception\RemoteException;
9
use Facile\OpenIDClientTest\TestCase;
10
use Psr\Http\Message\ResponseInterface;
11
12
class RemoteExceptionTest extends TestCase
13
{
14
    public function testException(): void
15
    {
16
        $response = $this->prophesize(ResponseInterface::class);
17
        $response->getReasonPhrase()->willReturn('Error message');
18
        $response->getStatusCode()->willReturn(400);
19
20
        $exception = new RemoteException($response->reveal());
21
22
        static::assertInstanceOf(ExceptionInterface::class, $exception);
23
        static::assertSame('Error message', $exception->getMessage());
24
        static::assertSame(400, $exception->getCode());
25
        static::assertSame($response->reveal(), $exception->getResponse());
26
    }
27
28
    public function testExceptionWithCustomMessage(): void
29
    {
30
        $response = $this->prophesize(ResponseInterface::class);
31
        $response->getReasonPhrase()->willReturn('Error message');
32
        $response->getStatusCode()->willReturn(400);
33
34
        $exception = new RemoteException($response->reveal(), 'foo');
35
36
        static::assertInstanceOf(ExceptionInterface::class, $exception);
37
        static::assertSame('foo', $exception->getMessage());
38
        static::assertSame(400, $exception->getCode());
39
        static::assertSame($response->reveal(), $exception->getResponse());
40
    }
41
}
42