Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move providers to new namespace #604

Merged
merged 11 commits into from May 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .styleci.yml
Expand Up @@ -10,3 +10,4 @@ enabled:

disabled:
- phpdoc_annotation_without_dot # This is still buggy: https://github.com/symfony/symfony/pull/19198
- phpdoc_summary # Currenly some issues 2017-05-13
91 changes: 73 additions & 18 deletions .travis.yml
@@ -1,34 +1,89 @@
language: php
sudo: false

addons:
apt:
packages:
- libgeoip-dev

language: php
apt_packages:
- parallel
- libgeoip-dev

env:
global:
- deps=""

php:
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm
- MIN_PHP=5.5.9

matrix:
fast_finish: true
include:
- php: 5.5
env: deps="low"
- php: 5.5
- php: 5.6
- php: 7.0
- php: 7.1
- php: hhvm

before_script:
before_install:
- if [ "$TRAVIS_PHP_VERSION" != "hhvm" && "$TRAVIS_PHP_VERSION" != "7.0" ]; then pecl install geoip; fi
- composer self-update
- if [ "$deps" = "low" ]; then composer update --prefer-dist --prefer-lowest; fi
- if [ "$deps" = "" ]; then composer install --prefer-dist --no-interaction; fi
- if [ "$TRAVIS_PHP_VERSION" == "7.0" ]; then composer require "geoip/geoip"; fi
- |
# General configuration
stty cols 120
PHP=$TRAVIS_PHP_VERSION
[ -d ~/.composer ] || mkdir ~/.composer
export PHPUNIT=$(readlink -f ./phpunit)
export PHPUNIT_X="$PHPUNIT --exclude-group benchmark"
export COMPOSER_UP='composer update --no-progress --no-suggest --ansi'

# tfold is a helper to create folded reports
tfold () {
title=$1
fold=$(echo $title | sed -r 's/[^-_A-Za-z\d]+/./g')
shift
echo -e "travis_fold:start:$fold\\n\\e[1;34m$title\\e[0m"
bash -xc "$*" 2>&1 &&
echo -e "\\e[32mOK\\e[0m $title\\n\\ntravis_fold:end:$fold" ||
( echo -e "\\e[41mKO\\e[0m $title\\n" && exit 1 )
}
export -f tfold

# Matrix lines for intermediate PHP versions are skipped for pull requests
if [[ ! $deps && ! $PHP = ${MIN_PHP%.*} && ! $PHP = hhvm* && $TRAVIS_PULL_REQUEST != false ]]; then
deps=skip
skip=1
else
COMPONENTS=$(find src -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n')
fi

# php.ini configuration
if [[ $PHP = hhvm* ]]; then
INI=/etc/hhvm/php.ini
else
INI=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
phpenv config-rm xdebug.ini || echo "xdebug not available"
fi
echo memory_limit = -1 >> $INI

install:
- if [[ ! $skip ]]; then $COMPOSER_UP; fi
- |
run_tests () {
set -e
if [[ $skip ]]; then
echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"
elif [[ $deps = high ]]; then
echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP && $PHPUNIT_X$LEGACY'"
elif [[ $deps = low ]]; then
echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT_X'" &&
# Test the PhpUnit bridge on PHP 5.5, using the original phpunit script
tfold src/Symfony/Bridge/PhpUnit \
"cd src/Symfony/Bridge/PhpUnit && wget https://phar.phpunit.de/phpunit-4.8.phar && phpenv global 5.3 && composer update --no-progress --ansi && php phpunit-4.8.phar"
elif [[ $PHP = hhvm* ]]; then
$PHPUNIT --exclude-group benchmark,intl-data
else
echo "$COMPONENTS" | parallel --gnu "tfold {} $PHPUNIT_X {}"
tfold tty-group $PHPUNIT --group tty
fi
}

script:
- (run_tests)

script: ./vendor/bin/phpunit --coverage-text
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,7 @@ CHANGELOG
* Introduced `GeocodeQuery` and `ReverseQuery`.
* `Provider` and `Geocoder` interfaces has been updated to use query objects
* All providers are stateless and immutable.
* Moved **all** providers to new namespaces. Previous `Geocoder\Provider\BingMaps` is now located at `Geocoder\Provider\BingMaps\BingMaps`
* Added: Interface for `Geocoder\Model\AddressCollection` called `Geocoder\Collection`. Public APIs are updated to type hint for `Geocoder\GeocoderResult`.
* Added: Interface for `Geocoder\Model\Address` called `Geocoder\Location`. Public APIs are updated to type hint for `Geocoder\Location`.
* Added: GeoArray dumper
Expand Down
12 changes: 8 additions & 4 deletions composer.json
Expand Up @@ -21,12 +21,14 @@
"php-http/discovery": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"phpunit/phpunit": "^4.8 || ^5.4",
"symfony/phpunit-bridge": "^3.2",
"geoip2/geoip2": "~2.0",
"symfony/stopwatch": "~2.5",
"php-http/message": "^1.0",
"php-http/guzzle6-adapter": "^1.0",
"php-http/mock-client": "^0.3.0"
"php-http/curl-client": "^1.7",
"php-http/mock-client": "^0.3.0",
"guzzlehttp/psr7": "^1.4"
},
"suggest": {
"ext-geoip": "Enabling the geoip extension allows you to use the MaxMindProvider.",
Expand All @@ -35,7 +37,9 @@
"symfony/stopwatch": "If you want to use the TimedGeocoder"
},
"autoload": {
"psr-4": { "Geocoder\\": "src/" }
"psr-4": {
"Geocoder\\": ["src/Common", "src/"]
}
},
"autoload-dev": {
"psr-4": { "Geocoder\\Tests\\": "tests/" }
Expand Down
9 changes: 9 additions & 0 deletions phpunit
@@ -0,0 +1,9 @@
#!/usr/bin/env php
<?php

if (!file_exists(__DIR__.'/vendor/phpunit/phpunit/phpunit')) {
echo "Unable to find the `PHPUnit` script in `vendor/phpunit/phpunit/`.\nPlease run `composer update` before running this command.\n";
exit(1);
}

require __DIR__.'/vendor/phpunit/phpunit/phpunit';
14 changes: 14 additions & 0 deletions phpunit.xml.dist
Expand Up @@ -30,14 +30,28 @@
<!-- <server name="MAXMIND_API_KEY" value="YOUR_API_KEY" /> -->
<!-- <server name="IPINFODB_API_KEY" value="YOUR_API_KEY" /> -->
</php>

<testsuites>
<testsuite name="Geocoder Test Suite">
<directory>./tests/</directory>
<directory>./src/Common/Tests/</directory>
<directory>./src/Provider/*/Tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./src/</directory>
<exclude>
<directory>./src/Common/Tests</directory>
<directory>./src/Provider/*/Tests</directory>
<directory>./src/Common/vendor</directory>
<directory>./src/Provider/*/vendor</directory>
</exclude>
</whitelist>
</filter>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
</phpunit>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -34,7 +34,7 @@ class TimedGeocoderTest extends TestCase
protected function setUp()
{
$this->stopwatch = new Stopwatch();
$this->delegate = $this->getMock(Provider::class);
$this->delegate = $this->getMockBuilder(Provider::class)->getMock();
$this->geocoder = new TimedGeocoder($this->delegate, $this->stopwatch);
}

Expand Down
File renamed without changes.
47 changes: 47 additions & 0 deletions src/Common/composer.json
@@ -0,0 +1,47 @@
{
"name": "willdurand/geocoder",
"type": "library",
"description": "Common files for PHP Geocoder",
"keywords": ["geocoder", "geocoding", "abstraction", "geoip"],
"homepage": "http://geocoder-php.org",
"license": "MIT",
"authors": [
{
"name": "William Durand",
"email": "william.durand1@gmail.com"
}
],
"require": {
"php": "^5.5 || ^7.0",
"igorw/get-in": "^1.0",
"psr/http-message-implementation": "^1.0",
"php-http/client-implementation": "^1.0",
"php-http/message-factory": "^1.0.2",
"php-http/httplug": "^1.0",
"php-http/discovery": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"symfony/stopwatch": "~2.5",
"php-http/message": "^1.0",
"php-http/curl-client": "^1.7",
"php-http/mock-client": "^0.3.0",
"guzzlehttp/psr7": "^1.4"
},
"suggest": {
"symfony/stopwatch": "If you want to use the TimedGeocoder"
},
"autoload": {
"psr-4": {
"Geocoder\\": ""
}
},
"scripts": {
"test": "vendor/bin/phpunit"
},
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
}
}
28 changes: 28 additions & 0 deletions src/Common/phpunit.xml.dist
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<php>
<ini name="error_reporting" value="-1" />
</php>

<testsuites>
<testsuite name="Geocoder Test Suite">
<directory>./Tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
3 changes: 3 additions & 0 deletions src/Provider/ArcGISOnline/.gitignore
@@ -0,0 +1,3 @@
vendor/
composer.lock
phpunit.xml
Expand Up @@ -8,14 +8,16 @@
* @license MIT License
*/

namespace Geocoder\Provider;
namespace Geocoder\Provider\ArcGISOnline;

use Geocoder\Exception\InvalidArgument;
use Geocoder\Exception\InvalidServerResponse;
use Geocoder\Exception\UnsupportedOperation;
use Geocoder\Exception\ZeroResults;
use Geocoder\Model\Query\GeocodeQuery;
use Geocoder\Model\Query\ReverseQuery;
use Geocoder\Provider\AbstractHttpProvider;
use Geocoder\Provider\Provider;
use Http\Client\HttpClient;

/**
Expand Down
Expand Up @@ -8,13 +8,13 @@
* @license MIT License
*/

namespace Geocoder\Tests\Provider;
namespace Geocoder\Provider\ArcGISOnlineTest\Tests;

use Geocoder\Location;
use Geocoder\Model\Query\GeocodeQuery;
use Geocoder\Model\Query\ReverseQuery;
use Geocoder\Tests\TestCase;
use Geocoder\Provider\ArcGISOnline;
use Geocoder\Provider\ArcGISOnline\ArcGISOnline;

class ArcGISOnlineTest extends TestCase
{
Expand Down
37 changes: 37 additions & 0 deletions src/Provider/ArcGISOnline/composer.json
@@ -0,0 +1,37 @@
{
"name": "geocoder-php/arcgis-online-provider",
"type": "library",
"description": "Geocoder ArcGIS Online adapter",
"keywords": [],
"homepage": "http://geocoder-php.org/Geocoder/",
"license": "MIT",
"authors": [
{
"name": "William Durand",
"email": "william.durand1@gmail.com"
}
],
"require": {
"php": "^5.5 || ^7.0",
"willdurand/geocoder": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"php-http/message": "^1.0",
"php-http/curl-client": "^1.7",
"symfony/phpunit-bridge": "^3.2",
"guzzlehttp/psr7": "^1.4"
},
"autoload": {
"psr-4": { "Geocoder\\Provider\\ArcGISOnine\\": "" },
"exclude-from-classmap": [
"/Tests/"
]
},
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
}
}
28 changes: 28 additions & 0 deletions src/Provider/ArcGISOnline/phpunit.xml.dist
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<php>
<ini name="error_reporting" value="-1" />
</php>

<testsuites>
<testsuite name="Geocoder Test Suite">
<directory>./Tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
3 changes: 3 additions & 0 deletions src/Provider/BingMaps/.gitignore
@@ -0,0 +1,3 @@
vendor/
composer.lock
phpunit.xml