Updated tests to fit current implementations

This commit is contained in:
Alejandro Celaya
2019-07-23 22:04:01 +02:00
parent 999beef349
commit 173bfbd300
3 changed files with 41 additions and 15 deletions

View File

@@ -46,6 +46,9 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface
}
}
/**
* @throws GeolocationDbUpdateFailedException
*/
private function downloadIfNeeded(?callable $mustBeUpdated, ?callable $handleProgress): void
{
if (! $this->dbUpdater->databaseFileExists()) {
@@ -59,21 +62,11 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface
}
}
private function buildIsTooOld(int $buildTimestamp): bool
{
$buildDate = Chronos::createFromTimestamp($buildTimestamp);
$now = Chronos::now();
return $now->gt($buildDate->addDays(35));
}
/**
* @throws GeolocationDbUpdateFailedException
*/
private function downloadNewDb(
bool $olderDbExists,
callable $mustBeUpdated = null,
callable $handleProgress = null
): void {
private function downloadNewDb(bool $olderDbExists, ?callable $mustBeUpdated, ?callable $handleProgress): void
{
if ($mustBeUpdated !== null) {
$mustBeUpdated($olderDbExists);
}
@@ -84,4 +77,11 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface
throw GeolocationDbUpdateFailedException::create($olderDbExists, $e);
}
}
private function buildIsTooOld(int $buildTimestamp): bool
{
$buildDate = Chronos::createFromTimestamp($buildTimestamp);
$now = Chronos::now();
return $now->gt($buildDate->addDays(35));
}
}