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

expiredJWTCreatesExpectedException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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