mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-20 06:03:37 -06:00
Fix DownloadGeoLiteDbCommandTest
This commit is contained in:
parent
84d12f6811
commit
2ede615da8
@ -12,6 +12,7 @@ use Shlinkio\Shlink\CLI\Command\Visit\DownloadGeoLiteDbCommand;
|
||||
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;
|
||||
@ -36,9 +37,9 @@ class DownloadGeoLiteDbCommandTest extends TestCase
|
||||
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()
|
||||
@ -105,8 +106,8 @@ class DownloadGeoLiteDbCommandTest extends TestCase
|
||||
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.'];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user