diff --git a/module/CLI/src/Util/GeolocationDbUpdater.php b/module/CLI/src/Util/GeolocationDbUpdater.php index 1133d5a2..067a9561 100644 --- a/module/CLI/src/Util/GeolocationDbUpdater.php +++ b/module/CLI/src/Util/GeolocationDbUpdater.php @@ -30,7 +30,7 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface { try { $meta = $this->geoLiteDbReader->metadata(); - if ($this->buildIsOlderThanOneWeek($meta->__get('buildEpoch'))) { + if ($this->buildIsTooOld($meta->__get('buildEpoch'))) { $this->downloadNewDb(true, $mustBeUpdated, $handleProgress); } } catch (InvalidArgumentException $e) { @@ -39,11 +39,11 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface } } - private function buildIsOlderThanOneWeek(int $buildTimestamp): bool + private function buildIsTooOld(int $buildTimestamp): bool { $buildDate = Chronos::createFromTimestamp($buildTimestamp); $now = Chronos::now(); - return $now->gt($buildDate->addDays(7)); + return $now->gt($buildDate->addDays(35)); } /** @@ -55,7 +55,7 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface callable $handleProgress = null ): void { if ($mustBeUpdated !== null) { - $mustBeUpdated(); + $mustBeUpdated($olderDbExists); } try { diff --git a/module/CLI/test/Util/GeolocationDbUpdaterTest.php b/module/CLI/test/Util/GeolocationDbUpdaterTest.php index be6709fa..3ab69aa7 100644 --- a/module/CLI/test/Util/GeolocationDbUpdaterTest.php +++ b/module/CLI/test/Util/GeolocationDbUpdaterTest.php @@ -64,7 +64,7 @@ class GeolocationDbUpdaterTest extends TestCase /** * @test - * @dataProvider provideDaysBiggerThanSeven + * @dataProvider provideBigDays */ public function exceptionIsThrownWhenOlderDbIsTooOldAndDownloadFails(int $days): void { @@ -96,17 +96,17 @@ class GeolocationDbUpdaterTest extends TestCase $download->shouldHaveBeenCalledOnce(); } - public function provideDaysBiggerThanSeven(): iterable + public function provideBigDays(): iterable { - yield [8]; - yield [9]; - yield [10]; + yield [36]; + yield [50]; + yield [75]; yield [100]; } /** * @test - * @dataProvider provideDaysSmallerThanSeven + * @dataProvider provideSmallDays */ public function databaseIsNotUpdatedIfItIsYoungerThanOneWeek(int $days): void { @@ -130,9 +130,9 @@ class GeolocationDbUpdaterTest extends TestCase $download->shouldNotHaveBeenCalled(); } - public function provideDaysSmallerThanSeven(): iterable + public function provideSmallDays(): iterable { - return map(range(0, 6), function (int $days) { + return map(range(0, 34), function (int $days) { return [$days]; }); }