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

ShortUrlNotFoundExceptionTest::provideMessages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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