Skip to content

Commit 7be5372

Browse files
committed
Improved tests
1 parent 866e90d commit 7be5372

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/GeoIPUpdater.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ class GeoIPUpdater
2121
/**
2222
* @param array $config
2323
*/
24-
public function __construct(array $config)
24+
public function __construct(array $config, Requester $requester = null)
2525
{
2626
$this->config = $config;
2727

28-
$this->requester = with(new Requester(new GuzzleClient()))->retry(2)->every(50);
28+
$this->requester = $requester ?: with(new Requester(new GuzzleClient()))->retry(2)->every(50);
2929
}
3030

3131
/**

tests/GeoIPUpdaterTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,22 @@ public function test_maxmind_updater()
3535

3636
unlink($database);
3737
}
38+
39+
public function test_maxmind_updater_dir_not_exist()
40+
{
41+
$database = __DIR__.'/data/new_dir/GeoLite2-City.mmdb';
42+
$config = [
43+
'driver' => 'maxmind',
44+
'maxmind' => [
45+
'database' => $database,
46+
],
47+
];
48+
49+
$geoipUpdater = new \PulkitJalan\GeoIP\GeoIPUpdater($config);
50+
51+
$this->assertEquals($geoipUpdater->update(), $database);
52+
53+
unlink($database);
54+
rmdir(pathinfo($database, PATHINFO_DIRNAME));
55+
}
3856
}

0 commit comments

Comments
 (0)