Skip to content

Commit

Permalink
Merge pull request #56 from peter-gribanov/enum_edition
Browse files Browse the repository at this point in the history
Fix the list of available values for the edition configuration option
  • Loading branch information
peter-gribanov committed Mar 12, 2020
2 parents 8967063 + 72db0a9 commit c45b263
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ gpslab_geoip:
# Your personal licence key
license: 'XXXXXXXXXXXXXXXX'

# Database edition ID
# Database edition ID GeoLite2-ASN, GeoLite2-City or GeoLite2-Country
edition: 'GeoLite2-City'
```

Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private function getDatabaseNode(): ArrayNodeDefinition

$database_node->children()->scalarNode('license');

$database_node->children()->scalarNode('edition');
$database_node->children()->enumNode('edition')->values(['GeoLite2-ASN', 'GeoLite2-City', 'GeoLite2-Country']);

return $root_node;
}
Expand Down
73 changes: 40 additions & 33 deletions tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,18 @@ public function getBadConfigs(): array
'license' => 'LICENSE',
],
];
// unrecognized option "edition" under "gpslab_geoip"
// permissible values: "GeoLite2-ASN", "GeoLite2-City", "GeoLite2-Country"
$configurations[] = [
'gpslab_geoip' => [
'license' => 'LICENSE',
'edition' => 'EDITION',
],
];
// unrecognized option "edition" under "gpslab_geoip"
$configurations[] = [
'gpslab_geoip' => [
'license' => 'LICENSE',
'edition' => 'GeoLite2-City',
'databases' => [],
],
];
Expand All @@ -49,7 +56,7 @@ public function getBadConfigs(): array
'databases' => [
'foo' => [
'license' => 'LICENSE',
'edition' => 'EDITION',
'edition' => 'GeoLite2-City',
],
],
],
Expand All @@ -61,7 +68,7 @@ public function getBadConfigs(): array
'databases' => [
'foo' => [
'license' => 'LICENSE',
'edition' => 'EDITION',
'edition' => 'GeoLite2-City',
],
],
],
Expand All @@ -72,7 +79,7 @@ public function getBadConfigs(): array
'databases' => [
'default' => [
'license' => 'LICENSE',
'edition' => 'EDITION',
'edition' => 'GeoLite2-City',
'url' => 'example.com',
'path' => '/tmp/GeoIP2-First.mmdb',
],
Expand All @@ -82,7 +89,7 @@ public function getBadConfigs(): array

$full_config = [
'license' => 'LICENSE',
'edition' => 'EDITION',
'edition' => 'GeoLite2-City',
'url' => 'https://example.com/GoeIp2.tar.gz',
'path' => '/var/local/GoeIp2',
'locales' => ['en'],
Expand Down Expand Up @@ -202,16 +209,16 @@ public function getConfigs(): array
$return[] = [$cache_dir, [
'gpslab_geoip' => [
'license' => 'LICENSE',
'edition' => 'EDITION',
'edition' => 'GeoLite2-City',
],
], [
'default_database' => 'default',
'databases' => [
'default' => [
'license' => 'LICENSE',
'edition' => 'EDITION',
'url' => sprintf(self::URL, 'EDITION', 'LICENSE'),
'path' => sprintf(self::PATH, $real_cache_dir, 'EDITION'),
'edition' => 'GeoLite2-City',
'url' => sprintf(self::URL, 'GeoLite2-City', 'LICENSE'),
'path' => sprintf(self::PATH, $real_cache_dir, 'GeoLite2-City'),
'locales' => ['en'],
],
],
Expand All @@ -222,7 +229,7 @@ public function getConfigs(): array
'license' => 'LICENSE',
'databases' => [
'default' => [
'edition' => 'EDITION',
'edition' => 'GeoLite2-City',
'locales' => ['ru'],
],
],
Expand All @@ -231,11 +238,11 @@ public function getConfigs(): array
'license' => 'LICENSE',
'databases' => [
'default' => [
'edition' => 'EDITION',
'edition' => 'GeoLite2-City',
'locales' => ['ru'],
'license' => 'LICENSE',
'url' => sprintf(self::URL, 'EDITION', 'LICENSE'),
'path' => sprintf(self::PATH, $real_cache_dir, 'EDITION'),
'url' => sprintf(self::URL, 'GeoLite2-City', 'LICENSE'),
'path' => sprintf(self::PATH, $real_cache_dir, 'GeoLite2-City'),
],
],
'default_database' => 'default',
Expand All @@ -247,16 +254,16 @@ public function getConfigs(): array
'databases' => [
'foo' => [
'license' => 'LICENSE1',
'edition' => 'EDITION_1',
'edition' => 'GeoLite2-ASN',
],
'bar' => [
'license' => 'LICENSE_2',
'edition' => 'EDITION_2',
'edition' => 'GeoLite2-City',
'locales' => ['ru'],
],
'baz' => [
'license' => 'LICENSE_3',
'edition' => 'EDITION_3',
'edition' => 'GeoLite2-Country',
'locales' => ['fr', 'en'],
],
],
Expand All @@ -266,24 +273,24 @@ public function getConfigs(): array
'databases' => [
'foo' => [
'license' => 'LICENSE1',
'edition' => 'EDITION_1',
'url' => sprintf(self::URL, 'EDITION_1', 'LICENSE1'),
'path' => sprintf(self::PATH, $real_cache_dir, 'EDITION_1'),
'edition' => 'GeoLite2-ASN',
'url' => sprintf(self::URL, 'GeoLite2-ASN', 'LICENSE1'),
'path' => sprintf(self::PATH, $real_cache_dir, 'GeoLite2-ASN'),
'locales' => ['en'],
],
'bar' => [
'license' => 'LICENSE_2',
'edition' => 'EDITION_2',
'edition' => 'GeoLite2-City',
'locales' => ['ru'],
'url' => sprintf(self::URL, 'EDITION_2', 'LICENSE_2'),
'path' => sprintf(self::PATH, $real_cache_dir, 'EDITION_2'),
'url' => sprintf(self::URL, 'GeoLite2-City', 'LICENSE_2'),
'path' => sprintf(self::PATH, $real_cache_dir, 'GeoLite2-City'),
],
'baz' => [
'license' => 'LICENSE_3',
'edition' => 'EDITION_3',
'edition' => 'GeoLite2-Country',
'locales' => ['fr', 'en'],
'url' => sprintf(self::URL, 'EDITION_3', 'LICENSE_3'),
'path' => sprintf(self::PATH, $real_cache_dir, 'EDITION_3'),
'url' => sprintf(self::URL, 'GeoLite2-Country', 'LICENSE_3'),
'path' => sprintf(self::PATH, $real_cache_dir, 'GeoLite2-Country'),
],
],
'locales' => ['en'],
Expand All @@ -294,11 +301,11 @@ public function getConfigs(): array
'locales' => ['ru', 'en'],
'databases' => [
'default' => [
'edition' => 'EDITION_1',
'edition' => 'GeoLite2-ASN',
'locales' => ['fr'],
],
'foo' => [
'edition' => 'EDITION_2',
'edition' => 'GeoLite2-City',
'license' => 'LICENSE_2',
],
],
Expand All @@ -308,18 +315,18 @@ public function getConfigs(): array
'locales' => ['ru', 'en'],
'databases' => [
'default' => [
'edition' => 'EDITION_1',
'edition' => 'GeoLite2-ASN',
'locales' => ['fr'],
'license' => 'LICENSE_1',
'url' => sprintf(self::URL, 'EDITION_1', 'LICENSE_1'),
'path' => sprintf(self::PATH, $real_cache_dir, 'EDITION_1'),
'url' => sprintf(self::URL, 'GeoLite2-ASN', 'LICENSE_1'),
'path' => sprintf(self::PATH, $real_cache_dir, 'GeoLite2-ASN'),
],
'foo' => [
'edition' => 'EDITION_2',
'edition' => 'GeoLite2-City',
'license' => 'LICENSE_2',
'locales' => ['ru', 'en'],
'url' => sprintf(self::URL, 'EDITION_2', 'LICENSE_2'),
'path' => sprintf(self::PATH, $real_cache_dir, 'EDITION_2'),
'url' => sprintf(self::URL, 'GeoLite2-City', 'LICENSE_2'),
'path' => sprintf(self::PATH, $real_cache_dir, 'GeoLite2-City'),
],
],
'default_database' => 'default',
Expand Down

0 comments on commit c45b263

Please sign in to comment.