Completed
Pull Request — master (#554)
by Alejandro
11:37 queued 08:50
created

ShortUrlNotFoundExceptionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A provideMessages() 0 11 1
A properlyCreatesExceptionFromNotFoundShortCode() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ShlinkioTest\Shlink\Core\Exception;
6
7
use PHPUnit\Framework\TestCase;
8
use Shlinkio\Shlink\Core\Exception\ShortUrlNotFoundException;
9
10
class ShortUrlNotFoundExceptionTest extends TestCase
11
{
12
    /**
13
     * @test
14
     * @dataProvider provideMessages
15
     */
16
    public function properlyCreatesExceptionFromNotFoundShortCode(
17
        string $expectedMessage,
18
        string $shortCode,
19
        ?string $domain
20
    ): void {
21
        $e = ShortUrlNotFoundException::fromNotFoundShortCode($shortCode, $domain);
22
        $this->assertEquals($expectedMessage, $e->getMessage());
23
    }
24
25
    public function provideMessages(): iterable
26
    {
27
        yield 'without domain' => [
28
            'No URL found with short code "abc123"',
29
            'abc123',
30
            null,
31
        ];
32
        yield 'with domain' => [
33
            'No URL found with short code "bar" for domain "foo"',
34
            'bar',
35
            'foo',
36
        ];
37
    }
38
}
39