mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Added test to check for GeoLite db update disabling based on tracking options
This commit is contained in:
@@ -29,11 +29,13 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||
private GeolocationDbUpdater $geolocationDbUpdater;
|
||||
private ObjectProphecy $dbUpdater;
|
||||
private ObjectProphecy $geoLiteDbReader;
|
||||
private TrackingOptions $trackingOptions;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->dbUpdater = $this->prophesize(DbUpdaterInterface::class);
|
||||
$this->geoLiteDbReader = $this->prophesize(Reader::class);
|
||||
$this->trackingOptions = new TrackingOptions();
|
||||
|
||||
$locker = $this->prophesize(Lock\LockFactory::class);
|
||||
$lock = $this->prophesize(Lock\LockInterface::class);
|
||||
@@ -46,7 +48,7 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||
$this->dbUpdater->reveal(),
|
||||
$this->geoLiteDbReader->reveal(),
|
||||
$locker->reveal(),
|
||||
new TrackingOptions(),
|
||||
$this->trackingOptions,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -176,4 +178,27 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||
'record_size' => 4,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideTrackingOptions
|
||||
*/
|
||||
public function downloadDbIsSkippedIfTrackingIsDisabled(array $props): void
|
||||
{
|
||||
foreach ($props as $prop) {
|
||||
$this->trackingOptions->{$prop} = true;
|
||||
}
|
||||
|
||||
$this->geolocationDbUpdater->checkDbUpdate();
|
||||
|
||||
$this->dbUpdater->databaseFileExists(Argument::cetera())->shouldNotHaveBeenCalled();
|
||||
$this->geoLiteDbReader->metadata(Argument::cetera())->shouldNotHaveBeenCalled();
|
||||
}
|
||||
|
||||
public function provideTrackingOptions(): iterable
|
||||
{
|
||||
yield 'disableTracking' => [['disableTracking']];
|
||||
yield 'disableIpTracking' => [['disableIpTracking']];
|
||||
yield 'both' => [['disableTracking', 'disableIpTracking']];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user