Skip to content

Commit

Permalink
Fix DownloadGeoLiteDbCommandTest
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Dec 11, 2024
1 parent 84d12f6 commit 2ede615
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions module/CLI/test/Command/Visit/DownloadGeoLiteDbCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Shlinkio\Shlink\CLI\Util\ExitCode;
use Shlinkio\Shlink\Core\Exception\GeolocationDbUpdateFailedException;
use Shlinkio\Shlink\Core\Geolocation\GeolocationDbUpdaterInterface;
use Shlinkio\Shlink\Core\Geolocation\GeolocationDownloadProgressHandlerInterface;
use Shlinkio\Shlink\Core\Geolocation\GeolocationResult;
use ShlinkioTest\Shlink\CLI\Util\CliTestUtils;
use Symfony\Component\Console\Tester\CommandTester;
Expand All @@ -36,9 +37,9 @@ public function showsProperMessageWhenGeoLiteUpdateFails(
int $expectedExitCode,
): void {
$this->dbUpdater->expects($this->once())->method('checkDbUpdate')->withAnyParameters()->willReturnCallback(
function (callable $beforeDownload, callable $handleProgress) use ($olderDbExists): void {
$beforeDownload($olderDbExists);
$handleProgress(100, 50);
function (GeolocationDownloadProgressHandlerInterface $handler) use ($olderDbExists): void {
$handler->beforeDownload($olderDbExists);
$handler->handleProgress(100, 50, $olderDbExists);

throw $olderDbExists
? GeolocationDbUpdateFailedException::withOlderDb()
Expand Down Expand Up @@ -105,8 +106,8 @@ public function printsExpectedMessageWhenNoErrorOccurs(callable $checkUpdateBeha
public static function provideSuccessParams(): iterable
{
yield 'up to date db' => [fn () => GeolocationResult::CHECK_SKIPPED, '[INFO] GeoLite2 db file is up to date.'];
yield 'outdated db' => [function (callable $beforeDownload): GeolocationResult {
$beforeDownload(true);
yield 'outdated db' => [function (GeolocationDownloadProgressHandlerInterface $handler): GeolocationResult {
$handler->beforeDownload(true);
return GeolocationResult::DB_CREATED;
}, '[OK] GeoLite2 db file properly downloaded.'];
}
Expand Down

0 comments on commit 2ede615

Please sign in to comment.