provideCreateArgs()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ShlinkioTest\Shlink\CLI\Exception;
6
7
use Exception;
8
use PHPUnit\Framework\TestCase;
9
use RuntimeException;
10
use Shlinkio\Shlink\CLI\Exception\GeolocationDbUpdateFailedException;
11
use Throwable;
12
13
class GeolocationDbUpdateFailedExceptionTest extends TestCase
14
{
15
    /**
16
     * @test
17
     * @dataProvider provideCreateArgs
18
     */
19
    public function createBuildsException(bool $olderDbExists, ?Throwable $prev): void
20
    {
21
        $e = GeolocationDbUpdateFailedException::create($olderDbExists, $prev);
22
23
        self::assertEquals($olderDbExists, $e->olderDbExists());
24
        self::assertEquals(
25
            'An error occurred while updating geolocation database, and an older version could not be found',
26
            $e->getMessage(),
27
        );
28
        self::assertEquals(0, $e->getCode());
29
        self::assertEquals($prev, $e->getPrevious());
30
    }
31
32
    public function provideCreateArgs(): iterable
33
    {
34
        yield 'older DB and no prev' => [true, null];
35
        yield 'older DB and prev' => [true, new RuntimeException('prev')];
36
        yield 'no older DB and no prev' => [false, null];
37
        yield 'no older DB and prev' => [false, new Exception('prev')];
38
    }
39
}
40