diff --git a/src/Command/UpdateDatabaseCommand.php b/src/Command/UpdateDatabaseCommand.php
index 0471de8..dc5041c 100644
--- a/src/Command/UpdateDatabaseCommand.php
+++ b/src/Command/UpdateDatabaseCommand.php
@@ -115,9 +115,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$io->section(sprintf('Update "%s" database', $database));
- $this->downloader->download($this->databases[$database]['url'], $this->databases[$database]['path']);
-
- $io->comment(sprintf('Database %s updated', $database));
+ if (empty($this->databases[$database]['license'])) {
+ $io->warning(sprintf('GeoIP Database %s has no maxmind license key', $database));
+ } else {
+ $this->downloader->download($this->databases[$database]['url'], $this->databases[$database]['path']);
+ $io->comment(sprintf('Database %s updated', $database));
+ }
}
$io->success('Finished updating');
diff --git a/tests/Command/UpdateDatabaseCommandTest.php b/tests/Command/UpdateDatabaseCommandTest.php
index 2c84694..e860b30 100644
--- a/tests/Command/UpdateDatabaseCommandTest.php
+++ b/tests/Command/UpdateDatabaseCommandTest.php
@@ -190,6 +190,28 @@ public function testInvalidDatabasePath(): void
$command->run($this->input, $this->output);
}
+ public function testDownloadWithoutLicense(): void
+ {
+ $this->input
+ ->expects($this->at(4))
+ ->method('getArgument')
+ ->with('databases')
+ ->willReturn(['default']);
+
+ $databases = ['default' => [
+ 'url' => 'https://example.com/GeoIP2.tar.gz',
+ 'path' => '/tmp/GeoIP2.mmdb',
+ ]];
+
+ $this->downloader
+ ->expects($this->never())
+ ->method('download')
+ ->with($databases['default']['url'], $databases['default']['path']);
+
+ $command = new UpdateDatabaseCommand($this->downloader, $databases);
+ $command->run($this->input, $this->output);
+ }
+
public function testDownloadOneDatabases(): void
{
$this->input
@@ -201,6 +223,7 @@ public function testDownloadOneDatabases(): void
$databases = ['default' => [
'url' => 'https://example.com/GeoIP2.tar.gz',
'path' => '/tmp/GeoIP2.mmdb',
+ 'license' => 'license',
]];
$this->downloader
@@ -224,10 +247,12 @@ public function testDownloadSeveralDatabases(): void
'first' => [
'url' => 'https://example.com/GeoIP2-First.tar.gz',
'path' => '/tmp/GeoIP2-First.mmdb',
+ 'license' => 'license',
],
'second' => [
'url' => 'https://example.com/GeoIP2-Second.tar.gz',
'path' => '/tmp/GeoIP2-Second.mmdb',
+ 'license' => 'license',
],
];