Passed
Pull Request — master (#354)
by Alejandro
05:24
created

AuthenticationExceptionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 7
dl 0
loc 19
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A providePrev() 0 4 1
A expiredJWTCreatesExpectedException() 0 7 1
1
<?php
2
declare(strict_types=1);
3
4
namespace ShlinkioTest\Shlink\Rest\Exception;
5
6
use Exception;
7
use PHPUnit\Framework\TestCase;
8
use Shlinkio\Shlink\Rest\Exception\AuthenticationException;
9
use Throwable;
10
11
class AuthenticationExceptionTest extends TestCase
12
{
13
    /**
14
     * @test
15
     * @dataProvider providePrev
16
     */
17
    public function expiredJWTCreatesExpectedException(?Throwable $prev): void
18
    {
19
        $e = AuthenticationException::expiredJWT($prev);
20
21
        $this->assertEquals($prev, $e->getPrevious());
22
        $this->assertEquals(-1, $e->getCode());
23
        $this->assertEquals('The token has expired.', $e->getMessage());
24
    }
25
26
    public function providePrev()
27
    {
28
        yield 'with previous exception' => [new Exception('Prev')];
29
        yield 'without previous exception' => [null];
30
    }
31
}
32