assertEquals($threshold, $e->getVisitsThreshold()); $this->assertEquals($expectedMessage, $e->getMessage()); $this->assertEquals(0, $e->getCode()); $this->assertNull($e->getPrevious()); } /** * @test * @dataProvider provideThresholds */ public function visitsThresholdIsProperlyReturned(int $threshold): void { $e = new DeleteShortUrlException($threshold); $this->assertEquals($threshold, $e->getVisitsThreshold()); $this->assertEquals('', $e->getMessage()); $this->assertEquals(0, $e->getCode()); $this->assertNull($e->getPrevious()); } public function provideThresholds(): array { return map(range(5, 50, 5), function (int $number) { $shortCode = $this->generateRandomString(6); return [$number, $shortCode, sprintf( 'Impossible to delete short URL with short code "%s" since it has more than "%s" visits.', $shortCode, $number )]; }); } }