From 7b4c8b57a3a2c96c6dbee89b4dc4dd148f0e2a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Beli=C3=ABn?= Date: Sun, 29 Nov 2020 11:46:00 +0100 Subject: [PATCH 1/8] Enable PHP 8.0 support --- .travis.yml | 5 +++++ composer.json | 2 +- src/Common/composer.json | 2 +- src/Http/composer.json | 2 +- src/Plugin/composer.json | 2 +- src/Provider/AlgoliaPlaces/composer.json | 2 +- src/Provider/ArcGISOnline/composer.json | 2 +- src/Provider/AzureMaps/composer.json | 2 +- src/Provider/BingMaps/composer.json | 2 +- src/Provider/Cache/composer.json | 2 +- src/Provider/Chain/composer.json | 2 +- src/Provider/FreeGeoIp/composer.json | 2 +- src/Provider/GeoIP2/composer.json | 2 +- src/Provider/GeoIPs/composer.json | 2 +- src/Provider/GeoPlugin/composer.json | 2 +- src/Provider/GeocodeEarth/composer.json | 2 +- src/Provider/Geoip/composer.json | 2 +- src/Provider/Geonames/composer.json | 2 +- src/Provider/GoogleMaps/composer.json | 2 +- src/Provider/GoogleMapsPlaces/composer.json | 2 +- src/Provider/GraphHopper/composer.json | 2 +- src/Provider/Here/composer.json | 2 +- src/Provider/HostIp/composer.json | 2 +- src/Provider/IP2Location/composer.json | 2 +- src/Provider/IP2LocationBinary/composer.json | 2 +- src/Provider/IpInfo/composer.json | 2 +- src/Provider/IpInfoDb/composer.json | 2 +- src/Provider/Ipstack/composer.json | 2 +- src/Provider/LocationIQ/composer.json | 2 +- src/Provider/MapQuest/composer.json | 2 +- src/Provider/Mapbox/composer.json | 2 +- src/Provider/Mapzen/composer.json | 2 +- src/Provider/MaxMind/composer.json | 2 +- src/Provider/MaxMindBinary/composer.json | 2 +- src/Provider/Nominatim/composer.json | 2 +- src/Provider/OpenCage/composer.json | 2 +- src/Provider/OpenRouteService/composer.json | 2 +- src/Provider/Pelias/composer.json | 2 +- src/Provider/Photon/composer.json | 2 +- src/Provider/PickPoint/composer.json | 2 +- src/Provider/TomTom/composer.json | 2 +- src/Provider/Yandex/composer.json | 2 +- 42 files changed, 46 insertions(+), 41 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4fd0bb4a9..b6490507f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,10 @@ cache: matrix: fast_finish: true include: + - php: 8.0 + env: deps="low" + - php: 8.0 + env: deps="high" - php: 7.4 env: deps="low" - php: 7.4 @@ -28,6 +32,7 @@ matrix: - php: 7.2 - php: 7.3 - php: 7.4 + - php: 8.0 before_install: - | diff --git a/composer.json b/composer.json index 2a3c559db..d1273df70 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "igorw/get-in": "^1.0", "php-http/client-implementation": "^1.0", "php-http/discovery": "^1.4", diff --git a/src/Common/composer.json b/src/Common/composer.json index 7e89162bd..d8e3cd9d8 100644 --- a/src/Common/composer.json +++ b/src/Common/composer.json @@ -17,7 +17,7 @@ } ], "require": { - "php": "^7.2" + "php": "^7.2 || ^8.0" }, "require-dev": { "nyholm/nsa": "^1.1", diff --git a/src/Http/composer.json b/src/Http/composer.json index fe358aa06..010ef4ede 100644 --- a/src/Http/composer.json +++ b/src/Http/composer.json @@ -14,7 +14,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "php-http/client-implementation": "^1.0", "php-http/discovery": "^1.6", "php-http/httplug": "^1.0 || ^2.0", diff --git a/src/Plugin/composer.json b/src/Plugin/composer.json index 71239ff22..4b6944eca 100644 --- a/src/Plugin/composer.json +++ b/src/Plugin/composer.json @@ -14,7 +14,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "php-http/promise": "^1.0", "psr/log": "^1.0", "psr/simple-cache": "^1.0", diff --git a/src/Provider/AlgoliaPlaces/composer.json b/src/Provider/AlgoliaPlaces/composer.json index 8e092fb2b..4143c2352 100644 --- a/src/Provider/AlgoliaPlaces/composer.json +++ b/src/Provider/AlgoliaPlaces/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "ext-json": "*", "geocoder-php/common-http": "^4.1", "willdurand/geocoder": "^4.0" diff --git a/src/Provider/ArcGISOnline/composer.json b/src/Provider/ArcGISOnline/composer.json index 3d65c36c7..790bcf14f 100644 --- a/src/Provider/ArcGISOnline/composer.json +++ b/src/Provider/ArcGISOnline/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/AzureMaps/composer.json b/src/Provider/AzureMaps/composer.json index 5293c9bad..da476e190 100644 --- a/src/Provider/AzureMaps/composer.json +++ b/src/Provider/AzureMaps/composer.json @@ -11,7 +11,7 @@ ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/BingMaps/composer.json b/src/Provider/BingMaps/composer.json index b736a57bb..0c37d3aa5 100644 --- a/src/Provider/BingMaps/composer.json +++ b/src/Provider/BingMaps/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Cache/composer.json b/src/Provider/Cache/composer.json index abcd0cfd9..6240a9cf8 100644 --- a/src/Provider/Cache/composer.json +++ b/src/Provider/Cache/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "psr/simple-cache": "^1.0", "willdurand/geocoder": "^4.0.0" }, diff --git a/src/Provider/Chain/composer.json b/src/Provider/Chain/composer.json index f9d218293..d76c7d97d 100644 --- a/src/Provider/Chain/composer.json +++ b/src/Provider/Chain/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "psr/log": "^1.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/FreeGeoIp/composer.json b/src/Provider/FreeGeoIp/composer.json index 1a38f0e0b..4984f79b3 100644 --- a/src/Provider/FreeGeoIp/composer.json +++ b/src/Provider/FreeGeoIp/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.1", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/GeoIP2/composer.json b/src/Provider/GeoIP2/composer.json index 1080a5e50..7eca795ba 100644 --- a/src/Provider/GeoIP2/composer.json +++ b/src/Provider/GeoIP2/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geoip2/geoip2": "~2.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/GeoIPs/composer.json b/src/Provider/GeoIPs/composer.json index e6584bdc8..3b10ca7fd 100644 --- a/src/Provider/GeoIPs/composer.json +++ b/src/Provider/GeoIPs/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.1" }, diff --git a/src/Provider/GeoPlugin/composer.json b/src/Provider/GeoPlugin/composer.json index 0b1914c93..f77136362 100644 --- a/src/Provider/GeoPlugin/composer.json +++ b/src/Provider/GeoPlugin/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "igorw/get-in": "^1.0", "willdurand/geocoder": "^4.0" diff --git a/src/Provider/GeocodeEarth/composer.json b/src/Provider/GeocodeEarth/composer.json index b21224829..dac15856f 100644 --- a/src/Provider/GeocodeEarth/composer.json +++ b/src/Provider/GeocodeEarth/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "geocoder-php/pelias-provider": "^1.0", "willdurand/geocoder": "^4.0" diff --git a/src/Provider/Geoip/composer.json b/src/Provider/Geoip/composer.json index f60f1ab76..3269ffd9a 100644 --- a/src/Provider/Geoip/composer.json +++ b/src/Provider/Geoip/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "ext-geoip": "*", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Geonames/composer.json b/src/Provider/Geonames/composer.json index 3a91c7a2c..b64c58f8e 100644 --- a/src/Provider/Geonames/composer.json +++ b/src/Provider/Geonames/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/GoogleMaps/composer.json b/src/Provider/GoogleMaps/composer.json index 3948b9afc..e0b98683e 100644 --- a/src/Provider/GoogleMaps/composer.json +++ b/src/Provider/GoogleMaps/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/GoogleMapsPlaces/composer.json b/src/Provider/GoogleMapsPlaces/composer.json index b022eb7c4..ed4aabffd 100644 --- a/src/Provider/GoogleMapsPlaces/composer.json +++ b/src/Provider/GoogleMapsPlaces/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/GraphHopper/composer.json b/src/Provider/GraphHopper/composer.json index 4ab68da88..5850829de 100644 --- a/src/Provider/GraphHopper/composer.json +++ b/src/Provider/GraphHopper/composer.json @@ -6,7 +6,7 @@ "homepage": "http://geocoder-php.org/Geocoder/", "license": "MIT", "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Here/composer.json b/src/Provider/Here/composer.json index dca98d45d..a722cd1f5 100644 --- a/src/Provider/Here/composer.json +++ b/src/Provider/Here/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/HostIp/composer.json b/src/Provider/HostIp/composer.json index 778b598d8..f9b1c3d2b 100644 --- a/src/Provider/HostIp/composer.json +++ b/src/Provider/HostIp/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/IP2Location/composer.json b/src/Provider/IP2Location/composer.json index 7ffdea9cd..256225139 100644 --- a/src/Provider/IP2Location/composer.json +++ b/src/Provider/IP2Location/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/IP2LocationBinary/composer.json b/src/Provider/IP2LocationBinary/composer.json index 5ffd12ad8..cdb0605a5 100644 --- a/src/Provider/IP2LocationBinary/composer.json +++ b/src/Provider/IP2LocationBinary/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "ip2location/ip2location-php": "^8.1.1", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/IpInfo/composer.json b/src/Provider/IpInfo/composer.json index fd78d6d04..a680c8b33 100644 --- a/src/Provider/IpInfo/composer.json +++ b/src/Provider/IpInfo/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/IpInfoDb/composer.json b/src/Provider/IpInfoDb/composer.json index a00a99c66..84c1ef694 100644 --- a/src/Provider/IpInfoDb/composer.json +++ b/src/Provider/IpInfoDb/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Ipstack/composer.json b/src/Provider/Ipstack/composer.json index f5bc4d4ef..c7905b35e 100644 --- a/src/Provider/Ipstack/composer.json +++ b/src/Provider/Ipstack/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/LocationIQ/composer.json b/src/Provider/LocationIQ/composer.json index f9542c992..cffa315ad 100644 --- a/src/Provider/LocationIQ/composer.json +++ b/src/Provider/LocationIQ/composer.json @@ -17,7 +17,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/MapQuest/composer.json b/src/Provider/MapQuest/composer.json index 0f8cffebc..f19bea229 100644 --- a/src/Provider/MapQuest/composer.json +++ b/src/Provider/MapQuest/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Mapbox/composer.json b/src/Provider/Mapbox/composer.json index 14cd38ac3..27f998496 100644 --- a/src/Provider/Mapbox/composer.json +++ b/src/Provider/Mapbox/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Mapzen/composer.json b/src/Provider/Mapzen/composer.json index c3d067368..78ec511ed 100644 --- a/src/Provider/Mapzen/composer.json +++ b/src/Provider/Mapzen/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/MaxMind/composer.json b/src/Provider/MaxMind/composer.json index 6c4673724..491656290 100644 --- a/src/Provider/MaxMind/composer.json +++ b/src/Provider/MaxMind/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "igorw/get-in": "^1.0", "willdurand/geocoder": "^4.1" }, diff --git a/src/Provider/MaxMindBinary/composer.json b/src/Provider/MaxMindBinary/composer.json index 5ff7b9d15..ae0b027cc 100644 --- a/src/Provider/MaxMindBinary/composer.json +++ b/src/Provider/MaxMindBinary/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geoip/geoip": "^1.17", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Nominatim/composer.json b/src/Provider/Nominatim/composer.json index d3c50988b..d2df8d5bc 100644 --- a/src/Provider/Nominatim/composer.json +++ b/src/Provider/Nominatim/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.1", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/OpenCage/composer.json b/src/Provider/OpenCage/composer.json index 9202d7005..9e5eefb70 100644 --- a/src/Provider/OpenCage/composer.json +++ b/src/Provider/OpenCage/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/OpenRouteService/composer.json b/src/Provider/OpenRouteService/composer.json index 6a02865e0..5f193064f 100644 --- a/src/Provider/OpenRouteService/composer.json +++ b/src/Provider/OpenRouteService/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "geocoder-php/pelias-provider": "^1.0", "willdurand/geocoder": "^4.0" diff --git a/src/Provider/Pelias/composer.json b/src/Provider/Pelias/composer.json index 50b40cfc5..7b2ee693a 100644 --- a/src/Provider/Pelias/composer.json +++ b/src/Provider/Pelias/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Photon/composer.json b/src/Provider/Photon/composer.json index 799fdb19e..75bcd0ec6 100644 --- a/src/Provider/Photon/composer.json +++ b/src/Provider/Photon/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.1", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/PickPoint/composer.json b/src/Provider/PickPoint/composer.json index 8a2b6ac64..e981f1872 100644 --- a/src/Provider/PickPoint/composer.json +++ b/src/Provider/PickPoint/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/TomTom/composer.json b/src/Provider/TomTom/composer.json index 4a0fe36c8..ecf27af43 100644 --- a/src/Provider/TomTom/composer.json +++ b/src/Provider/TomTom/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Yandex/composer.json b/src/Provider/Yandex/composer.json index 3550bd58c..038a5db00 100644 --- a/src/Provider/Yandex/composer.json +++ b/src/Provider/Yandex/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, From 4ba10b3395c1b2d5b1eab28c2d431a3989d4be65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Beli=C3=ABn?= Date: Tue, 15 Dec 2020 22:02:52 +0100 Subject: [PATCH 2/8] Add GitHub Actions --- .github/workflows/php.yml | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/php.yml diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 000000000..02f3da094 --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,50 @@ +name: PHP Composer + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php-version: ['7.4', '8.0'] + deps: ['low', 'high'] + include: + - php-version: '7.2' + deps: null + - php-version: '7.3' + deps: null + + name: PHP ${{ matrix.php-version }} (${{ matrix.deps }}) + + steps: + - uses: actions/checkout@v2 + + - name: Use PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: curl + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Install dependencies + if: ${{ matrix.deps == null }} + run: composer update --no-progress --prefer-dist + - name: Install dependencies (low) + if: ${{ matrix.deps == 'low' }} + run: composer update --no-progress --prefer-lowest --prefer-stable + - name: Install dependencies (high) + if: ${{ matrix.deps == 'high' }} + run: composer update --no-progress + + - name: Run test suite + run: composer run-script test From fdd15e680c43d959f3f6a79f7fb89212e633b30f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Beli=C3=ABn?= Date: Tue, 15 Dec 2020 22:06:22 +0100 Subject: [PATCH 3/8] Upgrade php-http/curl-client + php-http/httplug --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index d1273df70..457706bda 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "igorw/get-in": "^1.0", "php-http/client-implementation": "^1.0", "php-http/discovery": "^1.4", - "php-http/httplug": "^1.0", + "php-http/httplug": "^2.2", "php-http/message-factory": "^1.0.2", "php-http/promise": "^1.0", "psr/http-message-implementation": "^1.0", @@ -36,7 +36,7 @@ "geoip2/geoip2": "~2.0", "nyholm/nsa": "^1.1", "nyholm/psr7": "^1.0", - "php-http/curl-client": "^1.7", + "php-http/curl-client": "^2.2", "php-http/message": "^1.0", "php-http/mock-client": "^1.0", "phpunit/phpunit": "^7.5", From 815df46db044ed028c490e532ca5441a191fbcf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Beli=C3=ABn?= Date: Fri, 18 Dec 2020 20:25:15 +0100 Subject: [PATCH 4/8] Upgrade PHPUnit --- .gitignore | 1 + composer.json | 2 +- phpunit.xml.dist | 123 +++++++-------- src/Common/Tests/Dumper/GeoArrayTest.php | 10 +- src/Common/Tests/Dumper/GeoJsonTest.php | 2 +- src/Common/Tests/Dumper/GpxTest.php | 2 +- src/Common/Tests/Dumper/KmlTest.php | 2 +- src/Common/Tests/Dumper/WkbTest.php | 2 +- src/Common/Tests/Dumper/WktTest.php | 2 +- .../Tests/Formatter/StringFormatterTest.php | 2 +- .../Tests/Model/AddressCollectionTest.php | 2 + src/Common/Tests/ProviderAggregatorTest.php | 19 +-- src/Common/Tests/Query/GeocodeQueryTest.php | 10 +- src/Common/Tests/Query/ReverseQueryTest.php | 12 +- src/Common/Tests/TimedGeocoderTest.php | 2 +- .../AlgoliaPlaces/Tests/AlgoliaPlacesTest.php | 34 ++-- .../AlgoliaPlaces/Tests/IntegrationTest.php | 8 +- .../ArcGISOnline/Tests/ArcGISOnlineTest.php | 67 ++++---- .../AzureMaps/Tests/AzureMapsTest.php | 24 +-- src/Provider/BingMaps/Tests/BingMapsTest.php | 105 ++++++------- .../Cache/Tests/ProviderCacheTest.php | 2 +- .../FreeGeoIp/Tests/FreeGeoIpTest.php | 19 +-- .../GeoIP2/Tests/GeoIP2AdapterTest.php | 25 ++- src/Provider/GeoIP2/Tests/GeoIP2Test.php | 16 +- src/Provider/GeoIPs/Tests/GeoIPsTest.php | 66 ++++---- .../GeoPlugin/Tests/GeoPluginTest.php | 14 +- .../GeocodeEarth/Tests/GeocodeEarthTest.php | 74 ++++----- src/Provider/Geoip/Tests/GeoipTest.php | 2 +- src/Provider/Geoip/Tests/IntegrationTest.php | 2 +- .../Geonames/Tests/CountryInfoTest.php | 4 +- src/Provider/Geonames/Tests/GeonamesTest.php | 146 +++++++++--------- .../GoogleMaps/Tests/GoogleMapsTest.php | 84 +++++----- .../GraphHopper/Tests/GraphHopperTest.php | 40 +++-- src/Provider/Here/Tests/HereTest.php | 83 +++++----- src/Provider/Here/Tests/IntegrationTest.php | 16 +- src/Provider/HostIp/Tests/HostIpTest.php | 28 ++-- src/Provider/HostIp/Tests/HostIpXmlTest.php | 28 ++-- .../IP2Location/Tests/IP2LocationTest.php | 43 +++--- .../Tests/IP2LocationBinaryTest.php | 4 +- .../Tests/IntegrationTest.php | 2 +- src/Provider/IpInfo/Tests/IpInfoTest.php | 26 ++-- src/Provider/IpInfoDb/Tests/IpInfoDbTest.php | 52 +++---- src/Provider/Ipstack/Tests/IpstackTest.php | 49 +++--- .../LocationIQ/Tests/LocationIQTest.php | 4 + src/Provider/MapQuest/Tests/MapQuestTest.php | 108 +++++++------ src/Provider/Mapbox/Tests/MapboxTest.php | 35 ++--- src/Provider/Mapzen/Tests/MapzenTest.php | 66 ++++---- src/Provider/MaxMind/Tests/MaxMindTest.php | 68 ++++---- .../MaxMindBinary/Tests/IntegrationTest.php | 2 +- .../MaxMindBinary/Tests/MaxMindBinaryTest.php | 4 +- .../Nominatim/Tests/NominatimTest.php | 29 ++-- src/Provider/OpenCage/Tests/OpenCageTest.php | 74 ++++----- .../Tests/OpenRouteServiceTest.php | 70 ++++----- src/Provider/Photon/Tests/PhotonTest.php | 21 ++- .../PickPoint/Tests/PickPointTest.php | 10 +- src/Provider/TomTom/Tests/TomTomTest.php | 57 +++---- src/Provider/Yandex/Tests/YandexTest.php | 142 +++++++++-------- 57 files changed, 901 insertions(+), 1045 deletions(-) diff --git a/.gitignore b/.gitignore index 5d5fa0e4a..591912922 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ vendor/ composer.lock composer.phar phpunit.xml +.phpunit.result.cache php-cs-fixer.phar .puli/ diff --git a/composer.json b/composer.json index 457706bda..20d6ecdad 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "php-http/curl-client": "^2.2", "php-http/message": "^1.0", "php-http/mock-client": "^1.0", - "phpunit/phpunit": "^7.5", + "phpunit/phpunit": "^9.5", "symfony/stopwatch": "~2.5" }, "suggest": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index aa1ac0812..55794f4ba 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,68 +1,65 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ./tests/ - ./src/Common/Tests/ - ./src/Http/Tests/ - ./src/Provider/*/Tests/ - - - - - - ./src/ - - ./src/Common/Tests - ./src/Http/Tests - ./src/Provider/*/Tests - ./src/Common/vendor - ./src/Http/vendor - ./src/Provider/*/vendor - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ./src/Common/Tests/ + ./src/Http/Tests/ + ./src/Provider/*/Tests/ + + diff --git a/src/Common/Tests/Dumper/GeoArrayTest.php b/src/Common/Tests/Dumper/GeoArrayTest.php index 252955cc1..800d239dc 100644 --- a/src/Common/Tests/Dumper/GeoArrayTest.php +++ b/src/Common/Tests/Dumper/GeoArrayTest.php @@ -26,7 +26,7 @@ class GeoArrayTest extends TestCase */ private $dumper; - protected function setUp() + protected function setUp(): void { $this->dumper = new GeoArray(); } @@ -47,7 +47,7 @@ public function testDump() $result = $this->dumper->dump($address); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertEquals($expected, $result); } @@ -71,7 +71,7 @@ public function testDumpWithData() $result = $this->dumper->dump($address); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertEquals($expected, $result); } @@ -107,7 +107,7 @@ public function testDumpWithBounds() $result = $this->dumper->dump($address); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertEquals($expected, $result); } @@ -147,7 +147,7 @@ public function testDumpWithProperties() $result = $this->dumper->dump($address); - $this->assertInternalType('array', $result); + $this->assertIsArray($result); $this->assertEquals($expected, $result); } } diff --git a/src/Common/Tests/Dumper/GeoJsonTest.php b/src/Common/Tests/Dumper/GeoJsonTest.php index 9e745a8e5..eee43a08f 100644 --- a/src/Common/Tests/Dumper/GeoJsonTest.php +++ b/src/Common/Tests/Dumper/GeoJsonTest.php @@ -27,7 +27,7 @@ class GeoJsonTest extends TestCase */ private $dumper; - public function setUp() + public function setUp(): void { $this->dumper = new GeoJson(); } diff --git a/src/Common/Tests/Dumper/GpxTest.php b/src/Common/Tests/Dumper/GpxTest.php index f72c70c0b..297cdaf1c 100644 --- a/src/Common/Tests/Dumper/GpxTest.php +++ b/src/Common/Tests/Dumper/GpxTest.php @@ -27,7 +27,7 @@ class GpxTest extends TestCase */ private $dumper; - public function setUp() + public function setUp(): void { $this->dumper = new Gpx(); } diff --git a/src/Common/Tests/Dumper/KmlTest.php b/src/Common/Tests/Dumper/KmlTest.php index 2870acff4..7d1331c05 100644 --- a/src/Common/Tests/Dumper/KmlTest.php +++ b/src/Common/Tests/Dumper/KmlTest.php @@ -27,7 +27,7 @@ class KmlTest extends TestCase */ private $dumper; - public function setUp() + public function setUp(): void { $this->dumper = new Kml(); } diff --git a/src/Common/Tests/Dumper/WkbTest.php b/src/Common/Tests/Dumper/WkbTest.php index 325fa4bb7..4808632f7 100644 --- a/src/Common/Tests/Dumper/WkbTest.php +++ b/src/Common/Tests/Dumper/WkbTest.php @@ -27,7 +27,7 @@ class WkbTest extends TestCase */ private $dumper; - public function setUp() + public function setUp(): void { $this->dumper = new Wkb(); } diff --git a/src/Common/Tests/Dumper/WktTest.php b/src/Common/Tests/Dumper/WktTest.php index 6a44ac01b..8a135c5b7 100644 --- a/src/Common/Tests/Dumper/WktTest.php +++ b/src/Common/Tests/Dumper/WktTest.php @@ -27,7 +27,7 @@ class WktTest extends TestCase */ private $dumper; - public function setUp() + public function setUp(): void { $this->dumper = new Wkt(); } diff --git a/src/Common/Tests/Formatter/StringFormatterTest.php b/src/Common/Tests/Formatter/StringFormatterTest.php index 9e83bffef..89b9c3da6 100644 --- a/src/Common/Tests/Formatter/StringFormatterTest.php +++ b/src/Common/Tests/Formatter/StringFormatterTest.php @@ -26,7 +26,7 @@ class StringFormatterTest extends TestCase */ private $formatter; - public function setUp() + public function setUp(): void { $this->formatter = new StringFormatter(); } diff --git a/src/Common/Tests/Model/AddressCollectionTest.php b/src/Common/Tests/Model/AddressCollectionTest.php index 842d4e3a0..6981119f0 100644 --- a/src/Common/Tests/Model/AddressCollectionTest.php +++ b/src/Common/Tests/Model/AddressCollectionTest.php @@ -25,6 +25,8 @@ class AddressCollectionTest extends TestCase */ public function testFirstOnEmpty() { + $this->expectException(\Geocoder\Exception\CollectionIsEmpty::class); + $collection = new AddressCollection([]); $collection->first(); } diff --git a/src/Common/Tests/ProviderAggregatorTest.php b/src/Common/Tests/ProviderAggregatorTest.php index 382fee9cc..ebea95c45 100644 --- a/src/Common/Tests/ProviderAggregatorTest.php +++ b/src/Common/Tests/ProviderAggregatorTest.php @@ -32,7 +32,7 @@ class ProviderAggregatorTest extends TestCase */ protected $geocoder; - protected function setUp() + protected function setUp(): void { $this->geocoder = new ProviderAggregator(); } @@ -82,22 +82,20 @@ public function testRegisterProviders() $this->assertSame(['test' => $provider], NSA::getProperty($this->geocoder, 'providers')); } - /** - * @expectedException \Geocoder\Exception\ProviderNotRegistered - * @expectedExceptionMessage Provider "non_existant" is not registered, so you cannot use it. Did you forget to register it or made a typo? Registered providers are: test1. - */ public function testUsingNonExistantProviderShouldThrowAnException() { + $this->expectException(\Geocoder\Exception\ProviderNotRegistered::class); + $this->expectExceptionMessage('Provider "non_existant" is not registered, so you cannot use it. Did you forget to register it or made a typo? Registered providers are: test1.'); + $this->geocoder->registerProvider(new MockProvider('test1')); $this->geocoder->using('non_existant'); } - /** - * @expectedException \Geocoder\Exception\ProviderNotRegistered - */ public function testUsingAnEmptyProviderNameShouldThrowAnException() { + $this->expectException(\Geocoder\Exception\ProviderNotRegistered::class); + $this->geocoder->using(''); } @@ -119,11 +117,10 @@ public function testGetProviders() $this->assertArrayHasKey('test2', $result); } - /** - * @expectedException \RuntimeException - */ public function testGetProvider() { + $this->expectException(\RuntimeException::class); + NSA::invokeMethod($this->geocoder, 'getProvider', GeocodeQuery::create('foo'), [], null); $this->fail('getProvider() should throw an exception'); } diff --git a/src/Common/Tests/Query/GeocodeQueryTest.php b/src/Common/Tests/Query/GeocodeQueryTest.php index 60e4fa2cc..c14f3481a 100644 --- a/src/Common/Tests/Query/GeocodeQueryTest.php +++ b/src/Common/Tests/Query/GeocodeQueryTest.php @@ -26,10 +26,10 @@ public function testToString() $query = $query->withData('name', 'value'); $string = $query->__toString(); - $this->assertContains('GeocodeQuery', $string); - $this->assertContains('"text":"foo"', $string); - $this->assertContains('"locale":"en"', $string); - $this->assertContains('"limit":3', $string); - $this->assertContains('"name":"value"', $string); + $this->assertStringContainsString('GeocodeQuery', $string); + $this->assertStringContainsString('"text":"foo"', $string); + $this->assertStringContainsString('"locale":"en"', $string); + $this->assertStringContainsString('"limit":3', $string); + $this->assertStringContainsString('"name":"value"', $string); } } diff --git a/src/Common/Tests/Query/ReverseQueryTest.php b/src/Common/Tests/Query/ReverseQueryTest.php index 402725884..9bb815e0c 100644 --- a/src/Common/Tests/Query/ReverseQueryTest.php +++ b/src/Common/Tests/Query/ReverseQueryTest.php @@ -26,11 +26,11 @@ public function testToString() $query = $query->withData('name', 'value'); $string = $query->__toString(); - $this->assertContains('ReverseQuery', $string); - $this->assertContains('"lat":1', $string); - $this->assertContains('"lng":2', $string); - $this->assertContains('"locale":"en"', $string); - $this->assertContains('"limit":3', $string); - $this->assertContains('"name":"value"', $string); + $this->assertStringContainsString('ReverseQuery', $string); + $this->assertStringContainsString('"lat":1', $string); + $this->assertStringContainsString('"lng":2', $string); + $this->assertStringContainsString('"locale":"en"', $string); + $this->assertStringContainsString('"limit":3', $string); + $this->assertStringContainsString('"name":"value"', $string); } } diff --git a/src/Common/Tests/TimedGeocoderTest.php b/src/Common/Tests/TimedGeocoderTest.php index 438a0f973..c46a82fba 100644 --- a/src/Common/Tests/TimedGeocoderTest.php +++ b/src/Common/Tests/TimedGeocoderTest.php @@ -35,7 +35,7 @@ class TimedGeocoderTest extends TestCase */ private $geocoder; - protected function setUp() + protected function setUp(): void { $this->stopwatch = new Stopwatch(); $this->delegate = $this->getMockBuilder(Provider::class)->getMock(); diff --git a/src/Provider/AlgoliaPlaces/Tests/AlgoliaPlacesTest.php b/src/Provider/AlgoliaPlaces/Tests/AlgoliaPlacesTest.php index e8b317220..6041a245b 100644 --- a/src/Provider/AlgoliaPlaces/Tests/AlgoliaPlacesTest.php +++ b/src/Provider/AlgoliaPlaces/Tests/AlgoliaPlacesTest.php @@ -58,8 +58,8 @@ public function testGeocodeQueryWithLocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.8653, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.39844, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.8653, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.39844, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('10 Avenue Gambetta', $result->getStreetName()); $this->assertEquals(75020, $result->getPostalCode()); @@ -83,8 +83,8 @@ public function testGeocodeQueryWithoutLocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.8546, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.34771, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.8546, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.34771, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNull($result->getStreetName()); $this->assertSame('75000', $result->getPostalCode()); @@ -108,21 +108,19 @@ public function testGetName() $this->assertEquals('algolia_places', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\InvalidServerResponse - */ public function testGeocodeWithInvalidData() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $provider = new AlgoliaPlaces($this->getMockedHttpClient(), 'appId', 'appCode'); $provider->geocodeQuery(GeocodeQuery::create('foobar')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The AlgoliaPlaces provider does not support IP addresses, only street addresses. - */ public function testGeocodeIpv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The AlgoliaPlaces provider does not support IP addresses, only street addresses.'); + if (!isset($_SERVER['ALGOLIA_APP_ID']) || !isset($_SERVER['ALGOLIA_API_KEY'])) { $this->markTestSkipped('You need to configure the ALGOLIA_APP_ID and ALGOLIA_API_KEY value in phpunit.xml'); } @@ -131,22 +129,20 @@ public function testGeocodeIpv4() $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The AlgoliaPlaces provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The AlgoliaPlaces provider does not support IP addresses, only street addresses.'); + $provider = new AlgoliaPlaces($this->getMockedHttpClient(), 'appId', 'appCode'); $provider->geocodeQuery(GeocodeQuery::create('::1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The AlgoliaPlaces provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The AlgoliaPlaces provider does not support IP addresses, only street addresses.'); + if (!isset($_SERVER['ALGOLIA_APP_ID']) || !isset($_SERVER['ALGOLIA_API_KEY'])) { $this->markTestSkipped('You need to configure the ALGOLIA_APP_ID and ALGOLIA_API_KEY value in phpunit.xml'); } diff --git a/src/Provider/AlgoliaPlaces/Tests/IntegrationTest.php b/src/Provider/AlgoliaPlaces/Tests/IntegrationTest.php index 53e3643e8..9f394723d 100644 --- a/src/Provider/AlgoliaPlaces/Tests/IntegrationTest.php +++ b/src/Provider/AlgoliaPlaces/Tests/IntegrationTest.php @@ -92,12 +92,12 @@ public function testGeocodeQuery() // Check Downing Street $location = $result->first(); - $this->assertEquals(51.5033, $location->getCoordinates()->getLatitude(), 'Latitude should be in London', 0.1); - $this->assertEquals(-0.1276, $location->getCoordinates()->getLongitude(), 'Longitude should be in London', 0.1); - $this->assertContains('Downing', $location->getStreetName(), 'Street name should contain "Downing St"'); + $this->assertEqualsWithDelta(51.5033, $location->getCoordinates()->getLatitude(), 0.1, 'Latitude should be in London'); + $this->assertEqualsWithDelta(-0.1276, $location->getCoordinates()->getLongitude(), 0.1, 'Longitude should be in London'); + $this->assertStringContainsString('Downing', $location->getStreetName(), 'Street name should contain "Downing St"'); if (null !== $streetNumber = $location->getStreetNumber()) { - $this->assertContains('10', $streetNumber, 'Street number should contain "10"'); + $this->assertStringContainsString('10', $streetNumber, 'Street number should contain "10"'); } } diff --git a/src/Provider/ArcGISOnline/Tests/ArcGISOnlineTest.php b/src/Provider/ArcGISOnline/Tests/ArcGISOnlineTest.php index c5fd7057c..62f85cda7 100644 --- a/src/Provider/ArcGISOnline/Tests/ArcGISOnlineTest.php +++ b/src/Provider/ArcGISOnline/Tests/ArcGISOnlineTest.php @@ -32,22 +32,20 @@ public function testGetName() $this->assertEquals('arcgis_online', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The ArcGISOnline provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The ArcGISOnline provider does not support IP addresses, only street addresses.'); + $provider = new ArcGISOnline($this->getMockedHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The ArcGISOnline provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The ArcGISOnline provider does not support IP addresses, only street addresses.'); + $provider = new ArcGISOnline($this->getMockedHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('::1')); } @@ -63,8 +61,8 @@ public function testGeocodeWithRealAddress() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.863279997000461, $result->getCoordinates()->getLatitude(), '', 0.0001); - $this->assertEquals(2.3890199980004354, $result->getCoordinates()->getLongitude(), '', 0.0001); + $this->assertEqualsWithDelta(48.863279997000461, $result->getCoordinates()->getLatitude(), 0.0001); + $this->assertEqualsWithDelta(2.3890199980004354, $result->getCoordinates()->getLongitude(), 0.0001); $this->assertEquals(10, $result->getStreetNumber()); $this->assertEquals('10 Avenue Gambetta', $result->getStreetName()); $this->assertEquals(75020, $result->getPostalCode()); @@ -95,8 +93,8 @@ public function testGeocodeWithToken() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(43.093663, $result->getCoordinates()->getLatitude(), '', 0.0001); - $this->assertEquals(-90.131796, $result->getCoordinates()->getLongitude(), '', 0.0001); + $this->assertEqualsWithDelta(43.093663, $result->getCoordinates()->getLatitude(), 0.0001); + $this->assertEqualsWithDelta(-90.131796, $result->getCoordinates()->getLongitude(), 0.0001); $this->assertEquals(5754, $result->getStreetNumber()); $this->assertEquals('5754 WI-23', $result->getStreetName()); $this->assertEquals(53588, $result->getPostalCode()); @@ -134,8 +132,8 @@ public function testReverseWithRealCoordinates() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.863279997000461, $result->getCoordinates()->getLatitude(), '', 0.0001); - $this->assertEquals(2.3890199980004354, $result->getCoordinates()->getLongitude(), '', 0.0001); + $this->assertEqualsWithDelta(48.863279997000461, $result->getCoordinates()->getLatitude(), 0.0001); + $this->assertEqualsWithDelta(2.3890199980004354, $result->getCoordinates()->getLongitude(), 0.0001); $this->assertNull($result->getStreetNumber()); $this->assertEquals('5 Avenue Gambetta', $result->getStreetName()); $this->assertEquals(75020, $result->getPostalCode()); @@ -160,8 +158,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.37227000000007, $result->getCoordinates()->getLatitude(), '', 0.0001); - $this->assertEquals(9.738150000000076, $result->getCoordinates()->getLongitude(), '', 0.0001); + $this->assertEqualsWithDelta(52.37227000000007, $result->getCoordinates()->getLatitude(), 0.0001); + $this->assertEqualsWithDelta(9.738150000000076, $result->getCoordinates()->getLongitude(), 0.0001); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); $this->assertNull($result->getPostalCode()); @@ -178,8 +176,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(39.391768472000479, $result->getCoordinates()->getLatitude(), '', 0.0001); - $this->assertEquals(-77.440257128999633, $result->getCoordinates()->getLongitude(), '', 0.0001); + $this->assertEqualsWithDelta(39.391768472000479, $result->getCoordinates()->getLatitude(), 0.0001); + $this->assertEqualsWithDelta(-77.440257128999633, $result->getCoordinates()->getLongitude(), 0.0001); $this->assertNull($result->getStreetName()); $this->assertEquals('Hannover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); @@ -189,8 +187,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(53.174198173, $result->getCoordinates()->getLatitude(), '', 0.0001); - $this->assertEquals(8.5069383810005, $result->getCoordinates()->getLongitude(), '', 0.0001); + $this->assertEqualsWithDelta(53.174198173, $result->getCoordinates()->getLatitude(), 0.0001); + $this->assertEqualsWithDelta(8.5069383810005, $result->getCoordinates()->getLongitude(), 0.0001); $this->assertNull($result->getStreetName()); $this->assertEquals('Hannöver', $result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); @@ -200,8 +198,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(47.111290000000054, $result->getCoordinates()->getLatitude(), '', 0.0001); - $this->assertEquals(-101.42142999999999, $result->getCoordinates()->getLongitude(), '', 0.0001); + $this->assertEqualsWithDelta(47.111290000000054, $result->getCoordinates()->getLatitude(), 0.0001); + $this->assertEqualsWithDelta(-101.42142999999999, $result->getCoordinates()->getLongitude(), 0.0001); $this->assertNull($result->getStreetName()); $this->assertEquals('Hannover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); @@ -211,8 +209,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(32.518790000000024, $result->getCoordinates()->getLatitude(), '', 0.0001); - $this->assertEquals(-90.06298999999996, $result->getCoordinates()->getLongitude(), '', 0.0001); + $this->assertEqualsWithDelta(32.518790000000024, $result->getCoordinates()->getLatitude(), 0.0001); + $this->assertEqualsWithDelta(-90.06298999999996, $result->getCoordinates()->getLongitude(), 0.0001); $this->assertNull($result->getStreetName()); $this->assertNull($result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); @@ -221,32 +219,29 @@ public function testGeocodeWithCity() $this->assertEquals('USA', $result->getCountry()->getCode()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The ArcGISOnline provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The ArcGISOnline provider does not support IP addresses, only street addresses.'); + $provider = new ArcGISOnline($this->getHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('88.188.221.14')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The ArcGISOnline provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The ArcGISOnline provider does not support IP addresses, only street addresses.'); + $provider = new ArcGISOnline($this->getHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('::ffff:88.188.221.14')); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage Invalid token invalid-token - */ public function testGeocodeWithInvalidToken() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('Invalid token invalid-token'); + $provider = ArcGISOnline::token($this->getHttpClient(), 'invalid-token'); $results = $provider->geocodeQuery(GeocodeQuery::create('1313 Disneyland Dr, Anaheim, CA 92802, USA')); } diff --git a/src/Provider/AzureMaps/Tests/AzureMapsTest.php b/src/Provider/AzureMaps/Tests/AzureMapsTest.php index 599b1f1ff..7ca529acc 100644 --- a/src/Provider/AzureMaps/Tests/AzureMapsTest.php +++ b/src/Provider/AzureMaps/Tests/AzureMapsTest.php @@ -50,13 +50,13 @@ public function testGeocodeWithRealAddress() $result = $results->first(); $this->assertInstanceOf(Address::class, $result); - $this->assertEquals(32.09388, $result->getCoordinates()->getLatitude(), '', 0.001); - $this->assertEquals(34.78596, $result->getCoordinates()->getLongitude(), '', 0.001); + $this->assertEqualsWithDelta(32.09388, $result->getCoordinates()->getLatitude(), 0.001); + $this->assertEqualsWithDelta(34.78596, $result->getCoordinates()->getLongitude(), 0.001); $this->assertNotNull($result->getBounds()); - $this->assertEquals(32.09298, $result->getBounds()->getSouth(), '', 0.001); - $this->assertEquals(34.7849, $result->getBounds()->getWest(), '', 0.001); - $this->assertEquals(32.09478, $result->getBounds()->getNorth(), '', 0.001); - $this->assertEquals(34.78702, $result->getBounds()->getEast(), '', 0.001); + $this->assertEqualsWithDelta(32.09298, $result->getBounds()->getSouth(), 0.001); + $this->assertEqualsWithDelta(34.7849, $result->getBounds()->getWest(), 0.001); + $this->assertEqualsWithDelta(32.09478, $result->getBounds()->getNorth(), 0.001); + $this->assertEqualsWithDelta(34.78702, $result->getBounds()->getEast(), 0.001); $this->assertEquals(15, $result->getStreetNumber()); $this->assertEquals('Yehuda Hamaccabi Street', $result->getStreetName()); $this->assertEquals(6266924, $result->getPostalCode()); @@ -80,13 +80,13 @@ public function testReverseWithRealCoordinates() $result = $results->first(); $this->assertInstanceOf(Address::class, $result); - $this->assertEquals(32.09388, $result->getCoordinates()->getLatitude(), '', 0.001); - $this->assertEquals(34.78596, $result->getCoordinates()->getLongitude(), '', 0.001); + $this->assertEqualsWithDelta(32.09388, $result->getCoordinates()->getLatitude(), 0.001); + $this->assertEqualsWithDelta(34.78596, $result->getCoordinates()->getLongitude(), 0.001); $this->assertNotNull($result->getBounds()); - $this->assertEquals(32.09298, $result->getBounds()->getSouth(), '', 0.001); - $this->assertEquals(34.7849, $result->getBounds()->getWest(), '', 0.001); - $this->assertEquals(32.093772, $result->getBounds()->getNorth(), '', 0.001); - $this->assertEquals(34.78702, $result->getBounds()->getEast(), '', 0.001); + $this->assertEqualsWithDelta(32.09298, $result->getBounds()->getSouth(), 0.001); + $this->assertEqualsWithDelta(34.7849, $result->getBounds()->getWest(), 0.001); + $this->assertEqualsWithDelta(32.093772, $result->getBounds()->getNorth(), 0.001); + $this->assertEqualsWithDelta(34.78702, $result->getBounds()->getEast(), 0.001); $this->assertEquals(15, $result->getStreetNumber()); $this->assertEquals('Yehuda Hamaccabi Street', $result->getStreetName()); $this->assertEquals(6266924, $result->getPostalCode()); diff --git a/src/Provider/BingMaps/Tests/BingMapsTest.php b/src/Provider/BingMaps/Tests/BingMapsTest.php index 45a63e165..0123dc84d 100644 --- a/src/Provider/BingMaps/Tests/BingMapsTest.php +++ b/src/Provider/BingMaps/Tests/BingMapsTest.php @@ -35,31 +35,28 @@ public function testGetName() $this->assertEquals('bing_maps', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\InvalidServerResponse - */ public function testGeocodeWithInvalidData() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $provider = new BingMaps($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('foobar')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The BingMaps provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The BingMaps provider does not support IP addresses, only street addresses.'); + $provider = new BingMaps($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The BingMaps provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The BingMaps provider does not support IP addresses, only street addresses.'); + $provider = new BingMaps($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('::1')); } @@ -79,13 +76,13 @@ public function testGeocodeReturnsMultipleResults() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.86321675999999, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.3887721299999995, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.86321675999999, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.3887721299999995, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(48.859354042429, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(2.3809438666389, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(48.867079477571, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(2.3966003933611, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(48.859354042429, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(2.3809438666389, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(48.867079477571, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(2.3966003933611, $result->getBounds()->getEast(), 0.01); $this->assertNull($result->getStreetNumber()); $this->assertEquals('10 Avenue Gambetta', $result->getStreetName()); $this->assertEquals(75020, $result->getPostalCode()); @@ -101,13 +98,13 @@ public function testGeocodeReturnsMultipleResults() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.81342781, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.32503767, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.81342781, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.32503767, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(48.809565092429, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(2.3172171827738, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(48.817290527571, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(2.3328581572262, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(48.809565092429, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(2.3172171827738, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(48.817290527571, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(2.3328581572262, $result->getBounds()->getEast(), 0.01); $this->assertNull($result->getStreetNumber()); $this->assertEquals('10 Avenue Léon Gambetta', $result->getStreetName()); $this->assertEquals(92120, $result->getPostalCode()); @@ -121,13 +118,13 @@ public function testGeocodeReturnsMultipleResults() /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.81014147, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.43568048, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.81014147, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.43568048, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(48.806278752429, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(2.4278605052897, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(48.814004187571, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(2.4435004547103, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(48.806278752429, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(2.4278605052897, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(48.814004187571, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(2.4435004547103, $result->getBounds()->getEast(), 0.01); $this->assertNull($result->getStreetNumber()); $this->assertEquals('10 Avenue Gambetta', $result->getStreetName()); $this->assertEquals(94700, $result->getPostalCode()); @@ -154,13 +151,13 @@ public function testReverseReturnsSingleResult() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.86321648955345, $result->getCoordinates()->getLatitude(), '', 0.0001); - $this->assertEquals(2.3887719959020615, $result->getCoordinates()->getLongitude(), '', 0.0001); + $this->assertEqualsWithDelta(48.86321648955345, $result->getCoordinates()->getLatitude(), 0.0001); + $this->assertEqualsWithDelta(2.3887719959020615, $result->getCoordinates()->getLongitude(), 0.0001); $this->assertNotNull($result->getBounds()); - $this->assertEquals(48.859353771983, $result->getBounds()->getSouth(), '', 0.0001); - $this->assertEquals(2.3809437325833, $result->getBounds()->getWest(), '', 0.0001); - $this->assertEquals(48.867079207124, $result->getBounds()->getNorth(), '', 0.0001); - $this->assertEquals(2.3966002592208, $result->getBounds()->getEast(), '', 0.0001); + $this->assertEqualsWithDelta(48.859353771983, $result->getBounds()->getSouth(), 0.0001); + $this->assertEqualsWithDelta(2.3809437325833, $result->getBounds()->getWest(), 0.0001); + $this->assertEqualsWithDelta(48.867079207124, $result->getBounds()->getNorth(), 0.0001); + $this->assertEqualsWithDelta(2.3966002592208, $result->getBounds()->getEast(), 0.0001); $this->assertNull($result->getStreetNumber()); $this->assertEquals('10 Avenue Gambetta', $result->getStreetName()); $this->assertEquals(75020, $result->getPostalCode()); @@ -189,13 +186,13 @@ public function testGeocodeWithRealAddressReturnsSingleResults() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.86321675999999, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.3887721299999995, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.86321675999999, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.3887721299999995, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(48.859354042429, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(2.3967310, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(48.867079477571, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(2.3966003933611, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(48.859354042429, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(2.3967310, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(48.867079477571, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(2.3966003933611, $result->getBounds()->getEast(), 0.01); $this->assertNull($result->getStreetNumber()); $this->assertEquals('10 Avenue Gambetta', $result->getStreetName()); $this->assertEquals(75020, $result->getPostalCode()); @@ -239,13 +236,13 @@ public function testReverseWithRealCoordinatesReturnsSingleResult() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.86321648955345, $result->getCoordinates()->getLatitude(), '', 0.0001); - $this->assertEquals(2.3887719959020615, $result->getCoordinates()->getLongitude(), '', 0.0001); + $this->assertEqualsWithDelta(48.86321648955345, $result->getCoordinates()->getLatitude(), 0.0001); + $this->assertEqualsWithDelta(2.3887719959020615, $result->getCoordinates()->getLongitude(), 0.0001); $this->assertNotNull($result->getBounds()); - $this->assertEquals(48.859353771983, $result->getBounds()->getSouth(), '', 0.0001); - $this->assertEquals(2.3809437325833, $result->getBounds()->getWest(), '', 0.0001); - $this->assertEquals(48.867079207124, $result->getBounds()->getNorth(), '', 0.0001); - $this->assertEquals(2.3966002592208, $result->getBounds()->getEast(), '', 0.0001); + $this->assertEqualsWithDelta(48.859353771983, $result->getBounds()->getSouth(), 0.0001); + $this->assertEqualsWithDelta(2.3809437325833, $result->getBounds()->getWest(), 0.0001); + $this->assertEqualsWithDelta(48.867079207124, $result->getBounds()->getNorth(), 0.0001); + $this->assertEqualsWithDelta(2.3966002592208, $result->getBounds()->getEast(), 0.0001); $this->assertNull($result->getStreetNumber()); $this->assertEquals('3 Avenue Gambetta', $result->getStreetName()); $this->assertEquals(75020, $result->getPostalCode()); @@ -259,12 +256,11 @@ public function testReverseWithRealCoordinatesReturnsSingleResult() $this->assertNull($result->getTimezone()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The BingMaps provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The BingMaps provider does not support IP addresses, only street addresses.'); + if (!isset($_SERVER['BINGMAPS_API_KEY'])) { $this->markTestSkipped('You need to configure the BINGMAPS_API_KEY value in phpunit.xml'); } @@ -273,12 +269,11 @@ public function testGeocodeWithRealIPv4() $provider->geocodeQuery(GeocodeQuery::create('88.188.221.14')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The BingMaps provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The BingMaps provider does not support IP addresses, only street addresses.'); + if (!isset($_SERVER['BINGMAPS_API_KEY'])) { $this->markTestSkipped('You need to configure the BINGMAPS_API_KEY value in phpunit.xml'); } diff --git a/src/Provider/Cache/Tests/ProviderCacheTest.php b/src/Provider/Cache/Tests/ProviderCacheTest.php index 1aa66cce8..17d6937dc 100644 --- a/src/Provider/Cache/Tests/ProviderCacheTest.php +++ b/src/Provider/Cache/Tests/ProviderCacheTest.php @@ -36,7 +36,7 @@ class ProviderCacheTest extends TestCase */ private $cacheMock; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/src/Provider/FreeGeoIp/Tests/FreeGeoIpTest.php b/src/Provider/FreeGeoIp/Tests/FreeGeoIpTest.php index f0e433525..f93fbda42 100644 --- a/src/Provider/FreeGeoIp/Tests/FreeGeoIpTest.php +++ b/src/Provider/FreeGeoIp/Tests/FreeGeoIpTest.php @@ -31,12 +31,11 @@ public function testGetName() $this->assertEquals('free_geo_ip', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The FreeGeoIp provider does not support street addresses. - */ public function testGeocodeWithAddress() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The FreeGeoIp provider does not support street addresses.'); + $provider = $this->getProvider(); $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); } @@ -205,21 +204,19 @@ public function testGeocodeWithIncorrectLocale() $this->assertEquals('Russia', $results->first()->getCountry()->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The FreeGeoIp provider is not able to do reverse geocoding. - */ public function testReverse() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The FreeGeoIp provider is not able to do reverse geocoding.'); + $provider = $this->getProvider(); $provider->reverseQuery(ReverseQuery::fromCoordinates(1, 2)); } - /** - * @expectedException \Geocoder\Exception\InvalidServerResponse - */ public function testServerEmptyResponse() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $provider = new FreeGeoIp($this->getMockedHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('87.227.124.53')); } diff --git a/src/Provider/GeoIP2/Tests/GeoIP2AdapterTest.php b/src/Provider/GeoIP2/Tests/GeoIP2AdapterTest.php index 335ce0202..19272f02f 100644 --- a/src/Provider/GeoIP2/Tests/GeoIP2AdapterTest.php +++ b/src/Provider/GeoIP2/Tests/GeoIP2AdapterTest.php @@ -31,14 +31,14 @@ class GeoIP2AdapterTest extends TestCase * * @throws RuntimeException */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { if (false === class_exists('\GeoIp2\Database\Reader')) { throw new RuntimeException("The maxmind's lib 'geoip2/geoip2' is required to run this test."); } } - public function setUp() + public function setUp(): void { $this->adapter = new GeoIP2Adapter($this->getGeoIP2ProviderMock()); } @@ -49,22 +49,20 @@ public function testGetName() $this->assertEquals($expectedName, $this->adapter->getName()); } - /** - * @expectedException \Geocoder\Exception\InvalidArgument - * @expectedExceptionMessage must be called with a valid url. Got "127.0.0.1" instead. - */ public function testGetContentMustBeCalledWithUrl() { + $this->expectException(\Geocoder\Exception\InvalidArgument::class); + $this->expectExceptionMessage('must be called with a valid url. Got "127.0.0.1" instead.'); + $url = '127.0.0.1'; $this->adapter->getContent($url); } - /** - * @expectedException \Geocoder\Exception\InvalidArgument - * @expectedExceptionMessage URL must contain a valid query-string (an IP address, 127.0.0.1 for instance) - */ public function testAddressPassedToReaderMustBeIpAddress() { + $this->expectException(\Geocoder\Exception\InvalidArgument::class); + $this->expectExceptionMessage('URL must contain a valid query-string (an IP address, 127.0.0.1 for instance)'); + $url = 'file://database?not-valid=1'; $this->adapter->getContent($url); } @@ -95,12 +93,11 @@ public function testIpAddressIsPassedCorrectToReader($geoIp2Model) $adapter->getContent('file://geoip?127.0.0.1'); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage Model "unsupported_model" is not available. - */ public function testNotSupportedGeoIP2ModelLeadsToException() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('Model "unsupported_model" is not available.'); + new GeoIP2Adapter($this->getGeoIP2ProviderMock(), 'unsupported_model'); } diff --git a/src/Provider/GeoIP2/Tests/GeoIP2Test.php b/src/Provider/GeoIP2/Tests/GeoIP2Test.php index 57627793d..decbca209 100644 --- a/src/Provider/GeoIP2/Tests/GeoIP2Test.php +++ b/src/Provider/GeoIP2/Tests/GeoIP2Test.php @@ -35,7 +35,7 @@ class GeoIP2Test extends BaseTestCase */ protected $provider; - public function setUp() + public function setUp(): void { $this->provider = new GeoIP2($this->getGeoIP2AdapterMock()); } @@ -50,12 +50,11 @@ public function testGetName() $this->assertEquals('geoip2', $this->provider->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The GeoIP2 provider is not able to do reverse geocoding. - */ public function testQueryingReverseLeadsToException() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The GeoIP2 provider is not able to do reverse geocoding.'); + $this->provider->reverseQuery(ReverseQuery::fromCoordinates(50, 9)); } @@ -73,12 +72,11 @@ public function testGeocodeWithLocalhostIPv4() $this->assertEquals('localhost', $result->getCountry()->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The GeoIP2 provider does not support street addresses, only IP addresses. - */ public function testOnlyIpAddressesCouldBeResolved() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The GeoIP2 provider does not support street addresses, only IP addresses.'); + $this->provider->geocodeQuery(GeocodeQuery::create('Street 123, Somewhere')); } diff --git a/src/Provider/GeoIPs/Tests/GeoIPsTest.php b/src/Provider/GeoIPs/Tests/GeoIPsTest.php index 84e553177..d56d10720 100644 --- a/src/Provider/GeoIPs/Tests/GeoIPsTest.php +++ b/src/Provider/GeoIPs/Tests/GeoIPsTest.php @@ -32,12 +32,11 @@ protected function getCacheDir() return __DIR__.'/.cached_responses'; } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The GeoIPs provider does not support street addresses, only IPv4 addresses. - */ public function testGeocodeWithAddress() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The GeoIPs provider does not support street addresses, only IPv4 addresses.'); + $provider = new GeoIPs($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); } @@ -57,30 +56,27 @@ public function testGeocodeWithLocalhostIPv4() $this->assertEquals('localhost', $result->getCountry()->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The GeoIPs provider does not support IPv6 addresses, only IPv4 addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The GeoIPs provider does not support IPv6 addresses, only IPv4 addresses.'); + $provider = new GeoIPs($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('::1')); } - /** - * @expectedException \Geocoder\Exception\InvalidServerResponse - */ public function testGeocodeWithRealIPv4GetsNullContent() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $provider = new GeoIPs($this->getMockedHttpClient(null), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\InvalidServerResponse - */ public function testGeocodeWithRealIPv4GetsEmptyContent() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $provider = new GeoIPs($this->getMockedHttpClient(''), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } @@ -178,12 +174,11 @@ public function testGeocodeWithRealIPv4GetsFakeContent() $this->assertEquals('MST', $result->getTimezone()); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage The API key associated with your request was not recognized. - */ public function testGeocodeWithRealIPv4AndInvalidApiKeyGetsFakeContent() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('The API key associated with your request was not recognized.'); + $provider = new GeoIPs( $this->getMockedHttpClient( '{ @@ -204,12 +199,11 @@ public function testGeocodeWithRealIPv4AndInvalidApiKeyGetsFakeContent() $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage The API key has not been approved or has been disabled. - */ public function testGeocodeWithRealIPv4AndInvalidApiKeyGetsFakeContent2() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('The API key has not been approved or has been disabled.'); + $provider = new GeoIPs( $this->getMockedHttpClient( '{ @@ -230,12 +224,11 @@ public function testGeocodeWithRealIPv4AndInvalidApiKeyGetsFakeContent2() $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\QuotaExceeded - * @expectedExceptionMessage The service you have requested is over capacity. - */ public function testGeocodeWithRealIPv4AndQuotaExceeded() { + $this->expectException(\Geocoder\Exception\QuotaExceeded::class); + $this->expectExceptionMessage('The service you have requested is over capacity.'); + $provider = new GeoIPs( $this->getMockedHttpClient( '{ @@ -256,12 +249,11 @@ public function testGeocodeWithRealIPv4AndQuotaExceeded() $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\InvalidArgument - * @expectedExceptionMessage The API call should include a valid IP address. - */ public function testGeocodeGetsFakeContentWithIpNotFound() { + $this->expectException(\Geocoder\Exception\InvalidArgument::class); + $this->expectExceptionMessage('The API call should include a valid IP address.'); + $provider = new GeoIPs( $this->getMockedHttpClient( '{ @@ -282,12 +274,11 @@ public function testGeocodeGetsFakeContentWithIpNotFound() $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage The API call should include a API key parameter. - */ public function testGeocodeGetsFakeContentWithKeyNotFound() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('The API call should include a API key parameter.'); + $provider = new GeoIPs( $this->getMockedHttpClient( '{ @@ -350,12 +341,11 @@ public function testGeocodeWithRealIPv4ZeroResults() $this->assertEquals(0, $result->count()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The GeoIPs provider is not able to do reverse geocoding. - */ public function testReverse() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The GeoIPs provider is not able to do reverse geocoding.'); + $provider = new GeoIPs($this->getMockedHttpClient(), 'api_key'); $provider->reverseQuery(ReverseQuery::fromCoordinates(1, 2)); } diff --git a/src/Provider/GeoPlugin/Tests/GeoPluginTest.php b/src/Provider/GeoPlugin/Tests/GeoPluginTest.php index 945c38c5a..6cd25a33e 100644 --- a/src/Provider/GeoPlugin/Tests/GeoPluginTest.php +++ b/src/Provider/GeoPlugin/Tests/GeoPluginTest.php @@ -30,12 +30,11 @@ public function testgetName() $this->assertEquals('geo_plugin', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The GeoPlugin provider does not support street addresses, only IP addresses. - */ public function testGeocodeWithAddress() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The GeoPlugin provider does not support street addresses, only IP addresses.'); + $provider = new GeoPlugin($this->getMockedHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); } @@ -86,12 +85,11 @@ public function testGeocodeWithRealIPv4() $this->assertEquals('US', $result->getCountry()->getCode()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The GeoPlugin provider is not able to do reverse geocoding. - */ public function testReverse() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The GeoPlugin provider is not able to do reverse geocoding.'); + $provider = new GeoPlugin($this->getMockedHttpClient()); $provider->reverseQuery(ReverseQuery::fromCoordinates(1, 2)); } diff --git a/src/Provider/GeocodeEarth/Tests/GeocodeEarthTest.php b/src/Provider/GeocodeEarth/Tests/GeocodeEarthTest.php index 780066c31..228e2c123 100644 --- a/src/Provider/GeocodeEarth/Tests/GeocodeEarthTest.php +++ b/src/Provider/GeocodeEarth/Tests/GeocodeEarthTest.php @@ -55,8 +55,8 @@ public function testGeocodeWithRealAddress() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.521124, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.20360200000000001, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.521124, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.20360200000000001, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Acklam Road', $result->getStreetName()); $this->assertEquals('London', $result->getLocality()); $this->assertCount(3, $result->getAdminLevels()); @@ -80,8 +80,8 @@ public function testReverseWithRealCoordinates() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(54.048411999999999, $result->getCoordinates()->getLatitude(), '', 0.001); - $this->assertEquals(-2.7989549999999999, $result->getCoordinates()->getLongitude(), '', 0.001); + $this->assertEqualsWithDelta(54.048411999999999, $result->getCoordinates()->getLatitude(), 0.001); + $this->assertEqualsWithDelta(-2.7989549999999999, $result->getCoordinates()->getLongitude(), 0.001); $this->assertEquals(1, $result->getStreetNumber()); $this->assertEquals('Gage Street', $result->getStreetName()); $this->assertEquals('LA1 1UH', $result->getPostalCode()); @@ -126,8 +126,8 @@ public function testGeocodeWithCity() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.379952, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(9.787455, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(52.379952, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(9.787455, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(4, $result->getAdminLevels()); $this->assertEquals('Niedersachsen', $result->getAdminLevels()->get(1)->getName()); @@ -137,8 +137,8 @@ public function testGeocodeWithCity() /** @var \Geocoder\Model\Address $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.37362, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(9.73711, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(52.37362, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(9.73711, $result->getCoordinates()->getLongitude(), 0.01); $this->assertCount(3, $result->getAdminLevels()); $this->assertEquals('Niedersachsen', $result->getAdminLevels()->get(1)->getName()); $this->assertEquals('Germany', $result->getCountry()->getName()); @@ -146,8 +146,8 @@ public function testGeocodeWithCity() /** @var \Geocoder\Model\Address $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(18.393428, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-78.107687, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(18.393428, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-78.107687, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNull($result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Hanover', $result->getAdminLevels()->get(1)->getName()); @@ -156,8 +156,8 @@ public function testGeocodeWithCity() /** @var \Geocoder\Model\Address $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(39.192889999999998, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-76.724140000000006, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(39.192889999999998, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-76.724140000000006, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(4, $result->getAdminLevels()); $this->assertEquals('Hanover', $result->getAdminLevels()->get(3)->getName()); @@ -179,8 +179,8 @@ public function testGeocodeWithCityDistrict() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(50.189017, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(8.6367809999999992, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(50.189017, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(8.6367809999999992, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('10a', $result->getStreetNumber()); $this->assertEquals('Kalbacher Hauptstraße', $result->getStreetName()); $this->assertEquals(60437, $result->getPostalCode()); @@ -208,20 +208,19 @@ public function testGeocodeNoBounds() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.230428, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(21.004552, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(52.230428, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(21.004552, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Warsaw', $result->getLocality()); $this->assertEquals('Poland', $result->getCountry()->getName()); $this->assertEquals('POL', $result->getCountry()->getCode()); $this->assertNull($result->getBounds()); } - /** - * @expectedException \Geocoder\Exception\QuotaExceeded - * @expectedExceptionMessage Valid request but quota exceeded. - */ public function testGeocodeQuotaExceeded() { + $this->expectException(\Geocoder\Exception\QuotaExceeded::class); + $this->expectExceptionMessage('Valid request but quota exceeded.'); + $provider = new GeocodeEarth( $this->getMockedHttpClient( '{ @@ -242,12 +241,11 @@ public function testGeocodeQuotaExceeded() $provider->geocodeQuery(GeocodeQuery::create('New York')); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage Invalid or missing api key. - */ public function testGeocodeInvalidApiKey() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('Invalid or missing api key.'); + $provider = new GeocodeEarth( $this->getMockedHttpClient( '{ @@ -268,42 +266,38 @@ public function testGeocodeInvalidApiKey() $provider->geocodeQuery(GeocodeQuery::create('New York')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The geocode_earth provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The geocode_earth provider does not support IP addresses, only street addresses.'); + $provider = new GeocodeEarth($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The geocode_earth provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The geocode_earth provider does not support IP addresses, only street addresses.'); + $provider = new GeocodeEarth($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('::1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The geocode_earth provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The geocode_earth provider does not support IP addresses, only street addresses.'); + $provider = new GeocodeEarth($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The geocode_earth provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The geocode_earth provider does not support IP addresses, only street addresses.'); + $provider = new GeocodeEarth($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('::ffff:74.200.247.59')); } diff --git a/src/Provider/Geoip/Tests/GeoipTest.php b/src/Provider/Geoip/Tests/GeoipTest.php index 6fc5457bf..7ac9664cb 100644 --- a/src/Provider/Geoip/Tests/GeoipTest.php +++ b/src/Provider/Geoip/Tests/GeoipTest.php @@ -20,7 +20,7 @@ class GeoipTest extends BaseTestCase { - protected function setUp() + protected function setUp(): void { if (!function_exists('geoip_record_by_name')) { $this->markTestSkipped('You have to install GeoIP.'); diff --git a/src/Provider/Geoip/Tests/IntegrationTest.php b/src/Provider/Geoip/Tests/IntegrationTest.php index cf182ec4f..bdde2ffb8 100644 --- a/src/Provider/Geoip/Tests/IntegrationTest.php +++ b/src/Provider/Geoip/Tests/IntegrationTest.php @@ -29,7 +29,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testHttpProvider = false; - protected function setUp() + protected function setUp(): void { if (!function_exists('geoip_record_by_name')) { $this->markTestSkipped('You have to install GeoIP.'); diff --git a/src/Provider/Geonames/Tests/CountryInfoTest.php b/src/Provider/Geonames/Tests/CountryInfoTest.php index a87723315..3a8de4e1b 100644 --- a/src/Provider/Geonames/Tests/CountryInfoTest.php +++ b/src/Provider/Geonames/Tests/CountryInfoTest.php @@ -32,7 +32,7 @@ public function testCountryInfoWithOneCountry() $provider = new Geonames($this->getHttpClient($_SERVER['GEONAMES_USERNAME']), $_SERVER['GEONAMES_USERNAME']); $results = $provider->getCountryInfo('IN'); - $this->assertInternalType('array', $results); + $this->assertIsArray($results); $this->assertEquals(1, count($results)); /* @var CountryInfo $result */ @@ -42,7 +42,7 @@ public function testCountryInfoWithOneCountry() $this->assertInstanceOf('Geocoder\Model\Bounds', $result->getBounds()); $this->assertEquals('AS', $result->getContinent()); $this->assertEquals('New Delhi', $result->getCapital()); - $this->assertInternalType('array', $result->getLanguages()); + $this->assertIsArray($result->getLanguages()); $this->assertEquals(1269750, $result->getGeonameId()); $this->assertEquals('IND', $result->getIsoAlpha3()); $this->assertEquals('IN', $result->getFipsCode()); diff --git a/src/Provider/Geonames/Tests/GeonamesTest.php b/src/Provider/Geonames/Tests/GeonamesTest.php index 305543ea0..4faa96ec5 100644 --- a/src/Provider/Geonames/Tests/GeonamesTest.php +++ b/src/Provider/Geonames/Tests/GeonamesTest.php @@ -33,22 +33,20 @@ public function testGetName() $this->assertEquals('geonames', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Geonames provider does not support IP addresses. - */ public function testGeocodeWithLocalhostIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Geonames provider does not support IP addresses.'); + $provider = new Geonames($this->getMockedHttpClient(), 'username'); $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Geonames provider does not support IP addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Geonames provider does not support IP addresses.'); + $provider = new Geonames($this->getMockedHttpClient(), 'username'); $provider->geocodeQuery(GeocodeQuery::create('::1')); } @@ -82,8 +80,8 @@ public function testGeocodeWithRealPlace() /** @var GeonamesAddress $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.49957, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.16359, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.49957, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.16359, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('United Kingdom', $result->getCountry()->getName()); $this->assertEquals('GB', $result->getCountry()->getCode()); $this->assertEquals('Europe/London', $result->getTimezone()); @@ -112,13 +110,13 @@ public function testGeocodeWithMultipleRealPlaces() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.508528775863, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.12574195861816, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.508528775863, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.12574195861816, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(51.151689398345, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(-0.70360885396019, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(51.865368153381, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(0.45212493672386, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(51.151689398345, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(-0.70360885396019, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(51.865368153381, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(0.45212493672386, $result->getBounds()->getEast(), 0.01); $this->assertEquals('London', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Greater London', $result->getAdminLevels()->get(2)->getName()); @@ -130,13 +128,13 @@ public function testGeocodeWithMultipleRealPlaces() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(-33.015285093464, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(27.911624908447, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(-33.015285093464, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(27.911624908447, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(-33.104996458003, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(27.804746435655, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(-32.925573728925, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(28.018503381239, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(-33.104996458003, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(27.804746435655, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(-32.925573728925, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(28.018503381239, $result->getBounds()->getEast(), 0.01); $this->assertEquals('East London', $result->getLocality()); $this->assertCount(3, $result->getAdminLevels()); $this->assertEquals('Buffalo City', $result->getAdminLevels()->get(3)->getName()); @@ -149,13 +147,13 @@ public function testGeocodeWithMultipleRealPlaces() /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.512788890295, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.091838836669922, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.512788890295, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.091838836669922, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(51.155949512764, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(-0.66976046752962, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(51.869628267826, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(0.48608279418978, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(51.155949512764, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(-0.66976046752962, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(51.869628267826, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(0.48608279418978, $result->getBounds()->getEast(), 0.01); $this->assertEquals('City of London', $result->getLocality()); $this->assertCount(3, $result->getAdminLevels()); $this->assertEquals('City of London', $result->getAdminLevels()->get(3)->getName()); @@ -168,13 +166,13 @@ public function testGeocodeWithMultipleRealPlaces() /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(42.983389283, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-81.233042387, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(42.983389283, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-81.233042387, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(42.907075642763, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(-81.337489676463, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(43.059702923237, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(-81.128595097537, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(42.907075642763, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(-81.337489676463, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(43.059702923237, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(-81.128595097537, $result->getBounds()->getEast(), 0.01); $this->assertEquals('London', $result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); $this->assertEquals('Ontario', $result->getAdminLevels()->get(1)->getName()); @@ -185,13 +183,13 @@ public function testGeocodeWithMultipleRealPlaces() /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(41.3556539, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-72.0995209, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(41.3556539, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-72.0995209, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(41.334087887904, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(-72.128261254846, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(41.377219912096, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(-72.070780545154, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(41.334087887904, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(-72.128261254846, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(41.377219912096, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(-72.070780545154, $result->getBounds()->getEast(), 0.01); $this->assertEquals('New London', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('New London County', $result->getAdminLevels()->get(2)->getName()); @@ -216,13 +214,13 @@ public function testGeocodeWithMultipleRealPlacesWithLocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.50853, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.12574, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.50853, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.12574, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(51.15169, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(-0.70361, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(51.86537, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(0.45212, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(51.15169, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(-0.70361, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(51.86537, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(0.45212, $result->getBounds()->getEast(), 0.01); $this->assertEquals('Londra', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Greater London', $result->getAdminLevels()->get(2)->getName()); @@ -234,13 +232,13 @@ public function testGeocodeWithMultipleRealPlacesWithLocale() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(-33.015285093464, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(27.911624908447, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(-33.015285093464, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(27.911624908447, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(-33.104996458003, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(27.804746435655, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(-32.925573728925, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(28.018503381239, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(-33.104996458003, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(27.804746435655, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(-32.925573728925, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(28.018503381239, $result->getBounds()->getEast(), 0.01); $this->assertEquals('East London', $result->getLocality()); $this->assertCount(3, $result->getAdminLevels()); $this->assertEquals('Buffalo City', $result->getAdminLevels()->get(3)->getName()); @@ -253,13 +251,13 @@ public function testGeocodeWithMultipleRealPlacesWithLocale() /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.512788890295, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.091838836669922, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.512788890295, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.091838836669922, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(51.155949512764, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(-0.66976046752962, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(51.869628267826, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(0.48608279418978, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(51.155949512764, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(-0.66976046752962, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(51.869628267826, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(0.48608279418978, $result->getBounds()->getEast(), 0.01); $this->assertEquals('Città di Londra', $result->getLocality()); $this->assertCount(3, $result->getAdminLevels()); $this->assertEquals('City of London', $result->getAdminLevels()->get(3)->getName()); @@ -272,13 +270,13 @@ public function testGeocodeWithMultipleRealPlacesWithLocale() /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(42.983389283, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-81.233042387, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(42.983389283, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-81.233042387, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(42.907075642763, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(-81.337489676463, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(43.059702923237, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(-81.128595097537, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(42.907075642763, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(-81.337489676463, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(43.059702923237, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(-81.128595097537, $result->getBounds()->getEast(), 0.01); $this->assertEquals('London', $result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); $this->assertEquals('Ontario', $result->getAdminLevels()->get(1)->getName()); @@ -289,13 +287,13 @@ public function testGeocodeWithMultipleRealPlacesWithLocale() /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(41.3556539, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-72.0995209, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(41.3556539, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-72.0995209, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(41.334087887904, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(-72.128261254846, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(41.377219912096, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(-72.070780545154, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(41.334087887904, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(-72.128261254846, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(41.377219912096, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(-72.070780545154, $result->getBounds()->getEast(), 0.01); $this->assertEquals('New London', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Contea di New London', $result->getAdminLevels()->get(2)->getName()); @@ -320,8 +318,8 @@ public function testReverseWithRealCoordinates() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.50853, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.12574, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.50853, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.12574, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('London', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Greater London', $result->getAdminLevels()->get(2)->getName()); @@ -346,8 +344,8 @@ public function testReverseWithRealCoordinatesWithLocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.50853, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.12574, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.50853, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.12574, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Londra', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Greater London', $result->getAdminLevels()->get(2)->getName()); diff --git a/src/Provider/GoogleMaps/Tests/GoogleMapsTest.php b/src/Provider/GoogleMaps/Tests/GoogleMapsTest.php index 08b3ebab2..943fb19d0 100644 --- a/src/Provider/GoogleMaps/Tests/GoogleMapsTest.php +++ b/src/Provider/GoogleMaps/Tests/GoogleMapsTest.php @@ -45,41 +45,38 @@ public function testGetName() $this->assertEquals('google_maps', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - */ public function testGeocodeWithLocalhostIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The GoogleMaps provider does not support IP addresses, only street addresses.'); + $provider = new GoogleMaps($this->getMockedHttpClient(), null, 'mock-api-key'); $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The GoogleMaps provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The GoogleMaps provider does not support IP addresses, only street addresses.'); + $provider = new GoogleMaps($this->getMockedHttpClient(), null, 'mock-api-key'); $provider->geocodeQuery(GeocodeQuery::create('::1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The GoogleMaps provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIp() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The GoogleMaps provider does not support IP addresses, only street addresses.'); + $provider = $this->getGoogleMapsProvider(); $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\QuotaExceeded - * @expectedExceptionMessage Daily quota exceeded https://maps.googleapis.com/maps/api/geocode/json?address=10%20avenue%20Gambetta%2C%20Paris%2C%20France - */ public function testGeocodeWithQuotaExceeded() { + $this->expectException(\Geocoder\Exception\QuotaExceeded::class); + $this->expectExceptionMessage('Daily quota exceeded https://maps.googleapis.com/maps/api/geocode/json?address=10%20avenue%20Gambetta%2C%20Paris%2C%20France'); + $provider = new GoogleMaps($this->getMockedHttpClient('{"status":"OVER_QUERY_LIMIT"}'), null, 'mock-api-key'); $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); } @@ -100,13 +97,13 @@ public function testGeocodeWithRealAddress() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf(Address::class, $result); - $this->assertEquals(48.8630462, $result->getCoordinates()->getLatitude(), '', 0.001); - $this->assertEquals(2.3882487, $result->getCoordinates()->getLongitude(), '', 0.001); + $this->assertEqualsWithDelta(48.8630462, $result->getCoordinates()->getLatitude(), 0.001); + $this->assertEqualsWithDelta(2.3882487, $result->getCoordinates()->getLongitude(), 0.001); $this->assertNotNull($result->getBounds()); - $this->assertEquals(48.8617, $result->getBounds()->getSouth(), '', 0.001); - $this->assertEquals(2.3882487, $result->getBounds()->getWest(), '', 0.001); - $this->assertEquals(48.8644, $result->getBounds()->getNorth(), '', 0.001); - $this->assertEquals(2.3901, $result->getBounds()->getEast(), '', 0.001); + $this->assertEqualsWithDelta(48.8617, $result->getBounds()->getSouth(), 0.001); + $this->assertEqualsWithDelta(2.3882487, $result->getBounds()->getWest(), 0.001); + $this->assertEqualsWithDelta(48.8644, $result->getBounds()->getNorth(), 0.001); + $this->assertEqualsWithDelta(2.3901, $result->getBounds()->getEast(), 0.001); $this->assertEquals(10, $result->getStreetNumber()); $this->assertEquals('Avenue Gambetta', $result->getStreetName()); $this->assertEquals(75020, $result->getPostalCode()); @@ -135,19 +132,18 @@ public function testGeocodeBoundsWithRealAddressForNonRooftopLocation() $result = $results->first(); $this->assertInstanceOf(Address::class, $result); $this->assertNotNull($result->getBounds()); - $this->assertEquals(48.815573, $result->getBounds()->getSouth(), '', 0.0001); - $this->assertEquals(2.224199, $result->getBounds()->getWest(), '', 0.0001); - $this->assertEquals(48.902145, $result->getBounds()->getNorth(), '', 0.0001); - $this->assertEquals(2.4699209, $result->getBounds()->getEast(), '', 0.0001); + $this->assertEqualsWithDelta(48.815573, $result->getBounds()->getSouth(), 0.0001); + $this->assertEqualsWithDelta(2.224199, $result->getBounds()->getWest(), 0.0001); + $this->assertEqualsWithDelta(48.902145, $result->getBounds()->getNorth(), 0.0001); + $this->assertEqualsWithDelta(2.4699209, $result->getBounds()->getEast(), 0.0001); $this->assertEquals('ChIJD7fiBh9u5kcRYJSMaMOCCwQ', $result->getId()); $this->assertEquals(false, $result->isPartialMatch()); } - /** - * @expectedException \Geocoder\Exception\InvalidServerResponse - */ public function testReverse() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $provider = new GoogleMaps($this->getMockedHttpClient(), null, 'mock-api-key'); $provider->reverseQuery(ReverseQuery::fromCoordinates(1, 2)); } @@ -215,12 +211,11 @@ public function testGeocodeWithCityDistrict() $this->assertEquals(false, $result->isPartialMatch()); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage API key is invalid https://maps.googleapis.com/maps/api/geocode/json?address=10%20avenue%20Gambetta%2C%20Paris%2C%20France - */ public function testGeocodeWithInvalidApiKey() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('API key is invalid https://maps.googleapis.com/maps/api/geocode/json?address=10%20avenue%20Gambetta%2C%20Paris%2C%20France'); + $provider = new GoogleMaps($this->getMockedHttpClient('{"error_message":"The provided API key is invalid.", "status":"REQUEST_DENIED"}'), null, 'mock-api-key'); $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); } @@ -328,12 +323,11 @@ function (RequestInterface $request) use (&$uri) { ); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage API key is invalid https://maps.googleapis.com/maps/api/geocode/json?address=Columbia&key=fake_key - */ public function testGeocodeWithRealInvalidApiKey() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('API key is invalid https://maps.googleapis.com/maps/api/geocode/json?address=Columbia&key=fake_key'); + $provider = new GoogleMaps($this->getHttpClient($this->testAPIKey), null, $this->testAPIKey); $provider->geocodeQuery(GeocodeQuery::create('Columbia')); } @@ -424,20 +418,18 @@ function (RequestInterface $request) use (&$uri) { ); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - */ public function testGeocodeWithInvalidClientIdAndKey() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $provider = GoogleMaps::business($this->getHttpClient(), 'foo', 'bogus'); $provider->geocodeQuery(GeocodeQuery::create('Columbia University')); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - */ public function testGeocodeWithInvalidClientIdAndKeyNoSsl() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $provider = GoogleMaps::business($this->getHttpClient(), 'foo', 'bogus'); $provider->geocodeQuery(GeocodeQuery::create('Columbia University')); } @@ -570,10 +562,10 @@ public function testGeocodeBoundsWithRealAddressWithViewportOnly() $result = $results->first(); $this->assertInstanceOf(Address::class, $result); $this->assertNotNull($result->getBounds()); - $this->assertEquals(50.8376, $result->getBounds()->getSouth(), '', 0.001); - $this->assertEquals(5.8113, $result->getBounds()->getWest(), '', 0.001); - $this->assertEquals(50.8517, $result->getBounds()->getNorth(), '', 0.001); - $this->assertEquals(5.8433, $result->getBounds()->getEast(), '', 0.001); + $this->assertEqualsWithDelta(50.8376, $result->getBounds()->getSouth(), 0.001); + $this->assertEqualsWithDelta(5.8113, $result->getBounds()->getWest(), 0.001); + $this->assertEqualsWithDelta(50.8517, $result->getBounds()->getNorth(), 0.001); + $this->assertEqualsWithDelta(5.8433, $result->getBounds()->getEast(), 0.001); $this->assertEquals(false, $result->isPartialMatch()); } diff --git a/src/Provider/GraphHopper/Tests/GraphHopperTest.php b/src/Provider/GraphHopper/Tests/GraphHopperTest.php index b049a9325..4c6a0c30c 100644 --- a/src/Provider/GraphHopper/Tests/GraphHopperTest.php +++ b/src/Provider/GraphHopper/Tests/GraphHopperTest.php @@ -48,8 +48,8 @@ public function testGeocodeWithRealAddress() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.521124, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.20360200000000001, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.521124, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.20360200000000001, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Acklam Road', $result->getStreetName()); $this->assertEquals('London', $result->getLocality()); $this->assertEquals('United Kingdom', $result->getCountry()->getName()); @@ -70,8 +70,8 @@ public function testGeocodeWithRealAddressAndLocale() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.521124, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.20360200000000001, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.521124, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.20360200000000001, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Acklam Road', $result->getStreetName()); $this->assertEquals('Londres', $result->getLocality()); $this->assertEquals('Royaume-Uni', $result->getCountry()->getName()); @@ -92,8 +92,8 @@ public function testReverseWithRealCoordinates() /** @var \Geocoder\Model\Address $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(54.048411999999999, $result->getCoordinates()->getLatitude(), '', 0.001); - $this->assertEquals(-2.7989549999999999, $result->getCoordinates()->getLongitude(), '', 0.001); + $this->assertEqualsWithDelta(54.048411999999999, $result->getCoordinates()->getLatitude(), 0.001); + $this->assertEqualsWithDelta(-2.7989549999999999, $result->getCoordinates()->getLongitude(), 0.001); $this->assertEquals('1', $result->getStreetNumber()); $this->assertEquals('Gage Street', $result->getStreetName()); $this->assertEquals('LA1 1UH', $result->getPostalCode()); @@ -101,42 +101,38 @@ public function testReverseWithRealCoordinates() $this->assertEquals('United Kingdom', $result->getCountry()->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The GraphHopper provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The GraphHopper provider does not support IP addresses, only street addresses.'); + $provider = new GraphHopper($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The GraphHopper provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The GraphHopper provider does not support IP addresses, only street addresses.'); + $provider = new GraphHopper($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('::1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The GraphHopper provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The GraphHopper provider does not support IP addresses, only street addresses.'); + $provider = new GraphHopper($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The GraphHopper provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The GraphHopper provider does not support IP addresses, only street addresses.'); + $provider = new GraphHopper($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('::ffff:74.200.247.59')); } diff --git a/src/Provider/Here/Tests/HereTest.php b/src/Provider/Here/Tests/HereTest.php index 3a7a83710..6f17e95cf 100644 --- a/src/Provider/Here/Tests/HereTest.php +++ b/src/Provider/Here/Tests/HereTest.php @@ -49,13 +49,13 @@ public function testGeocodeWithRealAddress() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.8653, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.39844, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.8653, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.39844, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(48.8664242, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(2.3967311, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(48.8641758, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(2.4001489, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(48.8664242, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(2.3967311, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(48.8641758, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(2.4001489, $result->getBounds()->getEast(), 0.01); $this->assertEquals(10, $result->getStreetNumber()); $this->assertEquals('Avenue Gambetta', $result->getStreetName()); @@ -85,13 +85,13 @@ public function testGeocodeWithDefaultAdditionalData() $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(41.37854, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.01196, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(41.37854, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.01196, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(41.36505, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(1.99398, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(41.39203, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(2.02994, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(41.36505, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(1.99398, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(41.39203, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(2.02994, $result->getBounds()->getEast(), 0.01); $this->assertEquals('08690', $result->getPostalCode()); $this->assertEquals('Sant Roc', $result->getSubLocality()); @@ -130,13 +130,13 @@ public function testGeocodeWithAdditionalData() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(41.37854, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.01196, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(41.37854, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.01196, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(41.36505, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(1.99398, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(41.39203, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(2.02994, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(41.36505, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(1.99398, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(41.39203, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(2.02994, $result->getBounds()->getEast(), 0.01); $this->assertEquals('08690', $result->getPostalCode()); $this->assertEquals('Sant Roc', $result->getSubLocality()); @@ -152,7 +152,7 @@ public function testGeocodeWithAdditionalData() $this->assertEquals('NT_TzyupfxmTFN0Rh1TXEMqSA', $result->getAdditionalDataValue('routing_locationId')); $this->assertEquals('address', $result->getAdditionalDataValue('routing_result_type')); $this->assertEquals('WKTShapeType', $result->getShapeValue('_type')); - $this->assertRegexp('/^MULTIPOLYGON/', $result->getShapeValue('Value')); + $this->assertMatchesRegularExpression('/^MULTIPOLYGON/', $result->getShapeValue('Value')); } /** @@ -281,13 +281,13 @@ public function testReverseWithRealCoordinates() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.8632147, $result->getCoordinates()->getLatitude(), '', 0.001); - $this->assertEquals(2.3887722, $result->getCoordinates()->getLongitude(), '', 0.001); + $this->assertEqualsWithDelta(48.8632147, $result->getCoordinates()->getLatitude(), 0.001); + $this->assertEqualsWithDelta(2.3887722, $result->getCoordinates()->getLongitude(), 0.001); $this->assertNotNull($result->getBounds()); - $this->assertEquals(48.86315, $result->getBounds()->getSouth(), '', 0.001); - $this->assertEquals(2.38853, $result->getBounds()->getWest(), '', 0.001); - $this->assertEquals(48.8632147, $result->getBounds()->getNorth(), '', 0.001); - $this->assertEquals(2.38883, $result->getBounds()->getEast(), '', 0.001); + $this->assertEqualsWithDelta(48.86315, $result->getBounds()->getSouth(), 0.001); + $this->assertEqualsWithDelta(2.38853, $result->getBounds()->getWest(), 0.001); + $this->assertEqualsWithDelta(48.8632147, $result->getBounds()->getNorth(), 0.001); + $this->assertEqualsWithDelta(2.38883, $result->getBounds()->getEast(), 0.001); $this->assertEquals('Avenue Gambetta', $result->getStreetName()); $this->assertEquals(75020, $result->getPostalCode()); $this->assertEquals('Paris', $result->getLocality()); @@ -301,41 +301,37 @@ public function testGetName() $this->assertEquals('Here', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\InvalidServerResponse - */ public function testGeocodeWithInvalidData() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $provider = new Here($this->getMockedHttpClient(), 'appId', 'appCode'); $provider->geocodeQuery(GeocodeQuery::create('foobar')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Here provider does not support IP addresses, only street addresses. - */ public function testGeocodeIpv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Here provider does not support IP addresses, only street addresses.'); + $provider = $this->getProvider(); $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Here provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Here provider does not support IP addresses, only street addresses.'); + $provider = $this->getProvider(); $provider->geocodeQuery(GeocodeQuery::create('::1')); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage Invalid or missing api key. - */ public function testGeocodeInvalidApiKey() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('Invalid or missing api key.'); + $provider = new Here( $this->getMockedHttpClient( '{ @@ -350,12 +346,11 @@ public function testGeocodeInvalidApiKey() $provider->geocodeQuery(GeocodeQuery::create('New York')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Here provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Here provider does not support IP addresses, only street addresses.'); + $provider = $this->getProvider(); $provider->geocodeQuery(GeocodeQuery::create('::ffff:88.188.221.14')); } diff --git a/src/Provider/Here/Tests/IntegrationTest.php b/src/Provider/Here/Tests/IntegrationTest.php index 050bfd464..3ea04510c 100644 --- a/src/Provider/Here/Tests/IntegrationTest.php +++ b/src/Provider/Here/Tests/IntegrationTest.php @@ -98,12 +98,12 @@ public function testGeocodeQuery() // Check Downing Street $location = $result->first(); - $this->assertEquals(51.5033, $location->getCoordinates()->getLatitude(), 'Latitude should be in London', 0.1); - $this->assertEquals(-0.1276, $location->getCoordinates()->getLongitude(), 'Longitude should be in London', 0.1); - $this->assertContains('Downing', $location->getStreetName(), 'Street name should contain "Downing St"'); + $this->assertEqualsWithDelta(51.5033, $location->getCoordinates()->getLatitude(), 0.1, 'Latitude should be in London'); + $this->assertEqualsWithDelta(-0.1276, $location->getCoordinates()->getLongitude(), 0.1, 'Longitude should be in London'); + $this->assertStringContainsString('Downing', $location->getStreetName(), 'Street name should contain "Downing St"'); if (null !== $streetNumber = $location->getStreetNumber()) { - $this->assertContains('10', $streetNumber, 'Street number should contain "10"'); + $this->assertStringContainsString('10', $streetNumber, 'Street number should contain "10"'); } } @@ -123,12 +123,12 @@ public function testGeocodeQueryCIT() // Check Downing Street $location = $result->first(); - $this->assertEquals(51.5033, $location->getCoordinates()->getLatitude(), 'Latitude should be in London', 0.1); - $this->assertEquals(-0.1276, $location->getCoordinates()->getLongitude(), 'Longitude should be in London', 0.1); - $this->assertContains('Downing', $location->getStreetName(), 'Street name should contain "Downing St"'); + $this->assertEqualsWithDelta(51.5033, $location->getCoordinates()->getLatitude(), 0.1, 'Latitude should be in London'); + $this->assertEqualsWithDelta(-0.1276, $location->getCoordinates()->getLongitude(), 0.1, 'Longitude should be in London'); + $this->assertStringContainsString('Downing', $location->getStreetName(), 'Street name should contain "Downing St"'); if (null !== $streetNumber = $location->getStreetNumber()) { - $this->assertContains('10', $streetNumber, 'Street number should contain "10"'); + $this->assertStringContainsString('10', $streetNumber, 'Street number should contain "10"'); } } diff --git a/src/Provider/HostIp/Tests/HostIpTest.php b/src/Provider/HostIp/Tests/HostIpTest.php index 35ca26f3e..cc64c9ff0 100644 --- a/src/Provider/HostIp/Tests/HostIpTest.php +++ b/src/Provider/HostIp/Tests/HostIpTest.php @@ -31,12 +31,11 @@ public function testGetName() $this->assertEquals('host_ip', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Geocoder\Provider\HostIp\HostIp provider does not support Street addresses. - */ public function testGeocodeWithAddress() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Geocoder\Provider\HostIp\HostIp provider does not support Street addresses.'); + $provider = new HostIp($this->getMockedHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); } @@ -62,12 +61,11 @@ public function testGeocodeWithLocalhostIPv4() $this->assertEquals('localhost', $result->getCountry()->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The HostIp provider does not support IPv6 addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The HostIp provider does not support IPv6 addresses.'); + $provider = new HostIp($this->getMockedHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('::1')); } @@ -91,22 +89,20 @@ public function testGeocodeWithRealIPv4() $this->assertEquals('FR', $result->getCountry()->getCode()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The HostIp provider does not support IPv6 addresses. - */ public function testGeocodeWithRealIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The HostIp provider does not support IPv6 addresses.'); + $provider = new HostIp($this->getHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('::ffff:88.188.221.14')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The HostIp provider is not able to do reverse geocoding. - */ public function testReverse() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The HostIp provider is not able to do reverse geocoding.'); + $provider = new HostIp($this->getMockedHttpClient()); $provider->reverseQuery(ReverseQuery::fromCoordinates(1, 2)); } diff --git a/src/Provider/HostIp/Tests/HostIpXmlTest.php b/src/Provider/HostIp/Tests/HostIpXmlTest.php index b9082e600..56da5e977 100644 --- a/src/Provider/HostIp/Tests/HostIpXmlTest.php +++ b/src/Provider/HostIp/Tests/HostIpXmlTest.php @@ -31,12 +31,11 @@ public function testGetName() $this->assertEquals('host_ip_xml', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Geocoder\Provider\HostIp\HostIpXml provider does not support Street addresses. - */ public function testGeocodeWithAddress() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Geocoder\Provider\HostIp\HostIpXml provider does not support Street addresses.'); + $provider = new HostIpXml($this->getMockedHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); } @@ -62,12 +61,11 @@ public function testGeocodeWithLocalhostIPv4() $this->assertEquals('localhost', $result->getCountry()->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The HostIp provider does not support IPv6 addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The HostIp provider does not support IPv6 addresses.'); + $provider = new HostIpXml($this->getMockedHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('::1')); } @@ -92,22 +90,20 @@ public function testGeocodeWithRealIPv4() $this->assertEquals('LV', $result->getCountry()->getCode()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The HostIp provider does not support IPv6 addresses. - */ public function testGeocodeWithRealIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The HostIp provider does not support IPv6 addresses.'); + $provider = new HostIpXml($this->getHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('::ffff:88.188.221.14')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The HostIp provider is not able to do reverse geocoding. - */ public function testReverse() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The HostIp provider is not able to do reverse geocoding.'); + $provider = new HostIpXml($this->getMockedHttpClient()); $provider->reverseQuery(ReverseQuery::fromCoordinates(1, 2)); } diff --git a/src/Provider/IP2Location/Tests/IP2LocationTest.php b/src/Provider/IP2Location/Tests/IP2LocationTest.php index 6a7dc340c..5ea403697 100644 --- a/src/Provider/IP2Location/Tests/IP2LocationTest.php +++ b/src/Provider/IP2Location/Tests/IP2LocationTest.php @@ -31,42 +31,38 @@ public function testGetName() $this->assertEquals('ip2location', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The IP2Location provider does not support street addresses, only IP addresses. - */ public function testGeocodeWithRandomString() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The IP2Location provider does not support street addresses, only IP addresses.'); + $provider = new IP2Location($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('foobar')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The IP2Location provider does not support street addresses, only IP addresses. - */ public function testGeocodeWithAddress() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The IP2Location provider does not support street addresses, only IP addresses.'); + $provider = new IP2Location($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage API Key provided is not valid. - */ public function testGeocodeWithInvalidKey() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('API Key provided is not valid.'); + $provider = new IP2Location($this->getHttpClient('invalid_key'), 'api_key'); $results = $provider->geocodeQuery(GeocodeQuery::create('74.125.45.100')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The IP2Location provider does not support street addresses, only IP addresses. - */ public function testGeocodeWithInvalidIPAddress() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The IP2Location provider does not support street addresses, only IP addresses.'); + $provider = new IP2Location($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('300.23.255.5')); } @@ -86,8 +82,8 @@ public function testGeocodeWithRealIPv4() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(36.154, $result->getCoordinates()->getLatitude(), '', 0.001); - $this->assertEquals(-95.9928, $result->getCoordinates()->getLongitude(), '', 0.001); + $this->assertEqualsWithDelta(36.154, $result->getCoordinates()->getLatitude(), 0.001); + $this->assertEqualsWithDelta(-95.9928, $result->getCoordinates()->getLongitude(), 0.001); $this->assertEquals(74101, $result->getPostalCode()); $this->assertEquals('Tulsa', $result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); @@ -111,8 +107,8 @@ public function testGeocodeWithRealIPv6() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(36.154, $result->getCoordinates()->getLatitude(), '', 0.001); - $this->assertEquals(-95.9928, $result->getCoordinates()->getLongitude(), '', 0.001); + $this->assertEqualsWithDelta(36.154, $result->getCoordinates()->getLatitude(), 0.001); + $this->assertEqualsWithDelta(-95.9928, $result->getCoordinates()->getLongitude(), 0.001); $this->assertEquals(74101, $result->getPostalCode()); $this->assertEquals('Tulsa', $result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); @@ -121,12 +117,11 @@ public function testGeocodeWithRealIPv6() $this->assertEquals('US', $result->getCountry()->getCode()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The IP2Location provider is not able to do reverse geocoding. - */ public function testReverse() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The IP2Location provider is not able to do reverse geocoding.'); + $provider = new IP2Location($this->getMockedHttpClient(), 'api_key'); $provider->reverseQuery(ReverseQuery::fromCoordinates(0, 0)); } diff --git a/src/Provider/IP2LocationBinary/Tests/IP2LocationBinaryTest.php b/src/Provider/IP2LocationBinary/Tests/IP2LocationBinaryTest.php index d02e33300..5e80c54d7 100644 --- a/src/Provider/IP2LocationBinary/Tests/IP2LocationBinaryTest.php +++ b/src/Provider/IP2LocationBinary/Tests/IP2LocationBinaryTest.php @@ -22,7 +22,7 @@ class IP2LocationBinaryTest extends BaseTestCase { private $binaryFile; - public function setUp() + public function setUp(): void { // Download this BIN database from https://lite.ip2location.com/database/ip-country-region-city-latitude-longitude-zipcode $this->binaryFile = __DIR__.'/fixtures/IP2LOCATION-LITE-DB9.IPV6.BIN'; @@ -33,7 +33,7 @@ protected function getCacheDir() return __DIR__.'/.cached_responses'; } - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { if (false == class_exists('\\IP2Location\\Database')) { self::markTestSkipped('The IP2Location\'s official library required to run these tests.'); diff --git a/src/Provider/IP2LocationBinary/Tests/IntegrationTest.php b/src/Provider/IP2LocationBinary/Tests/IntegrationTest.php index c4279005e..bc00d8e7b 100644 --- a/src/Provider/IP2LocationBinary/Tests/IntegrationTest.php +++ b/src/Provider/IP2LocationBinary/Tests/IntegrationTest.php @@ -32,7 +32,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testHttpProvider = false; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { if (false == class_exists('\\IP2Location\\Database')) { self::markTestSkipped('The IP2Location\'s official library required to run these tests.'); diff --git a/src/Provider/IpInfo/Tests/IpInfoTest.php b/src/Provider/IpInfo/Tests/IpInfoTest.php index 28d9a6335..e59d2cc0d 100644 --- a/src/Provider/IpInfo/Tests/IpInfoTest.php +++ b/src/Provider/IpInfo/Tests/IpInfoTest.php @@ -31,22 +31,20 @@ public function testGetName() $this->assertEquals('ip_info', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The IpInfo provider does not support street addresses, only IP addresses. - */ public function testGeocodeWithRandomString() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The IpInfo provider does not support street addresses, only IP addresses.'); + $provider = new IpInfo($this->getMockedHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('foobar')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The IpInfo provider does not support street addresses, only IP addresses. - */ public function testGeocodeWithAddress() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The IpInfo provider does not support street addresses, only IP addresses.'); + $provider = new IpInfo($this->getMockedHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); } @@ -79,11 +77,10 @@ public function provideLocalhostIps() yield ['::1']; } - /** - * @expectedException \Geocoder\Exception\InvalidServerResponse - */ public function testGeocodeWithRealIPv4GetsNullContent() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $provider = new IpInfo($this->getMockedHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('74.125.45.100')); } @@ -130,12 +127,11 @@ public function testGeocodeWithRealIPv6() $this->assertNull($result->getTimezone()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The IpInfo provider is not able to do reverse geocoding. - */ public function testReverse() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The IpInfo provider is not able to do reverse geocoding.'); + $provider = new IpInfo($this->getMockedHttpClient()); $provider->reverseQuery(ReverseQuery::fromCoordinates(0, 0)); } diff --git a/src/Provider/IpInfoDb/Tests/IpInfoDbTest.php b/src/Provider/IpInfoDb/Tests/IpInfoDbTest.php index 5e73b9ad8..d32d7e7ec 100644 --- a/src/Provider/IpInfoDb/Tests/IpInfoDbTest.php +++ b/src/Provider/IpInfoDb/Tests/IpInfoDbTest.php @@ -25,12 +25,11 @@ protected function getCacheDir() return __DIR__.'/.cached_responses'; } - /** - * @expectedException \Geocoder\Exception\InvalidArgument - * @expectedExceptionMessage Invalid precision value "foo" (allowed values: "city", "country"). - */ public function testConstructWithInvalidPrecision() { + $this->expectException(\Geocoder\Exception\InvalidArgument::class); + $this->expectExceptionMessage('Invalid precision value "foo" (allowed values: "city", "country").'); + new IpInfoDb($this->getMockedHttpClient(), 'api_key', 'foo'); } @@ -40,22 +39,20 @@ public function testGetName() $this->assertEquals('ip_info_db', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The IpInfoDb provider does not support street addresses, only IPv4 addresses. - */ public function testGeocodeWithRandomString() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The IpInfoDb provider does not support street addresses, only IPv4 addresses.'); + $provider = new IpInfoDb($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('foobar')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The IpInfoDb provider does not support street addresses, only IPv4 addresses. - */ public function testGeocodeWithAddress() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The IpInfoDb provider does not support street addresses, only IPv4 addresses.'); + $provider = new IpInfoDb($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); } @@ -81,30 +78,27 @@ public function testGeocodeWithLocalhostIPv4() $this->assertEquals('localhost', $result->getCountry()->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The IpInfoDb provider does not support IPv6 addresses, only IPv4 addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The IpInfoDb provider does not support IPv6 addresses, only IPv4 addresses.'); + $provider = new IpInfoDb($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('::1')); } - /** - * @expectedException \Geocoder\Exception\InvalidServerResponse - */ public function testGeocodeWithRealIPv4GetsNullContent() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $provider = new IpInfoDb($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('74.125.45.100')); } - /** - * @expectedException \Geocoder\Exception\InvalidServerResponse - */ public function testGeocodeWithRealIPv4GetsEmptyContent() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $provider = new IpInfoDb($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('74.125.45.100')); } @@ -135,12 +129,11 @@ public function testGeocodeWithRealIPv4() $this->assertEquals('America/New_York', $result->getTimezone()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The IpInfoDb provider does not support IPv6 addresses, only IPv4 addresses. - */ public function testGeocodeWithRealIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The IpInfoDb provider does not support IPv6 addresses, only IPv4 addresses.'); + if (!isset($_SERVER['IPINFODB_API_KEY'])) { $this->markTestSkipped('You need to configure the IPINFODB_API_KEY value in phpunit.xml'); } @@ -177,12 +170,11 @@ public function testGetGeocodedDataWithCountryPrecision() $this->assertNull($result->getTimezone()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The IpInfoDb provider is not able to do reverse geocoding. - */ public function testReverse() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The IpInfoDb provider is not able to do reverse geocoding.'); + $provider = new IpInfoDb($this->getMockedHttpClient(), 'api_key'); $provider->reverseQuery(ReverseQuery::fromCoordinates(0, 0)); } diff --git a/src/Provider/Ipstack/Tests/IpstackTest.php b/src/Provider/Ipstack/Tests/IpstackTest.php index ebbcf33c0..6ebeecd18 100644 --- a/src/Provider/Ipstack/Tests/IpstackTest.php +++ b/src/Provider/Ipstack/Tests/IpstackTest.php @@ -33,21 +33,19 @@ public function testGetName() $this->assertEquals('ipstack', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage No API key provided. - */ public function testGeocodeWithNoKey() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('No API key provided.'); + $provider = new Ipstack($this->getMockedHttpClient(), ''); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Ipstack provider does not support street addresses. - */ public function testGeocodeWithAddress() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Ipstack provider does not support street addresses.'); + $provider = new Ipstack($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); } @@ -116,22 +114,20 @@ public function testGeocodeWithRealIPv4InFrench() $this->assertEquals('US', $result->getCountry()->getCode()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Ipstack provider is not able to do reverse geocoding. - */ public function testReverse() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Ipstack provider is not able to do reverse geocoding.'); + $provider = new Ipstack($this->getMockedHttpClient(), 'api_key'); $provider->reverseQuery(ReverseQuery::fromCoordinates(1, 2)); } - /** - * @expectedException \Geocoder\Exception\InvalidArgument - * @expectedExceptionMessage Invalid request (a required parameter is missing). - */ public function testGeocodeWith301Code() { + $this->expectException(\Geocoder\Exception\InvalidArgument::class); + $this->expectExceptionMessage('Invalid request (a required parameter is missing).'); + $json = <<<'JSON' {"success":false,"error":{"code":301}} JSON; @@ -139,12 +135,11 @@ public function testGeocodeWith301Code() $result = $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\InvalidArgument - * @expectedExceptionMessage Bulk requests are not supported on your plan. Please upgrade your subscription. - */ public function testGeocodeWith303Code() { + $this->expectException(\Geocoder\Exception\InvalidArgument::class); + $this->expectExceptionMessage('Bulk requests are not supported on your plan. Please upgrade your subscription.'); + $json = <<<'JSON' {"success":false,"error":{"code":303,"type":"batch_not_supported_on_plan","info":"Bulk requests are not supported on your plan. Please upgrade your subscription."}} JSON; @@ -152,12 +147,11 @@ public function testGeocodeWith303Code() $result = $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\QuotaExceeded - * @expectedExceptionMessage The maximum allowed amount of monthly API requests has been reached. - */ public function testGeocodeWith104Code() { + $this->expectException(\Geocoder\Exception\QuotaExceeded::class); + $this->expectExceptionMessage('The maximum allowed amount of monthly API requests has been reached.'); + $json = <<<'JSON' {"success":false,"error":{"code":104}} JSON; @@ -165,12 +159,11 @@ public function testGeocodeWith104Code() $result = $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage No API Key was specified or an invalid API Key was specified. - */ public function testGeocodeWith101Code() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('No API Key was specified or an invalid API Key was specified.'); + $json = <<<'JSON' {"success":false,"error":{"code":101,"type":"invalid_access_key","info":"You have not supplied a valid API Access Key. [Technical Support: support@apilayer.com]"}} JSON; diff --git a/src/Provider/LocationIQ/Tests/LocationIQTest.php b/src/Provider/LocationIQ/Tests/LocationIQTest.php index c6d38ffb9..829c93fa4 100644 --- a/src/Provider/LocationIQ/Tests/LocationIQTest.php +++ b/src/Provider/LocationIQ/Tests/LocationIQTest.php @@ -31,6 +31,8 @@ protected function getCacheDir() */ public function testGeocodeWithAddressGetsEmptyContent() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $provider = new LocationIQ($this->getMockedHttpClient(''), $_SERVER['LOCATIONIQ_API_KEY']); $provider->geocodeQuery(GeocodeQuery::create('Läntinen Pitkäkatu 35, Turku')); } @@ -40,6 +42,8 @@ public function testGeocodeWithAddressGetsEmptyContent() */ public function testGeocodeWithAddressGetsEmptyXML() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $emptyXML = <<<'XML' XML; diff --git a/src/Provider/MapQuest/Tests/MapQuestTest.php b/src/Provider/MapQuest/Tests/MapQuestTest.php index 60c18a969..478f9b858 100644 --- a/src/Provider/MapQuest/Tests/MapQuestTest.php +++ b/src/Provider/MapQuest/Tests/MapQuestTest.php @@ -73,8 +73,8 @@ public function testGeocodeWithRealAddress() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.866205, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.389089, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.866205, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.389089, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('10 Avenue Gambetta', $result->getStreetName()); $this->assertEquals(75020, $result->getPostalCode()); $this->assertEquals('Paris', $result->getLocality()); @@ -91,8 +91,8 @@ public function testGeocodeWithRealAddress() $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.810071, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.435937, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.810071, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.435937, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('10 Avenue Gambetta', $result->getStreetName()); $this->assertEquals(94700, $result->getPostalCode()); $this->assertEquals('Maisons-Alfort', $result->getLocality()); @@ -140,8 +140,8 @@ public function testGeocodeWithRealSpecificAddress() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(36.062933, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-86.672811, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(36.062933, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-86.672811, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Payne Road', $result->getStreetName()); $this->assertEquals('37013', $result->getPostalCode()); $this->assertEquals('Nashville', $result->getLocality()); @@ -172,8 +172,8 @@ public function testReverseWithRealCoordinates() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(54.0484068, $result->getCoordinates()->getLatitude(), '', 0.001); - $this->assertEquals(-2.7990345, $result->getCoordinates()->getLongitude(), '', 0.001); + $this->assertEqualsWithDelta(54.0484068, $result->getCoordinates()->getLatitude(), 0.001); + $this->assertEqualsWithDelta(-2.7990345, $result->getCoordinates()->getLongitude(), 0.001); $this->assertEquals('Collegian W.M.C.', $result->getStreetName()); $this->assertEquals('LA1 1NP', $result->getPostalCode()); $this->assertEquals('Lancaster', $result->getLocality()); @@ -205,8 +205,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = reset($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.374478, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(9.738553, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(52.374478, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(9.738553, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Region Hannover', $result->getAdminLevels()->get(2)->getName()); @@ -217,8 +217,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = next($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(18.384049, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-78.131485, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(18.384049, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-78.131485, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('', $result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); $this->assertEquals('Hanover', $result->getAdminLevels()->get(2)->getName()); @@ -228,8 +228,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = next($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(43.703622, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-72.288666, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(43.703622, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-72.288666, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Grafton County', $result->getAdminLevels()->get(2)->getName()); @@ -240,8 +240,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = next($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(39.806325, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-76.984273, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(39.806325, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-76.984273, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('York County', $result->getAdminLevels()->get(2)->getName()); @@ -252,8 +252,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = next($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(37.744783, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-77.446416, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(37.744783, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-77.446416, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Hanover County', $result->getAdminLevels()->get(2)->getName()); @@ -286,8 +286,8 @@ public function testGeocodeWithSpecificCity() /** @var Location $result */ $result = reset($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.374478, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(9.738553, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(52.374478, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(9.738553, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Region Hannover', $result->getAdminLevels()->get(2)->getName()); @@ -298,8 +298,8 @@ public function testGeocodeWithSpecificCity() /** @var Location $result */ $result = next($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(43.703622, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-72.288666, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(43.703622, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-72.288666, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Grafton County', $result->getAdminLevels()->get(2)->getName()); @@ -310,8 +310,8 @@ public function testGeocodeWithSpecificCity() /** @var Location $result */ $result = next($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(39.806325, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-76.984273, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(39.806325, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-76.984273, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('York County', $result->getAdminLevels()->get(2)->getName()); @@ -322,8 +322,8 @@ public function testGeocodeWithSpecificCity() /** @var Location $result */ $result = next($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(40.661764, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-75.412404, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(40.661764, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-75.412404, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Northampton County', $result->getAdminLevels()->get(2)->getName()); @@ -334,8 +334,8 @@ public function testGeocodeWithSpecificCity() /** @var Location $result */ $result = next($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(40.651401, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-75.440663, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(40.651401, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-75.440663, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Lehigh County', $result->getAdminLevels()->get(2)->getName()); @@ -370,8 +370,8 @@ public function testGeocodeWithSpecificCityAndBounds() $result = reset($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('17331', $result->getPostalCode()); - $this->assertEquals(39.806325, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-76.984273, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(39.806325, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-76.984273, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('York County', $result->getAdminLevels()->get(2)->getName()); @@ -382,8 +382,8 @@ public function testGeocodeWithSpecificCityAndBounds() /** @var Location $result */ $result = next($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(40.661764, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-75.412404, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(40.661764, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-75.412404, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Northampton County', $result->getAdminLevels()->get(2)->getName()); @@ -394,8 +394,8 @@ public function testGeocodeWithSpecificCityAndBounds() /** @var Location $result */ $result = next($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(40.651401, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-75.440663, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(40.651401, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-75.440663, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Lehigh County', $result->getAdminLevels()->get(2)->getName()); @@ -407,8 +407,8 @@ public function testGeocodeWithSpecificCityAndBounds() $result = next($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('20794:21076', $result->getPostalCode()); - $this->assertEquals(39.192885, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-76.724137, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(39.192885, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-76.724137, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Howard County', $result->getAdminLevels()->get(2)->getName()); @@ -419,8 +419,8 @@ public function testGeocodeWithSpecificCityAndBounds() /** @var Location $result */ $result = next($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.374478, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(9.738553, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(52.374478, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(9.738553, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Region Hannover', $result->getAdminLevels()->get(2)->getName()); @@ -444,8 +444,8 @@ public function testGeocodeWithCityDistrict() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(50.189062, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(8.636567, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(50.189062, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(8.636567, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Kalbacher Hauptstraße 10', $result->getStreetName()); $this->assertEquals(60437, $result->getPostalCode()); $this->assertEquals('Frankfurt', $result->getLocality()); @@ -461,42 +461,38 @@ public function testGeocodeWithCityDistrict() $this->assertNull($result->getTimezone()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The MapQuest provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The MapQuest provider does not support IP addresses, only street addresses.'); + $provider = new MapQuest($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The MapQuest provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The MapQuest provider does not support IP addresses, only street addresses.'); + $provider = new MapQuest($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('::1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The MapQuest provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The MapQuest provider does not support IP addresses, only street addresses.'); + $provider = new MapQuest($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The MapQuest provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The MapQuest provider does not support IP addresses, only street addresses.'); + $provider = new MapQuest($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('::ffff:74.200.247.59')); } diff --git a/src/Provider/Mapbox/Tests/MapboxTest.php b/src/Provider/Mapbox/Tests/MapboxTest.php index 71ad64068..9c1097309 100644 --- a/src/Provider/Mapbox/Tests/MapboxTest.php +++ b/src/Provider/Mapbox/Tests/MapboxTest.php @@ -38,40 +38,37 @@ public function testGetName() $this->assertEquals('mapbox', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - */ public function testGeocodeWithLocalhostIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Mapbox provider does not support IP addresses, only street addresses.'); + $provider = new Mapbox($this->getMockedHttpClient(), 'access_token'); $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Mapbox provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Mapbox provider does not support IP addresses, only street addresses.'); + $provider = new Mapbox($this->getMockedHttpClient(), 'access_token'); $provider->geocodeQuery(GeocodeQuery::create('::1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Mapbox provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIp() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Mapbox provider does not support IP addresses, only street addresses.'); + $provider = new Mapbox($this->getHttpClient(), 'access_token'); $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\QuotaExceeded - */ public function testGeocodeWithQuotaExceeded() { + $this->expectException(\Geocoder\Exception\QuotaExceeded::class); + $provider = new Mapbox($this->getMockedHttpClient('', 429), 'access_token'); $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); } @@ -152,11 +149,10 @@ public function testGeocodeWithRealAddress() $this->assertNull($result->getTimezone()); } - /** - * @expectedException \Geocoder\Exception\InvalidServerResponse - */ public function testReverse() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $provider = new Mapbox($this->getMockedHttpClient(), 'access_token'); $provider->reverseQuery(ReverseQuery::fromCoordinates(1, 2)); } @@ -187,11 +183,10 @@ public function testReverseWithRealCoordinates() $this->assertEquals('address.1085979616', $result->getId()); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - */ public function testGeocodeWithInvalidApiKey() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $provider = new Mapbox($this->getMockedHttpClient('', 403), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); } diff --git a/src/Provider/Mapzen/Tests/MapzenTest.php b/src/Provider/Mapzen/Tests/MapzenTest.php index 8339aea09..88984a344 100644 --- a/src/Provider/Mapzen/Tests/MapzenTest.php +++ b/src/Provider/Mapzen/Tests/MapzenTest.php @@ -67,8 +67,8 @@ public function testGeocodeWithRealAddress() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.521124, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.20360200000000001, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.521124, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.20360200000000001, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Acklam Road', $result->getStreetName()); $this->assertEquals('London', $result->getLocality()); $this->assertCount(4, $result->getAdminLevels()); @@ -93,8 +93,8 @@ public function testReverseWithRealCoordinates() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(54.048411999999999, $result->getCoordinates()->getLatitude(), '', 0.001); - $this->assertEquals(-2.7989549999999999, $result->getCoordinates()->getLongitude(), '', 0.001); + $this->assertEqualsWithDelta(54.048411999999999, $result->getCoordinates()->getLatitude(), 0.001); + $this->assertEqualsWithDelta(-2.7989549999999999, $result->getCoordinates()->getLongitude(), 0.001); $this->assertNull($result->getStreetNumber()); $this->assertEquals('Gage Street', $result->getStreetName()); $this->assertEquals('LA1 1UH', $result->getPostalCode()); @@ -139,8 +139,8 @@ public function testGeocodeWithCity() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(42.027323000000003, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-88.204203000000007, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(42.027323000000003, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-88.204203000000007, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNull($result->getLocality()); $this->assertCount(3, $result->getAdminLevels()); $this->assertEquals('United States', $result->getAdminLevels()->get(5)->getName()); @@ -150,8 +150,8 @@ public function testGeocodeWithCity() /** @var \Geocoder\Model\Address $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(18.393428, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-78.122906, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(18.393428, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-78.122906, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNull($result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Hanover', $result->getAdminLevels()->get(1)->getName()); @@ -160,8 +160,8 @@ public function testGeocodeWithCity() /** @var \Geocoder\Model\Address $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(39.192889999999998, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-76.724140000000006, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(39.192889999999998, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-76.724140000000006, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(4, $result->getAdminLevels()); $this->assertEquals('Hanover', $result->getAdminLevels()->get(3)->getName()); @@ -183,8 +183,8 @@ public function testGeocodeWithCityDistrict() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(50.189017, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(8.6367809999999992, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(50.189017, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(8.6367809999999992, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('10a', $result->getStreetNumber()); $this->assertEquals('Kalbacher Hauptstraße', $result->getStreetName()); $this->assertEquals(60437, $result->getPostalCode()); @@ -197,12 +197,11 @@ public function testGeocodeWithCityDistrict() $this->assertEquals('DEU', $result->getCountry()->getCode()); } - /** - * @expectedException \Geocoder\Exception\QuotaExceeded - * @expectedExceptionMessage Valid request but quota exceeded. - */ public function testGeocodeQuotaExceeded() { + $this->expectException(\Geocoder\Exception\QuotaExceeded::class); + $this->expectExceptionMessage('Valid request but quota exceeded.'); + $provider = new Mapzen( $this->getMockedHttpClient( '{ @@ -223,12 +222,11 @@ public function testGeocodeQuotaExceeded() $provider->geocodeQuery(GeocodeQuery::create('New York')); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage Invalid or missing api key. - */ public function testGeocodeInvalidApiKey() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('Invalid or missing api key.'); + $provider = new Mapzen( $this->getMockedHttpClient( '{ @@ -249,42 +247,38 @@ public function testGeocodeInvalidApiKey() $provider->geocodeQuery(GeocodeQuery::create('New York')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Mapzen provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Mapzen provider does not support IP addresses, only street addresses.'); + $provider = new Mapzen($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Mapzen provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Mapzen provider does not support IP addresses, only street addresses.'); + $provider = new Mapzen($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('::1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Mapzen provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Mapzen provider does not support IP addresses, only street addresses.'); + $provider = new Mapzen($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Mapzen provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Mapzen provider does not support IP addresses, only street addresses.'); + $provider = new Mapzen($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('::ffff:74.200.247.59')); } diff --git a/src/Provider/MaxMind/Tests/MaxMindTest.php b/src/Provider/MaxMind/Tests/MaxMindTest.php index 4c5eb2132..8824dcbe3 100644 --- a/src/Provider/MaxMind/Tests/MaxMindTest.php +++ b/src/Provider/MaxMind/Tests/MaxMindTest.php @@ -32,12 +32,11 @@ public function testGetName() $this->assertEquals('maxmind', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The MaxMind provider does not support street addresses, only IP addresses. - */ public function testGeocodeWithAddress() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The MaxMind provider does not support street addresses, only IP addresses.'); + $provider = new MaxMind($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); } @@ -72,22 +71,20 @@ public function testGeocodeWithLocalhostIPv6() $this->assertEquals('localhost', $result->getCountry()->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage Unknown MaxMind service foo - */ public function testGeocodeWithRealIPv4AndNotSupportedService() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('Unknown MaxMind service foo'); + $provider = new MaxMind($this->getMockedHttpClient(), 'api_key', 'foo'); $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage Unknown MaxMind service 12345 - */ public function testGeocodeWithRealIPv6AndNotSupportedService() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('Unknown MaxMind service 12345'); + $provider = new MaxMind($this->getMockedHttpClient(), 'api_key', '12345'); $provider->geocodeQuery(GeocodeQuery::create('::ffff:74.200.247.59')); } @@ -174,22 +171,20 @@ public function testGeocodeWithRealIPv4GetsFakeContent() $this->assertNull($result->getTimezone()); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage API Key provided is not valid. - */ public function testGeocodeWithRealIPv4AndInvalidApiKeyGetsFakeContent() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('API Key provided is not valid.'); + $provider = new MaxMind($this->getMockedHttpClient(',,,,,,,,,,INVALID_LICENSE_KEY'), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage API Key provided is not valid. - */ public function testGeocodeOmniServiceWithRealIPv6AndInvalidApiKeyGetsFakeContent() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('API Key provided is not valid.'); + $provider = new MaxMind( $this->getMockedHttpClient(',,,,,,,,,,,,,,,,,,,,,,,,INVALID_LICENSE_KEY'), 'api_key', @@ -198,32 +193,29 @@ public function testGeocodeOmniServiceWithRealIPv6AndInvalidApiKeyGetsFakeConten $provider->geocodeQuery(GeocodeQuery::create('::ffff:74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage API Key provided is not valid. - */ public function testGeocodeWithRealIPv4AndInvalidApiKey() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('API Key provided is not valid.'); + $provider = new MaxMind($this->getHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage API Key provided is not valid. - */ public function testGeocodeWithRealIPv4AndInvalidApiKeyGetsFakeContent2() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('API Key provided is not valid.'); + $provider = new MaxMind($this->getMockedHttpClient(',,,,,,,,,,LICENSE_REQUIRED'), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage API Key provided is not valid. - */ public function testGeocodeOmniServiceWithRealIPv6AndInvalidApiKeyGetsFakeContent2() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('API Key provided is not valid.'); + $provider = new MaxMind( $this->getMockedHttpClient(',,,,,,,,,,,,,,,,,,,,,,,INVALID_LICENSE_KEY'), 'api_key', @@ -254,11 +246,10 @@ public function testGeocodeOmniServiceWithRealIPv6GetsFakeContentWithIpNotFound( $this->assertEquals(0, $result->count()); } - /** - * @expectedException \Geocoder\Exception\InvalidServerResponse - */ public function testGeocodeGetsFakeContentWithInvalidData() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $provider = new MaxMind($this->getMockedHttpClient(',,,,,,,,,,'), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } @@ -399,12 +390,11 @@ public function testGeocodeOmniServiceWithRealIPv6WithSsl() $this->assertEquals('America/Denver', $result->getTimezone()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The MaxMind provider is not able to do reverse geocoding. - */ public function testReverse() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The MaxMind provider is not able to do reverse geocoding.'); + $provider = new MaxMind($this->getMockedHttpClient(), 'api_key'); $provider->reverseQuery(ReverseQuery::fromCoordinates(1, 2)); } diff --git a/src/Provider/MaxMindBinary/Tests/IntegrationTest.php b/src/Provider/MaxMindBinary/Tests/IntegrationTest.php index 4ee6f82bb..38d185b8d 100644 --- a/src/Provider/MaxMindBinary/Tests/IntegrationTest.php +++ b/src/Provider/MaxMindBinary/Tests/IntegrationTest.php @@ -32,7 +32,7 @@ class IntegrationTest extends ProviderIntegrationTest protected $testHttpProvider = false; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { if (false == function_exists('geoip_open')) { self::markTestSkipped('The maxmind\'s official lib required to run these tests.'); diff --git a/src/Provider/MaxMindBinary/Tests/MaxMindBinaryTest.php b/src/Provider/MaxMindBinary/Tests/MaxMindBinaryTest.php index d54e6e975..4083fc32a 100644 --- a/src/Provider/MaxMindBinary/Tests/MaxMindBinaryTest.php +++ b/src/Provider/MaxMindBinary/Tests/MaxMindBinaryTest.php @@ -23,7 +23,7 @@ class MaxMindBinaryTest extends BaseTestCase { private $binaryFile; - public function setUp() + public function setUp(): void { $this->binaryFile = __DIR__.'/fixtures/GeoLiteCity.dat'; } @@ -33,7 +33,7 @@ protected function getCacheDir() return __DIR__.'/.cached_responses'; } - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { if (false == function_exists('geoip_open')) { self::markTestSkipped('The maxmind\'s official lib required to run these tests.'); diff --git a/src/Provider/Nominatim/Tests/NominatimTest.php b/src/Provider/Nominatim/Tests/NominatimTest.php index e8dca80fb..412484dcd 100644 --- a/src/Provider/Nominatim/Tests/NominatimTest.php +++ b/src/Provider/Nominatim/Tests/NominatimTest.php @@ -26,32 +26,29 @@ protected function getCacheDir() return __DIR__.'/.cached_responses'; } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Nominatim provider does not support IP addresses. - */ public function testGeocodeWithLocalhostIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Nominatim provider does not support IP addresses.'); + $provider = Nominatim::withOpenStreetMapServer($this->getMockedHttpClient(), 'Geocoder PHP/Nominatim Provider/Nominatim Test'); $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Nominatim provider does not support IP addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Nominatim provider does not support IP addresses.'); + $provider = Nominatim::withOpenStreetMapServer($this->getMockedHttpClient(), 'Geocoder PHP/Nominatim Provider/Nominatim Test'); $provider->geocodeQuery(GeocodeQuery::create('::1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Nominatim provider does not support IP addresses. - */ public function testGeocodeWithRealIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Nominatim provider does not support IP addresses.'); + $provider = Nominatim::withOpenStreetMapServer($this->getHttpClient(), 'Geocoder PHP/Nominatim Provider/Nominatim Test'); $provider->geocodeQuery(GeocodeQuery::create('::ffff:88.188.221.14')); } @@ -92,8 +89,8 @@ public function testGeocodeWithRealAddress() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(50.896344, $result->getCoordinates()->getLatitude(), '', 0.00001); - $this->assertEquals(4.3605984, $result->getCoordinates()->getLongitude(), '', 0.00001); + $this->assertEqualsWithDelta(50.896344, $result->getCoordinates()->getLatitude(), 0.00001); + $this->assertEqualsWithDelta(4.3605984, $result->getCoordinates()->getLongitude(), 0.00001); $this->assertEquals('35', $result->getStreetNumber()); $this->assertEquals('Avenue Jean de Bologne - Jean de Bolognelaan', $result->getStreetName()); $this->assertEquals('1020', $result->getPostalCode()); @@ -143,8 +140,8 @@ public function testGeocodeWithViewbox() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(50.896344, $result->getCoordinates()->getLatitude(), '', 0.00001); - $this->assertEquals(4.3605984, $result->getCoordinates()->getLongitude(), '', 0.00001); + $this->assertEqualsWithDelta(50.896344, $result->getCoordinates()->getLatitude(), 0.00001); + $this->assertEqualsWithDelta(4.3605984, $result->getCoordinates()->getLongitude(), 0.00001); $this->assertEquals('35', $result->getStreetNumber()); $this->assertEquals('Avenue Jean de Bologne - Jean de Bolognelaan', $result->getStreetName()); $this->assertEquals('1020', $result->getPostalCode()); diff --git a/src/Provider/OpenCage/Tests/OpenCageTest.php b/src/Provider/OpenCage/Tests/OpenCageTest.php index de22fb282..be62b457d 100644 --- a/src/Provider/OpenCage/Tests/OpenCageTest.php +++ b/src/Provider/OpenCage/Tests/OpenCageTest.php @@ -61,8 +61,8 @@ public function testGeocodeWithRealAddress() /** @var OpenCageAddress $result */ $result = $results->first(); $this->assertInstanceOf(OpenCageAddress::class, $result); - $this->assertEquals(48.866205, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.389089, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.866205, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.389089, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); $this->assertEquals(48.863142699999997, $result->getBounds()->getSouth()); $this->assertEquals(2.3890394000000001, $result->getBounds()->getWest()); @@ -100,13 +100,13 @@ public function testReverseWithRealCoordinates() /** @var OpenCageAddress $result */ $result = $results->first(); $this->assertInstanceOf(OpenCageAddress::class, $result); - $this->assertEquals(54.0484068, $result->getCoordinates()->getLatitude(), '', 0.001); - $this->assertEquals(-2.7990345, $result->getCoordinates()->getLongitude(), '', 0.001); + $this->assertEqualsWithDelta(54.0484068, $result->getCoordinates()->getLatitude(), 0.001); + $this->assertEqualsWithDelta(-2.7990345, $result->getCoordinates()->getLongitude(), 0.001); $this->assertNotNull($result->getBounds()); - $this->assertEquals(54.0484068, $result->getBounds()->getSouth(), '', 0.001); - $this->assertEquals(-2.7998815, $result->getBounds()->getWest(), '', 0.001); - $this->assertEquals(54.049472, $result->getBounds()->getNorth(), '', 0.001); - $this->assertEquals(-2.7980925, $result->getBounds()->getEast(), '', 0.001); + $this->assertEqualsWithDelta(54.0484068, $result->getBounds()->getSouth(), 0.001); + $this->assertEqualsWithDelta(-2.7998815, $result->getBounds()->getWest(), 0.001); + $this->assertEqualsWithDelta(54.049472, $result->getBounds()->getNorth(), 0.001); + $this->assertEqualsWithDelta(-2.7980925, $result->getBounds()->getEast(), 0.001); $this->assertNull($result->getStreetNumber()); $this->assertEquals('Lancaster Gate', $result->getStreetName()); $this->assertEquals('LA1 1LZ', $result->getPostalCode()); @@ -157,8 +157,8 @@ public function testGeocodeWithCity() /** @var OpenCageAddress $result */ $result = $results->first(); $this->assertInstanceOf(OpenCageAddress::class, $result); - $this->assertEquals(52.374478, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(9.738553, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(52.374478, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(9.738553, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Region Hannover', $result->getAdminLevels()->get(2)->getName()); @@ -168,8 +168,8 @@ public function testGeocodeWithCity() /** @var OpenCageAddress $result */ $result = $results->get(1); $this->assertInstanceOf(OpenCageAddress::class, $result); - $this->assertEquals(18.3840489, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-78.131485, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(18.3840489, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-78.131485, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNull($result->getLocality()); $this->assertTrue($result->getAdminLevels()->has(2)); $this->assertEquals('Hanover', $result->getAdminLevels()->get(2)->getName()); @@ -178,8 +178,8 @@ public function testGeocodeWithCity() /** @var OpenCageAddress $result */ $result = $results->get(2); $this->assertInstanceOf(OpenCageAddress::class, $result); - $this->assertEquals(43.7033073, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-72.2885663, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(43.7033073, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-72.2885663, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Grafton County', $result->getAdminLevels()->get(2)->getName()); @@ -202,8 +202,8 @@ public function testGeocodeWithCityDistrict() /** @var OpenCageAddress $result */ $result = $results->first(); $this->assertInstanceOf(OpenCageAddress::class, $result); - $this->assertEquals(50.189062, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(8.636567, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(50.189062, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(8.636567, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals(10, $result->getStreetNumber()); $this->assertEquals('Kalbacher Hauptstraße', $result->getStreetName()); $this->assertEquals(60437, $result->getPostalCode()); @@ -292,12 +292,11 @@ public function testAmbiguousResultProximity() $this->assertEquals('US', $result->getCountry()->getCode()); } - /** - * @expectedException \Geocoder\Exception\QuotaExceeded - * @expectedExceptionMessage Valid request but quota exceeded. - */ public function testGeocodeQuotaExceeded() { + $this->expectException(\Geocoder\Exception\QuotaExceeded::class); + $this->expectExceptionMessage('Valid request but quota exceeded.'); + $provider = new OpenCage( $this->getMockedHttpClient( '{ @@ -312,12 +311,11 @@ public function testGeocodeQuotaExceeded() $provider->geocodeQuery(GeocodeQuery::create('New York')); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage Invalid or missing api key. - */ public function testGeocodeInvalidApiKey() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('Invalid or missing api key.'); + $provider = new OpenCage( $this->getMockedHttpClient( '{ @@ -332,42 +330,38 @@ public function testGeocodeInvalidApiKey() $provider->geocodeQuery(GeocodeQuery::create('New York')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The OpenCage provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The OpenCage provider does not support IP addresses, only street addresses.'); + $provider = new OpenCage($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The OpenCage provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The OpenCage provider does not support IP addresses, only street addresses.'); + $provider = new OpenCage($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('::1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The OpenCage provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The OpenCage provider does not support IP addresses, only street addresses.'); + $provider = new OpenCage($this->getHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The OpenCage provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The OpenCage provider does not support IP addresses, only street addresses.'); + $provider = new OpenCage($this->getHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('::ffff:74.200.247.59')); } diff --git a/src/Provider/OpenRouteService/Tests/OpenRouteServiceTest.php b/src/Provider/OpenRouteService/Tests/OpenRouteServiceTest.php index 01cc964d2..8ac25d555 100644 --- a/src/Provider/OpenRouteService/Tests/OpenRouteServiceTest.php +++ b/src/Provider/OpenRouteService/Tests/OpenRouteServiceTest.php @@ -55,8 +55,8 @@ public function testGeocodeWithRealAddress() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.521124, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.20360200000000001, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.521124, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.20360200000000001, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Acklam Road', $result->getStreetName()); $this->assertEquals('London', $result->getLocality()); $this->assertCount(4, $result->getAdminLevels()); @@ -80,8 +80,8 @@ public function testReverseWithRealCoordinates() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(54.048411999999999, $result->getCoordinates()->getLatitude(), '', 0.001); - $this->assertEquals(-2.7989549999999999, $result->getCoordinates()->getLongitude(), '', 0.001); + $this->assertEqualsWithDelta(54.048411999999999, $result->getCoordinates()->getLatitude(), 0.001); + $this->assertEqualsWithDelta(-2.7989549999999999, $result->getCoordinates()->getLongitude(), 0.001); $this->assertEquals(1, $result->getStreetNumber()); $this->assertEquals('Gage Street', $result->getStreetName()); $this->assertEquals('LA1 1UH', $result->getPostalCode()); @@ -126,8 +126,8 @@ public function testGeocodeWithCity() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.379952, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(9.787455, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(52.379952, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(9.787455, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(4, $result->getAdminLevels()); $this->assertEquals('Niedersachsen', $result->getAdminLevels()->get(1)->getName()); @@ -137,8 +137,8 @@ public function testGeocodeWithCity() /** @var \Geocoder\Model\Address $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.37362, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(9.73711, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(52.37362, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(9.73711, $result->getCoordinates()->getLongitude(), 0.01); $this->assertCount(3, $result->getAdminLevels()); $this->assertEquals('Niedersachsen', $result->getAdminLevels()->get(1)->getName()); $this->assertEquals('Germany', $result->getCountry()->getName()); @@ -146,8 +146,8 @@ public function testGeocodeWithCity() /** @var \Geocoder\Model\Address $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(18.393428, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-78.107687, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(18.393428, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-78.107687, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNull($result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Hanover', $result->getAdminLevels()->get(1)->getName()); @@ -156,8 +156,8 @@ public function testGeocodeWithCity() /** @var \Geocoder\Model\Address $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(39.192889999999998, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-76.724140000000006, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(39.192889999999998, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-76.724140000000006, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(4, $result->getAdminLevels()); $this->assertEquals('Hanover', $result->getAdminLevels()->get(3)->getName()); @@ -179,8 +179,8 @@ public function testGeocodeWithCityDistrict() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(50.189017, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(8.6367809999999992, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(50.189017, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(8.6367809999999992, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('10a', $result->getStreetNumber()); $this->assertEquals('Kalbacher Hauptstraße', $result->getStreetName()); $this->assertEquals(60437, $result->getPostalCode()); @@ -193,12 +193,11 @@ public function testGeocodeWithCityDistrict() $this->assertEquals('DEU', $result->getCountry()->getCode()); } - /** - * @expectedException \Geocoder\Exception\QuotaExceeded - * @expectedExceptionMessage Valid request but quota exceeded. - */ public function testGeocodeQuotaExceeded() { + $this->expectException(\Geocoder\Exception\QuotaExceeded::class); + $this->expectExceptionMessage('Valid request but quota exceeded.'); + $provider = new OpenRouteService( $this->getMockedHttpClient( '{ @@ -219,12 +218,11 @@ public function testGeocodeQuotaExceeded() $provider->geocodeQuery(GeocodeQuery::create('New York')); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage Invalid or missing api key. - */ public function testGeocodeInvalidApiKey() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('Invalid or missing api key.'); + $provider = new OpenRouteService( $this->getMockedHttpClient( '{ @@ -245,42 +243,38 @@ public function testGeocodeInvalidApiKey() $provider->geocodeQuery(GeocodeQuery::create('New York')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The openrouteservice provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The openrouteservice provider does not support IP addresses, only street addresses.'); + $provider = new OpenRouteService($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The openrouteservice provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The openrouteservice provider does not support IP addresses, only street addresses.'); + $provider = new OpenRouteService($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('::1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The openrouteservice provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The openrouteservice provider does not support IP addresses, only street addresses.'); + $provider = new OpenRouteService($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The openrouteservice provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithRealIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The openrouteservice provider does not support IP addresses, only street addresses.'); + $provider = new OpenRouteService($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('::ffff:74.200.247.59')); } diff --git a/src/Provider/Photon/Tests/PhotonTest.php b/src/Provider/Photon/Tests/PhotonTest.php index bf2202f99..ddc0f7692 100644 --- a/src/Provider/Photon/Tests/PhotonTest.php +++ b/src/Provider/Photon/Tests/PhotonTest.php @@ -24,32 +24,29 @@ protected function getCacheDir() return __DIR__.'/.cached_responses'; } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Photon provider does not support IP addresses. - */ public function testGeocodeWithLocalhostIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Photon provider does not support IP addresses.'); + $provider = Photon::withKomootServer($this->getMockedHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Photon provider does not support IP addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Photon provider does not support IP addresses.'); + $provider = Photon::withKomootServer($this->getMockedHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('::1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Photon provider does not support IP addresses. - */ public function testGeocodeWithRealIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Photon provider does not support IP addresses.'); + $provider = Photon::withKomootServer($this->getHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('::ffff:88.188.221.14')); } diff --git a/src/Provider/PickPoint/Tests/PickPointTest.php b/src/Provider/PickPoint/Tests/PickPointTest.php index fa95055d2..a82ba01ce 100644 --- a/src/Provider/PickPoint/Tests/PickPointTest.php +++ b/src/Provider/PickPoint/Tests/PickPointTest.php @@ -26,20 +26,18 @@ protected function getCacheDir() return __DIR__.'/.cached_responses'; } - /** - * @expectedException \Geocoder\Exception\InvalidServerResponse - */ public function testGeocodeWithAddressGetsEmptyContent() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $provider = new PickPoint($this->getMockedHttpClient(''), 'API-KEY'); $provider->geocodeQuery(GeocodeQuery::create('Läntinen Pitkäkatu 35, Turku')); } - /** - * @expectedException \Geocoder\Exception\InvalidServerResponse - */ public function testGeocodeWithAddressGetsEmptyXML() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $emptyXML = <<<'XML' XML; diff --git a/src/Provider/TomTom/Tests/TomTomTest.php b/src/Provider/TomTom/Tests/TomTomTest.php index 3e9f89c12..f7020daea 100644 --- a/src/Provider/TomTom/Tests/TomTomTest.php +++ b/src/Provider/TomTom/Tests/TomTomTest.php @@ -32,11 +32,10 @@ public function testGetName() $this->assertEquals('tomtom', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\InvalidServerResponse - */ public function testGeocodeWithAddress() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $provider = new TomTom($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('Tagensvej 47, 2200 København N')); } @@ -52,8 +51,8 @@ public function testGeocodeWithRealAddress() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(55.70, $result->getCoordinates()->getLatitude(), '', 0.001); - $this->assertEquals(12.5529, $result->getCoordinates()->getLongitude(), '', 0.001); + $this->assertEqualsWithDelta(55.70, $result->getCoordinates()->getLatitude(), 0.001); + $this->assertEqualsWithDelta(12.5529, $result->getCoordinates()->getLongitude(), 0.001); $this->assertNull($result->getBounds()); $this->assertEquals(47, $result->getStreetNumber()); $this->assertEquals('Tagensvej', $result->getStreetName()); @@ -78,60 +77,54 @@ public function testGeocodeWithRealAddressWithFrenchLocale() $this->assertInstanceOf('\Geocoder\Model\Address', $result); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The TomTom provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The TomTom provider does not support IP addresses, only street addresses.'); + $provider = new TomTom($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The TomTom provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The TomTom provider does not support IP addresses, only street addresses.'); + $provider = new TomTom($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('::1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The TomTom provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The TomTom provider does not support IP addresses, only street addresses.'); + $provider = new TomTom($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The TomTom provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The TomTom provider does not support IP addresses, only street addresses.'); + $provider = new TomTom($this->getMockedHttpClient(), 'api_key'); $provider->geocodeQuery(GeocodeQuery::create('::ffff:74.200.247.59')); } - /** - * @expectedException \Geocoder\Exception\InvalidCredentials - * @expectedExceptionMessage No API key provided - */ public function testWithoutApiKey() { + $this->expectException(\Geocoder\Exception\InvalidCredentials::class); + $this->expectExceptionMessage('No API key provided'); + new TomTom($this->getMockedHttpClient(), ''); } - /** - * @expectedException \Geocoder\Exception\InvalidServerResponse - */ public function testReverse() { + $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $provider = new TomTom($this->getMockedHttpClient(), 'api_key'); $provider->reverseQuery(ReverseQuery::fromCoordinates(1, 2)); } @@ -172,8 +165,8 @@ public function testReverseWithRealCoordinates() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.86323, $result->getCoordinates()->getLatitude(), '', 0.001); - $this->assertEquals(2.38877, $result->getCoordinates()->getLongitude(), '', 0.001); + $this->assertEqualsWithDelta(48.86323, $result->getCoordinates()->getLatitude(), 0.001); + $this->assertEqualsWithDelta(2.38877, $result->getCoordinates()->getLongitude(), 0.001); $this->assertNull($result->getBounds()); $this->assertEquals('Avenue Gambetta', $result->getStreetName()); $this->assertNull($result->getPostalCode()); @@ -200,8 +193,8 @@ public function testGeocodeWithRealCoordinates() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(56.52435, $result->getCoordinates()->getLatitude(), '', 0.001); - $this->assertEquals(10.06744, $result->getCoordinates()->getLongitude(), '', 0.001); + $this->assertEqualsWithDelta(56.52435, $result->getCoordinates()->getLatitude(), 0.001); + $this->assertEqualsWithDelta(10.06744, $result->getCoordinates()->getLongitude(), 0.001); $this->assertNull($result->getBounds()); $this->assertEquals(16, $result->getStreetNumber()); $this->assertEquals('Stabelsvej', $result->getStreetName()); diff --git a/src/Provider/Yandex/Tests/YandexTest.php b/src/Provider/Yandex/Tests/YandexTest.php index ca80db3cf..67d70e18f 100644 --- a/src/Provider/Yandex/Tests/YandexTest.php +++ b/src/Provider/Yandex/Tests/YandexTest.php @@ -36,22 +36,20 @@ public function testGetName() $this->assertEquals('yandex', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Yandex provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Yandex provider does not support IP addresses, only street addresses.'); + $provider = new Yandex($this->getMockedHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Yandex provider does not support IP addresses, only street addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Yandex provider does not support IP addresses, only street addresses.'); + $provider = new Yandex($this->getMockedHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('::1')); } @@ -85,13 +83,13 @@ public function testGeocodeWithRealAddress() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result); - $this->assertEquals(48.863277, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.389016, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.863277, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.389016, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(48.861926, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(2.386967, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(48.864629, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(2.391064, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(48.861926, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(2.386967, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(48.864629, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(2.391064, $result->getBounds()->getEast(), 0.01); $this->assertEquals(10, $result->getStreetNumber()); $this->assertEquals('Avenue Gambetta', $result->getStreetName()); $this->assertEquals('Париж', $result->getLocality()); @@ -120,13 +118,13 @@ public function testGeocodeWithRealAddressWithUALocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result); - $this->assertEquals(55.675676, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(12.585828, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(55.675676, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(12.585828, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(55.614999, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(12.45295, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(55.73259, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(12.65075, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(55.614999, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(12.45295, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(55.73259, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(12.65075, $result->getBounds()->getEast(), 0.01); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); $this->assertEquals('Копенгаген', $result->getLocality()); @@ -147,14 +145,14 @@ public function testGeocodeWithRealAddressWithUALocale() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result); - $this->assertEquals(55.716853, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(12.463837, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(55.716853, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(12.463837, $result->getCoordinates()->getLongitude(), 0.01); /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result); - $this->assertEquals(55.590338, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(12.130041, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(55.590338, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(12.130041, $result->getCoordinates()->getLongitude(), 0.01); } public function testGeocodeWithRealAddressWithUSLocale() @@ -168,13 +166,13 @@ public function testGeocodeWithRealAddressWithUSLocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result); - $this->assertEquals(38.897695, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-77.038692, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(38.897695, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-77.038692, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(38.891265, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(-77.058105, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(38.904125, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(-77.012426, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(38.891265, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(-77.058105, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(38.904125, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(-77.012426, $result->getBounds()->getEast(), 0.01); $this->assertNull($result->getStreetNumber()); $this->assertEquals('Pennsylvania Avenue Northwest', $result->getStreetName()); $this->assertEquals('City of Washington', $result->getLocality()); @@ -203,13 +201,13 @@ public function testGeocodeWithRealAddressWithBYLocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result); - $this->assertEquals(53.898077, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(27.563673, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(53.898077, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(27.563673, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(53.896867, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(27.561624, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(53.899286, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(27.565721, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(53.896867, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(27.561624, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(53.899286, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(27.565721, $result->getBounds()->getEast(), 0.01); $this->assertEquals(19, $result->getStreetNumber()); $this->assertEquals('вуліца Леніна', $result->getStreetName()); $this->assertEquals('Мінск', $result->getLocality()); @@ -237,13 +235,13 @@ public function testReverseWithRealCoordinates() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result); - $this->assertEquals(48.863212, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.388773, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.863212, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.388773, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(48.86294, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(2.387497, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(48.866063, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(2.392833, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(48.86294, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(2.387497, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(48.866063, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(2.392833, $result->getBounds()->getEast(), 0.01); $this->assertEquals(1, $result->getStreetNumber()); $this->assertEquals('Avenue Gambetta', $result->getStreetName()); $this->assertEquals('Париж', $result->getLocality()); @@ -264,14 +262,14 @@ public function testReverseWithRealCoordinates() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result); - $this->assertEquals(48.864848, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.3993549, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.864848, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.3993549, $result->getCoordinates()->getLongitude(), 0.01); /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result); - $this->assertEquals(48.856929, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.392115, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.856929, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.392115, $result->getCoordinates()->getLongitude(), 0.01); } public function testReverseWithRealCoordinatesWithUSLocaleAndStreeToponym() @@ -285,13 +283,13 @@ public function testReverseWithRealCoordinatesWithUSLocaleAndStreeToponym() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result); - $this->assertEquals(48.87132, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.404017, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.87132, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.404017, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(48.86294, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(2.387497, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(48.877038, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(2.406587, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(48.86294, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(2.387497, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(48.877038, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(2.406587, $result->getBounds()->getEast(), 0.01); $this->assertNull($result->getStreetNumber()); $this->assertEquals('Avenue Gambetta', $result->getStreetName()); $this->assertEquals('20e Arrondissement', $result->getSubLocality()); @@ -312,26 +310,26 @@ public function testReverseWithRealCoordinatesWithUSLocaleAndStreeToponym() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result); - $this->assertEquals(48.863230, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.388261, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.863230, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.388261, $result->getCoordinates()->getLongitude(), 0.01); /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result); - $this->assertEquals(48.866022, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.389662, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.866022, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.389662, $result->getCoordinates()->getLongitude(), 0.01); /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result); - $this->assertEquals(48.863918, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.387767, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.863918, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.387767, $result->getCoordinates()->getLongitude(), 0.01); /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result); - $this->assertEquals(48.863787, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(2.389600, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(48.863787, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(2.389600, $result->getCoordinates()->getLongitude(), 0.01); } public function testReverseWithRealCoordinatesWithUALocaleAndHouseToponym() @@ -345,13 +343,13 @@ public function testReverseWithRealCoordinatesWithUALocaleAndHouseToponym() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result); - $this->assertEquals(60.454462, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(22.256561, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(60.454462, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(22.256561, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(60.45345, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(22.254513, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(60.455474, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(22.258609, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(60.45345, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(22.254513, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(60.455474, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(22.258609, $result->getBounds()->getEast(), 0.01); $this->assertEquals(35, $result->getStreetNumber()); $this->assertEquals('Läntinen Pitkäkatu', $result->getStreetName()); $this->assertNull($result->getLocality()); @@ -380,13 +378,13 @@ public function testReverseWithRealCoordinatesWithTRLocaleAndLocalityToponym() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result); - $this->assertEquals(41.01117, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(28.978151, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(41.01117, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(28.978151, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(40.795964, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(28.401361, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(41.224206, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(29.420984, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(40.795964, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(28.401361, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(41.224206, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(29.420984, $result->getBounds()->getEast(), 0.01); $this->assertNull($result->getStreetName()); $this->assertNull($result->getStreetNumber()); $this->assertEquals('İstanbul', $result->getLocality()); From 38cea378746c4d6ce7f2207c50c2c8d53119152c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Beli=C3=ABn?= Date: Fri, 18 Dec 2020 20:25:29 +0100 Subject: [PATCH 5/8] Drop PHP 7.2 support --- composer.json | 2 +- src/Http/composer.json | 2 +- src/Plugin/composer.json | 2 +- src/Provider/AlgoliaPlaces/composer.json | 2 +- src/Provider/ArcGISOnline/composer.json | 2 +- src/Provider/AzureMaps/composer.json | 2 +- src/Provider/BingMaps/composer.json | 2 +- src/Provider/Cache/composer.json | 2 +- src/Provider/Chain/composer.json | 2 +- src/Provider/FreeGeoIp/composer.json | 2 +- src/Provider/GeoIP2/composer.json | 2 +- src/Provider/GeoIPs/composer.json | 2 +- src/Provider/GeoPlugin/composer.json | 2 +- src/Provider/GeocodeEarth/composer.json | 2 +- src/Provider/Geoip/composer.json | 2 +- src/Provider/Geonames/composer.json | 2 +- src/Provider/GoogleMaps/composer.json | 2 +- src/Provider/GoogleMapsPlaces/composer.json | 2 +- src/Provider/GraphHopper/composer.json | 2 +- src/Provider/Here/composer.json | 2 +- src/Provider/HostIp/composer.json | 2 +- src/Provider/IP2Location/composer.json | 2 +- src/Provider/IP2LocationBinary/composer.json | 2 +- src/Provider/IpInfo/composer.json | 2 +- src/Provider/IpInfoDb/composer.json | 2 +- src/Provider/Ipstack/composer.json | 2 +- src/Provider/LocationIQ/composer.json | 2 +- src/Provider/MapQuest/composer.json | 2 +- src/Provider/Mapbox/composer.json | 2 +- src/Provider/Mapzen/composer.json | 2 +- src/Provider/MaxMind/composer.json | 2 +- src/Provider/MaxMindBinary/composer.json | 2 +- src/Provider/Nominatim/composer.json | 2 +- src/Provider/OpenCage/composer.json | 2 +- src/Provider/OpenRouteService/composer.json | 2 +- src/Provider/Pelias/composer.json | 2 +- src/Provider/Photon/composer.json | 2 +- src/Provider/PickPoint/composer.json | 2 +- src/Provider/TomTom/composer.json | 2 +- src/Provider/Yandex/composer.json | 2 +- 40 files changed, 40 insertions(+), 40 deletions(-) diff --git a/composer.json b/composer.json index 20d6ecdad..f25b20e6a 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "igorw/get-in": "^1.0", "php-http/client-implementation": "^1.0", "php-http/discovery": "^1.4", diff --git a/src/Http/composer.json b/src/Http/composer.json index 010ef4ede..ac59cc196 100644 --- a/src/Http/composer.json +++ b/src/Http/composer.json @@ -14,7 +14,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "php-http/client-implementation": "^1.0", "php-http/discovery": "^1.6", "php-http/httplug": "^1.0 || ^2.0", diff --git a/src/Plugin/composer.json b/src/Plugin/composer.json index 4b6944eca..069d70fa2 100644 --- a/src/Plugin/composer.json +++ b/src/Plugin/composer.json @@ -14,7 +14,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "php-http/promise": "^1.0", "psr/log": "^1.0", "psr/simple-cache": "^1.0", diff --git a/src/Provider/AlgoliaPlaces/composer.json b/src/Provider/AlgoliaPlaces/composer.json index 4143c2352..35b327466 100644 --- a/src/Provider/AlgoliaPlaces/composer.json +++ b/src/Provider/AlgoliaPlaces/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "ext-json": "*", "geocoder-php/common-http": "^4.1", "willdurand/geocoder": "^4.0" diff --git a/src/Provider/ArcGISOnline/composer.json b/src/Provider/ArcGISOnline/composer.json index 790bcf14f..31f9b389c 100644 --- a/src/Provider/ArcGISOnline/composer.json +++ b/src/Provider/ArcGISOnline/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/AzureMaps/composer.json b/src/Provider/AzureMaps/composer.json index da476e190..56f79f9f7 100644 --- a/src/Provider/AzureMaps/composer.json +++ b/src/Provider/AzureMaps/composer.json @@ -11,7 +11,7 @@ ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/BingMaps/composer.json b/src/Provider/BingMaps/composer.json index 0c37d3aa5..3539b350f 100644 --- a/src/Provider/BingMaps/composer.json +++ b/src/Provider/BingMaps/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Cache/composer.json b/src/Provider/Cache/composer.json index 6240a9cf8..1af5a375b 100644 --- a/src/Provider/Cache/composer.json +++ b/src/Provider/Cache/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "psr/simple-cache": "^1.0", "willdurand/geocoder": "^4.0.0" }, diff --git a/src/Provider/Chain/composer.json b/src/Provider/Chain/composer.json index d76c7d97d..17fb56b5d 100644 --- a/src/Provider/Chain/composer.json +++ b/src/Provider/Chain/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "psr/log": "^1.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/FreeGeoIp/composer.json b/src/Provider/FreeGeoIp/composer.json index 4984f79b3..6a99bd779 100644 --- a/src/Provider/FreeGeoIp/composer.json +++ b/src/Provider/FreeGeoIp/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.1", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/GeoIP2/composer.json b/src/Provider/GeoIP2/composer.json index 7eca795ba..c3f72fe2a 100644 --- a/src/Provider/GeoIP2/composer.json +++ b/src/Provider/GeoIP2/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geoip2/geoip2": "~2.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/GeoIPs/composer.json b/src/Provider/GeoIPs/composer.json index 3b10ca7fd..5471fafe4 100644 --- a/src/Provider/GeoIPs/composer.json +++ b/src/Provider/GeoIPs/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.1" }, diff --git a/src/Provider/GeoPlugin/composer.json b/src/Provider/GeoPlugin/composer.json index f77136362..ac4698f05 100644 --- a/src/Provider/GeoPlugin/composer.json +++ b/src/Provider/GeoPlugin/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "igorw/get-in": "^1.0", "willdurand/geocoder": "^4.0" diff --git a/src/Provider/GeocodeEarth/composer.json b/src/Provider/GeocodeEarth/composer.json index dac15856f..f40d11534 100644 --- a/src/Provider/GeocodeEarth/composer.json +++ b/src/Provider/GeocodeEarth/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "geocoder-php/pelias-provider": "^1.0", "willdurand/geocoder": "^4.0" diff --git a/src/Provider/Geoip/composer.json b/src/Provider/Geoip/composer.json index 3269ffd9a..0afb82787 100644 --- a/src/Provider/Geoip/composer.json +++ b/src/Provider/Geoip/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "ext-geoip": "*", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Geonames/composer.json b/src/Provider/Geonames/composer.json index b64c58f8e..3b0f2c4f6 100644 --- a/src/Provider/Geonames/composer.json +++ b/src/Provider/Geonames/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/GoogleMaps/composer.json b/src/Provider/GoogleMaps/composer.json index e0b98683e..475cb1aa5 100644 --- a/src/Provider/GoogleMaps/composer.json +++ b/src/Provider/GoogleMaps/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/GoogleMapsPlaces/composer.json b/src/Provider/GoogleMapsPlaces/composer.json index ed4aabffd..5ad5899f2 100644 --- a/src/Provider/GoogleMapsPlaces/composer.json +++ b/src/Provider/GoogleMapsPlaces/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/GraphHopper/composer.json b/src/Provider/GraphHopper/composer.json index 5850829de..0e4da85c9 100644 --- a/src/Provider/GraphHopper/composer.json +++ b/src/Provider/GraphHopper/composer.json @@ -6,7 +6,7 @@ "homepage": "http://geocoder-php.org/Geocoder/", "license": "MIT", "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Here/composer.json b/src/Provider/Here/composer.json index a722cd1f5..89db33af5 100644 --- a/src/Provider/Here/composer.json +++ b/src/Provider/Here/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/HostIp/composer.json b/src/Provider/HostIp/composer.json index f9b1c3d2b..271ebd1fd 100644 --- a/src/Provider/HostIp/composer.json +++ b/src/Provider/HostIp/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/IP2Location/composer.json b/src/Provider/IP2Location/composer.json index 256225139..9cfef0224 100644 --- a/src/Provider/IP2Location/composer.json +++ b/src/Provider/IP2Location/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/IP2LocationBinary/composer.json b/src/Provider/IP2LocationBinary/composer.json index cdb0605a5..83f64926e 100644 --- a/src/Provider/IP2LocationBinary/composer.json +++ b/src/Provider/IP2LocationBinary/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "ip2location/ip2location-php": "^8.1.1", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/IpInfo/composer.json b/src/Provider/IpInfo/composer.json index a680c8b33..64904a307 100644 --- a/src/Provider/IpInfo/composer.json +++ b/src/Provider/IpInfo/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/IpInfoDb/composer.json b/src/Provider/IpInfoDb/composer.json index 84c1ef694..52639d92e 100644 --- a/src/Provider/IpInfoDb/composer.json +++ b/src/Provider/IpInfoDb/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Ipstack/composer.json b/src/Provider/Ipstack/composer.json index c7905b35e..b5f5b1b12 100644 --- a/src/Provider/Ipstack/composer.json +++ b/src/Provider/Ipstack/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/LocationIQ/composer.json b/src/Provider/LocationIQ/composer.json index cffa315ad..ac44f1d4c 100644 --- a/src/Provider/LocationIQ/composer.json +++ b/src/Provider/LocationIQ/composer.json @@ -17,7 +17,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/MapQuest/composer.json b/src/Provider/MapQuest/composer.json index f19bea229..e5e7ca227 100644 --- a/src/Provider/MapQuest/composer.json +++ b/src/Provider/MapQuest/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Mapbox/composer.json b/src/Provider/Mapbox/composer.json index 27f998496..f9acbea1a 100644 --- a/src/Provider/Mapbox/composer.json +++ b/src/Provider/Mapbox/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Mapzen/composer.json b/src/Provider/Mapzen/composer.json index 78ec511ed..229d2ef33 100644 --- a/src/Provider/Mapzen/composer.json +++ b/src/Provider/Mapzen/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/MaxMind/composer.json b/src/Provider/MaxMind/composer.json index 491656290..8a83e4224 100644 --- a/src/Provider/MaxMind/composer.json +++ b/src/Provider/MaxMind/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "igorw/get-in": "^1.0", "willdurand/geocoder": "^4.1" }, diff --git a/src/Provider/MaxMindBinary/composer.json b/src/Provider/MaxMindBinary/composer.json index ae0b027cc..746f8d782 100644 --- a/src/Provider/MaxMindBinary/composer.json +++ b/src/Provider/MaxMindBinary/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geoip/geoip": "^1.17", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Nominatim/composer.json b/src/Provider/Nominatim/composer.json index d2df8d5bc..b41214d54 100644 --- a/src/Provider/Nominatim/composer.json +++ b/src/Provider/Nominatim/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.1", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/OpenCage/composer.json b/src/Provider/OpenCage/composer.json index 9e5eefb70..430db1b18 100644 --- a/src/Provider/OpenCage/composer.json +++ b/src/Provider/OpenCage/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/OpenRouteService/composer.json b/src/Provider/OpenRouteService/composer.json index 5f193064f..5c00883cb 100644 --- a/src/Provider/OpenRouteService/composer.json +++ b/src/Provider/OpenRouteService/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "geocoder-php/pelias-provider": "^1.0", "willdurand/geocoder": "^4.0" diff --git a/src/Provider/Pelias/composer.json b/src/Provider/Pelias/composer.json index 7b2ee693a..aedd6711d 100644 --- a/src/Provider/Pelias/composer.json +++ b/src/Provider/Pelias/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Photon/composer.json b/src/Provider/Photon/composer.json index 75bcd0ec6..2d0bcb1d6 100644 --- a/src/Provider/Photon/composer.json +++ b/src/Provider/Photon/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.1", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/PickPoint/composer.json b/src/Provider/PickPoint/composer.json index e981f1872..14fce989a 100644 --- a/src/Provider/PickPoint/composer.json +++ b/src/Provider/PickPoint/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/TomTom/composer.json b/src/Provider/TomTom/composer.json index ecf27af43..d5b4c1d66 100644 --- a/src/Provider/TomTom/composer.json +++ b/src/Provider/TomTom/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, diff --git a/src/Provider/Yandex/composer.json b/src/Provider/Yandex/composer.json index 038a5db00..9ea5852fb 100644 --- a/src/Provider/Yandex/composer.json +++ b/src/Provider/Yandex/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" }, From dfe727b9b78df7596e871aa4fbf89fb56515f0c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Beli=C3=ABn?= Date: Fri, 18 Dec 2020 20:27:27 +0100 Subject: [PATCH 6/8] Update GitHub Actions Remove PHP 7.2 --- .github/workflows/php.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 02f3da094..727a873f7 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -17,10 +17,7 @@ jobs: php-version: ['7.4', '8.0'] deps: ['low', 'high'] include: - - php-version: '7.2' - deps: null - php-version: '7.3' - deps: null name: PHP ${{ matrix.php-version }} (${{ matrix.deps }}) From 8c403d2b21898e04aa5b201fe45cd585bd0df004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Beli=C3=ABn?= Date: Fri, 18 Dec 2020 20:29:00 +0100 Subject: [PATCH 7/8] Update Travis CI Remove PHP 7.2 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b6490507f..7ffcddde4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,6 @@ matrix: env: deps="low" - php: 7.4 env: deps="high" - - php: 7.2 - php: 7.3 - php: 7.4 - php: 8.0 From 2647da4e869a779bcc447480626b02e800993815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Beli=C3=ABn?= Date: Sat, 19 Dec 2020 09:29:25 +0100 Subject: [PATCH 8/8] Drop PHP 7.2 support --- src/Common/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Common/composer.json b/src/Common/composer.json index d8e3cd9d8..e276831ad 100644 --- a/src/Common/composer.json +++ b/src/Common/composer.json @@ -17,7 +17,7 @@ } ], "require": { - "php": "^7.2 || ^8.0" + "php": "^7.3 || ^8.0" }, "require-dev": { "nyholm/nsa": "^1.1",