From 23c7629129fdf47dabc89383d525527593bc7801 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 19 Feb 2018 19:01:03 +0000 Subject: [PATCH] Updating the package --- .gitignore | 1 + .scrutinizer.yml | 2 +- .travis.yml | 6 ++-- LICENSE.md | 2 +- composer.json | 17 ++++------ config/geoip.php | 37 +++++++++++++-------- tests/DriverManagerTest.php | 6 ++-- tests/Drivers/FreeGeoIpDriverTest.php | 12 +++---- tests/Drivers/IpApiDriverTest.php | 20 +++++------ tests/Drivers/MaxmindDatabaseDriverTest.php | 12 +++---- tests/Entities/ContinentsTest.php | 12 +++---- tests/Entities/CurrenciesTest.php | 12 +++---- tests/GeoIPServiceProviderTest.php | 4 +-- tests/GeoIPTest.php | 26 +++++++-------- 14 files changed, 86 insertions(+), 83 deletions(-) diff --git a/.gitignore b/.gitignore index cb1299f..08011a8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /vendor/ /composer.lock /composer.phar +/phpunit.xml diff --git a/.scrutinizer.yml b/.scrutinizer.yml index d44a72f..282131b 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -22,7 +22,7 @@ checks: tools: external_code_coverage: timeout: 600 - runs: 2 + runs: 3 php_code_sniffer: enabled: true config: diff --git a/.travis.yml b/.travis.yml index 03a87c5..6a8ff58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,18 +5,16 @@ sudo: false php: - 7.0 - 7.1 + - 7.2 - nightly matrix: allow_failures: - php: nightly -env: - - TESTBENCH_VERSION=3.5.* - before_script: - travis_retry composer self-update - - travis_retry composer require --prefer-source --no-interaction --dev "orchestra/testbench:${TESTBENCH_VERSION}" + - travis_retry composer install --prefer-source --no-interaction script: - composer validate diff --git a/LICENSE.md b/LICENSE.md index 640e814..47a573d 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015-2017 ARCANEDEV - GeoIP +Copyright (c) 2015-2018 ARCANEDEV - GeoIP Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/composer.json b/composer.json index 739d050..8bac079 100644 --- a/composer.json +++ b/composer.json @@ -14,13 +14,14 @@ ], "require": { "php": ">=7.0", - "arcanedev/support": "~4.2", + "arcanedev/support": "~4.2.0", "guzzlehttp/guzzle": "~6.0" }, "require-dev": { - "phpunit/phpcov": "~4.0", - "phpunit/phpunit": "~6.0", - "geoip2/geoip2": "~2.6" + "orchestra/testbench": "~3.5.0", + "phpunit/phpunit": "~6.0", + "phpunit/phpcov": "~4.0", + "geoip2/geoip2": "~2.6" }, "autoload": { "psr-4": { @@ -36,16 +37,10 @@ "laravel": { "providers": [ "Arcanedev\\GeoIP\\GeoIPServiceProvider" - ], - "aliases": { - "GeoIP": "Arcanedev\\GeoIP\\Facades\\GeoIP" - } + ] } }, "suggest": { "geoip2/geoip2": "Required if you're going to use the MaxMind database or web service." - }, - "scripts": { - "testbench": "composer require --dev \"orchestra/testbench=~3.5.0\"" } } diff --git a/config/geoip.php b/config/geoip.php index b698df1..8fe4f22 100644 --- a/config/geoip.php +++ b/config/geoip.php @@ -1,17 +1,20 @@ 'freegeoip', - /* ------------------------------------------------------------------------------------------------ + /* ----------------------------------------------------------------- | Supported Drivers - | ------------------------------------------------------------------------------------------------ + | ----------------------------------------------------------------- */ + 'supported' => [ 'freegeoip' => [ 'driver' => Arcanedev\GeoIP\Drivers\FreeGeoIpDriver::class, @@ -47,10 +50,11 @@ ], ], - /* ------------------------------------------------------------------------------------------------ + /* ----------------------------------------------------------------- | Cache - | ------------------------------------------------------------------------------------------------ + | ----------------------------------------------------------------- */ + 'cache' => [ 'mode' => 'all', @@ -59,20 +63,22 @@ 'expires' => 30, ], - /* ------------------------------------------------------------------------------------------------ + /* ----------------------------------------------------------------- | Log failures - | ------------------------------------------------------------------------------------------------ + | ----------------------------------------------------------------- */ + 'log-failures' => [ 'enabled' => true, 'location' => storage_path('logs/geoip.log'), ], - /* ------------------------------------------------------------------------------------------------ + /* ----------------------------------------------------------------- | Entities - | ------------------------------------------------------------------------------------------------ + | ----------------------------------------------------------------- */ + 'location' => [ 'default' => [ 'ip' => '', @@ -90,10 +96,11 @@ ], ], - /* ------------------------------------------------------------------------------------------------ + /* ----------------------------------------------------------------- | Continents - | ------------------------------------------------------------------------------------------------ + | ----------------------------------------------------------------- */ + 'continents' => [ 'A1' => '--', 'A2' => '--', @@ -349,10 +356,11 @@ 'ZW' => 'AF', ], - /* ------------------------------------------------------------------------------------------------ + /* ----------------------------------------------------------------- | Currencies - | ------------------------------------------------------------------------------------------------ + | ----------------------------------------------------------------- */ + 'currencies' => [ 'included' => true, @@ -606,4 +614,5 @@ 'ZW' => 'ZWL', ], ], + ]; diff --git a/tests/DriverManagerTest.php b/tests/DriverManagerTest.php index 66ce960..268e349 100644 --- a/tests/DriverManagerTest.php +++ b/tests/DriverManagerTest.php @@ -50,14 +50,14 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->manager); + static::assertInstanceOf($expected, $this->manager); } } /** @test */ public function it_can_get_default_driver() { - $this->assertInstanceOf( + static::assertInstanceOf( \Arcanedev\GeoIP\Drivers\FreeGeoIpDriver::class, $this->manager->driver() ); @@ -74,7 +74,7 @@ public function it_can_get_driver_by_name() ]; foreach ($drivers as $name => $driver) { - $this->assertInstanceOf($driver, $this->manager->driver($name)); + static::assertInstanceOf($driver, $this->manager->driver($name)); } } } diff --git a/tests/Drivers/FreeGeoIpDriverTest.php b/tests/Drivers/FreeGeoIpDriverTest.php index 073d40f..696c8e4 100644 --- a/tests/Drivers/FreeGeoIpDriverTest.php +++ b/tests/Drivers/FreeGeoIpDriverTest.php @@ -53,7 +53,7 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->driver); + static::assertInstanceOf($expected, $this->driver); } } @@ -62,7 +62,7 @@ public function it_can_locate() { $location = $this->driver->locate('128.101.101.101'); - $this->assertInstanceOf(\Arcanedev\GeoIP\Location::class, $location); + static::assertInstanceOf(\Arcanedev\GeoIP\Location::class, $location); $expected = [ 'ip' => '128.101.101.101', @@ -78,10 +78,10 @@ public function it_can_locate() 'continent' => 'NA', ]; - $this->assertSame($expected, $location->attributes()); - $this->assertSame($expected, $location->toArray()); + static::assertSame($expected, $location->attributes()); + static::assertSame($expected, $location->toArray()); - $this->assertFalse($location->default); - $this->assertSame($expected['city'].', '.$expected['state_code'], $location->display_name); + static::assertFalse($location->default); + static::assertSame($expected['city'].', '.$expected['state_code'], $location->display_name); } } diff --git a/tests/Drivers/IpApiDriverTest.php b/tests/Drivers/IpApiDriverTest.php index 1cb844a..a8b62c2 100644 --- a/tests/Drivers/IpApiDriverTest.php +++ b/tests/Drivers/IpApiDriverTest.php @@ -53,7 +53,7 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->driver); + static::assertInstanceOf($expected, $this->driver); } } @@ -62,26 +62,26 @@ public function it_can_locate() { $location = $this->driver->locate('128.101.101.101'); - $this->assertInstanceOf(\Arcanedev\GeoIP\Location::class, $location); + static::assertInstanceOf(\Arcanedev\GeoIP\Location::class, $location); $expected = [ 'ip' => '128.101.101.101', 'iso_code' => 'US', 'country' => 'United States', - 'city' => 'Minneapolis', + 'city' => 'Saint Paul', 'state' => 'Minnesota', 'state_code' => 'MN', - 'postal_code' => '55414', - 'latitude' => 44.9759, - 'longitude' => -93.2166, + 'postal_code' => '55102', + 'latitude' => 44.9278, + 'longitude' => -93.1162, 'timezone' => 'America/Chicago', 'continent' => 'NA', ]; - $this->assertSame($expected, $location->attributes()); - $this->assertSame($expected, $location->toArray()); + static::assertSame($expected, $location->attributes()); + static::assertSame($expected, $location->toArray()); - $this->assertFalse($location->default); - $this->assertSame($expected['city'].', '.$expected['state_code'], $location->display_name); + static::assertFalse($location->default); + static::assertSame($expected['city'].', '.$expected['state_code'], $location->display_name); } } diff --git a/tests/Drivers/MaxmindDatabaseDriverTest.php b/tests/Drivers/MaxmindDatabaseDriverTest.php index cfafae0..3f1ba9a 100644 --- a/tests/Drivers/MaxmindDatabaseDriverTest.php +++ b/tests/Drivers/MaxmindDatabaseDriverTest.php @@ -18,7 +18,7 @@ class MaxmindDatabaseDriverTest extends TestCase /** @test */ public function it_can_be_instantiated() { - $this->assertInstanceOf( + static::assertInstanceOf( \Arcanedev\GeoIP\Drivers\MaxmindDatabaseDriver::class, $this->makeDriver() ); @@ -31,7 +31,7 @@ public function it_can_locate() $location = $this->makeDriver()->locate('128.101.101.101'); - $this->assertInstanceOf(\Arcanedev\GeoIP\Location::class, $location); + static::assertInstanceOf(\Arcanedev\GeoIP\Location::class, $location); $expected = [ 'ip' => '128.101.101.101', @@ -47,11 +47,11 @@ public function it_can_locate() 'continent' => 'NA', ]; - $this->assertSame($expected, $location->attributes()); - $this->assertSame($expected, $location->toArray()); + static::assertSame($expected, $location->attributes()); + static::assertSame($expected, $location->toArray()); - $this->assertFalse($location->default); - $this->assertSame($expected['city'].', '.$expected['state_code'], $location->display_name); + static::assertFalse($location->default); + static::assertSame($expected['city'].', '.$expected['state_code'], $location->display_name); } /** diff --git a/tests/Entities/ContinentsTest.php b/tests/Entities/ContinentsTest.php index ada375d..e733c06 100644 --- a/tests/Entities/ContinentsTest.php +++ b/tests/Entities/ContinentsTest.php @@ -52,11 +52,11 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->continents); + static::assertInstanceOf($expected, $this->continents); } - $this->assertFalse($this->continents->isEmpty()); - $this->assertCount(252, $this->continents); + static::assertFalse($this->continents->isEmpty()); + static::assertCount(252, $this->continents); } /** @test */ @@ -70,10 +70,10 @@ public function it_can_get_continent() ]; foreach ($expectations as $key => $expected) { - $this->assertSame($expected, $this->continents->get($key)); + static::assertSame($expected, $this->continents->get($key)); } - $this->assertNull($this->continents->get('ZZ')); - $this->assertSame('Unknown', $this->continents->get('ZZ', 'Unknown')); + static::assertNull($this->continents->get('ZZ')); + static::assertSame('Unknown', $this->continents->get('ZZ', 'Unknown')); } } diff --git a/tests/Entities/CurrenciesTest.php b/tests/Entities/CurrenciesTest.php index 225d2b1..7786593 100644 --- a/tests/Entities/CurrenciesTest.php +++ b/tests/Entities/CurrenciesTest.php @@ -51,11 +51,11 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->currencies); + static::assertInstanceOf($expected, $this->currencies); } - $this->assertFalse($this->currencies->isEmpty()); - $this->assertCount(247, $this->currencies); + static::assertFalse($this->currencies->isEmpty()); + static::assertCount(247, $this->currencies); } /** @test */ @@ -68,10 +68,10 @@ public function it_can_get_continent() ]; foreach ($expectations as $key => $expected) { - $this->assertSame($expected, $this->currencies->get($key)); + static::assertSame($expected, $this->currencies->get($key)); } - $this->assertNull($this->currencies->get('ZZ')); - $this->assertSame('Unknown', $this->currencies->get('ZZ', 'Unknown')); + static::assertNull($this->currencies->get('ZZ')); + static::assertSame('Unknown', $this->currencies->get('ZZ', 'Unknown')); } } diff --git a/tests/GeoIPServiceProviderTest.php b/tests/GeoIPServiceProviderTest.php index 4fbaa8c..3bff9c2 100644 --- a/tests/GeoIPServiceProviderTest.php +++ b/tests/GeoIPServiceProviderTest.php @@ -51,7 +51,7 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->provider); + static::assertInstanceOf($expected, $this->provider); } } @@ -66,6 +66,6 @@ public function it_can_provides() \Arcanedev\GeoIP\Contracts\DriverFactory::class, ]; - $this->assertSame($expected, $this->provider->provides()); + static::assertSame($expected, $this->provider->provides()); } } diff --git a/tests/GeoIPTest.php b/tests/GeoIPTest.php index ad49235..5318c2d 100644 --- a/tests/GeoIPTest.php +++ b/tests/GeoIPTest.php @@ -49,20 +49,20 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->geoip); + static::assertInstanceOf($expected, $this->geoip); } } /** @test */ public function it_can_get_driver() { - $this->assertInstanceOf(\Arcanedev\GeoIP\Contracts\GeoIPDriver::class, $this->geoip->driver()); + static::assertInstanceOf(\Arcanedev\GeoIP\Contracts\GeoIPDriver::class, $this->geoip->driver()); } /** @test */ public function it_can_get_cache() { - $this->assertInstanceOf(\Arcanedev\GeoIP\Contracts\GeoIPCache::class, $this->geoip->cache()); + static::assertInstanceOf(\Arcanedev\GeoIP\Contracts\GeoIPCache::class, $this->geoip->cache()); } /** @test */ @@ -75,7 +75,7 @@ public function it_can_get_currency_from_config() ]; foreach ($currencies as $iso => $expected) { - $this->assertSame($expected, $this->geoip->getCurrency($iso)); + static::assertSame($expected, $this->geoip->getCurrency($iso)); } } @@ -86,7 +86,7 @@ public function it_can_get_location() $location = $this->geoip->location($ip); - $this->assertInstanceOf(\Arcanedev\GeoIP\Location::class, $location); + static::assertInstanceOf(\Arcanedev\GeoIP\Location::class, $location); $expected = [ 'ip' => '128.101.101.101', @@ -104,11 +104,11 @@ public function it_can_get_location() 'default' => false, ]; - $this->assertSame($expected, $location->attributes()); - $this->assertSame($expected, $location->toArray()); + static::assertSame($expected, $location->attributes()); + static::assertSame($expected, $location->toArray()); - $this->assertFalse($location->default); - $this->assertSame($expected['city'].', '.$expected['state_code'], $location->display_name); + static::assertFalse($location->default); + static::assertSame($expected['city'].', '.$expected['state_code'], $location->display_name); } /** @test */ @@ -131,10 +131,10 @@ public function it_can_get_default_location_if_it_fails() $location = $this->geoip->location('0.0.0'); - $this->assertSame($default, $location->attributes()); - $this->assertSame($default, $location->toArray()); + static::assertSame($default, $location->attributes()); + static::assertSame($default, $location->toArray()); - $this->assertFalse($location->default); - $this->assertSame($default['city'].', '.$default['state_code'], $location->display_name); + static::assertFalse($location->default); + static::assertSame($default['city'].', '.$default['state_code'], $location->display_name); } }