| Total Complexity | 3 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 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 | $expectedAdditional = ['shortCode' => $shortCode]; |
||
| 22 | if ($domain !== null) { |
||
| 23 | $expectedAdditional['domain'] = $domain; |
||
| 24 | } |
||
| 25 | |||
| 26 | $e = ShortUrlNotFoundException::fromNotFoundShortCode($shortCode, $domain); |
||
| 27 | |||
| 28 | $this->assertEquals($expectedMessage, $e->getMessage()); |
||
| 29 | $this->assertEquals($expectedMessage, $e->getDetail()); |
||
| 30 | $this->assertEquals('Short URL not found', $e->getTitle()); |
||
| 31 | $this->assertEquals('INVALID_SHORTCODE', $e->getType()); |
||
| 32 | $this->assertEquals(404, $e->getStatus()); |
||
| 33 | $this->assertEquals($expectedAdditional, $e->getAdditionalData()); |
||
| 34 | } |
||
| 35 | |||
| 36 | public function provideMessages(): iterable |
||
| 47 | ]; |
||
| 48 | } |
||
| 50 |