| Total Complexity | 3 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class ShortUrlNotFoundExceptionTest extends TestCase |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @test |
||
| 15 | * @dataProvider provideMessages |
||
| 16 | */ |
||
| 17 | public function properlyCreatesExceptionFromNotFoundShortCode( |
||
| 18 | string $expectedMessage, |
||
| 19 | string $shortCode, |
||
| 20 | ?string $domain |
||
| 21 | ): void { |
||
| 22 | $expectedAdditional = ['shortCode' => $shortCode]; |
||
| 23 | if ($domain !== null) { |
||
| 24 | $expectedAdditional['domain'] = $domain; |
||
| 25 | } |
||
| 26 | |||
| 27 | $e = ShortUrlNotFoundException::fromNotFound(new ShortUrlIdentifier($shortCode, $domain)); |
||
| 28 | |||
| 29 | self::assertEquals($expectedMessage, $e->getMessage()); |
||
| 30 | self::assertEquals($expectedMessage, $e->getDetail()); |
||
| 31 | self::assertEquals('Short URL not found', $e->getTitle()); |
||
| 32 | self::assertEquals('INVALID_SHORTCODE', $e->getType()); |
||
| 33 | self::assertEquals(404, $e->getStatus()); |
||
| 34 | self::assertEquals($expectedAdditional, $e->getAdditionalData()); |
||
| 35 | } |
||
| 36 | |||
| 37 | public function provideMessages(): iterable |
||
| 48 | ]; |
||
| 49 | } |
||
| 51 |