assertEquals('Provided short code "abc123" does not match the char set "def456"', $e->getMessage()); $this->assertEquals($prev !== null ? $prev->getCode() : -1, $e->getCode()); $this->assertEquals($prev, $e->getPrevious()); } public function providePrevious(): iterable { yield 'null previous' => [null]; yield 'instance previous' => [new Exception('Previous error', 10)]; } /** @test */ public function properlyCreatesExceptionFromNotFoundShortCode(): void { $e = InvalidShortCodeException::fromNotFoundShortCode('abc123'); $this->assertEquals('Provided short code "abc123" does not belong to a short URL', $e->getMessage()); } }