mirror of
https://github.com/shlinkio/shlink.git
synced 2026-02-28 12:13:13 +08:00
Updated tests to fit current implementations
This commit is contained in:
@@ -58,8 +58,10 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||
$mustBeUpdated = function () {
|
||||
$this->assertTrue(true);
|
||||
};
|
||||
$getMeta = $this->geoLiteDbReader->metadata()->willThrow(InvalidArgumentException::class);
|
||||
$prev = new RuntimeException('');
|
||||
|
||||
$fileExists = $this->dbUpdater->databaseFileExists()->willReturn(false);
|
||||
$getMeta = $this->geoLiteDbReader->metadata();
|
||||
$download = $this->dbUpdater->downloadFreshCopy(null)->willThrow($prev);
|
||||
|
||||
try {
|
||||
@@ -72,7 +74,8 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||
$this->assertFalse($e->olderDbExists());
|
||||
}
|
||||
|
||||
$getMeta->shouldHaveBeenCalledOnce();
|
||||
$fileExists->shouldHaveBeenCalledOnce();
|
||||
$getMeta->shouldNotHaveBeenCalled();
|
||||
$download->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
|
||||
@@ -82,6 +85,7 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||
*/
|
||||
public function exceptionIsThrownWhenOlderDbIsTooOldAndDownloadFails(int $days): void
|
||||
{
|
||||
$fileExists = $this->dbUpdater->databaseFileExists()->willReturn(true);
|
||||
$getMeta = $this->geoLiteDbReader->metadata()->willReturn(new Metadata([
|
||||
'binary_format_major_version' => '',
|
||||
'binary_format_minor_version' => '',
|
||||
@@ -106,6 +110,7 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||
$this->assertTrue($e->olderDbExists());
|
||||
}
|
||||
|
||||
$fileExists->shouldHaveBeenCalledOnce();
|
||||
$getMeta->shouldHaveBeenCalledOnce();
|
||||
$download->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
@@ -124,6 +129,7 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||
*/
|
||||
public function databaseIsNotUpdatedIfItIsYoungerThanOneWeek(int $days): void
|
||||
{
|
||||
$fileExists = $this->dbUpdater->databaseFileExists()->willReturn(true);
|
||||
$getMeta = $this->geoLiteDbReader->metadata()->willReturn(new Metadata([
|
||||
'binary_format_major_version' => '',
|
||||
'binary_format_minor_version' => '',
|
||||
@@ -140,6 +146,7 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||
|
||||
$this->geolocationDbUpdater->checkDbUpdate();
|
||||
|
||||
$fileExists->shouldHaveBeenCalledOnce();
|
||||
$getMeta->shouldHaveBeenCalledOnce();
|
||||
$download->shouldNotHaveBeenCalled();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user