Skip to content

Commit

Permalink
Rework Travis file:
Browse files Browse the repository at this point in the history
* remove PHP 5.3 because of namespaces
* add PHP 7.0 and 7.1
* remove xdebug
* use phpunit from vendor and remove useless bootstrap file
  • Loading branch information
jmleroux committed Feb 8, 2017
1 parent 84fe82a commit cb029dc
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 24 deletions.
27 changes: 17 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,35 @@
# example available at https://github.com/travis-ci/travis-ci-php-example
language: php

before_script:
- composer self-update

env: GEOPHP_RUN_TESTS=1

cache:
directories:
- $HOME/.composer/cache

before_install:
- phpenv config-rm xdebug.ini

install:

install:
- composer install
- composer install --prefer-dist --no-interaction --no-scripts
# TODO Install geos library -- as a matrix test
# TODO optionally set up a postgis database for testing

script:
script:
- cd tests
- phpunit --verbose --colors --stderr tests
- ../vendor/bin/phpunit --verbose --colors --stderr tests
- php test.php

# run tests on the following versions
php:
- 5.6
- 5.5
- 5.4
- 5.3
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm

matrix:
fast_finish: false
7 changes: 6 additions & 1 deletion src/Adapters/GeoJSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,12 @@ public function write(Geometry $geometry, $return_array = false)
return ($return_array) ? $this->getArray($geometry) : json_encode($this->getArray($geometry));
}

public function getArray(Collection $geometry)
/**
* @param Geometry|Collection|Point $geometry
*
* @return array
*/
public function getArray(Geometry $geometry)
{
if ($geometry->getGeomType() == 'GeometryCollection') {
$component_array = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Adapters/KML.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private function geometryToKML($geom)
}
}

private function pointToKML(Collection $geom)
private function pointToKML(Geometry $geom)
{
$out = '<' . $this->nss . 'Point>';

Expand Down
13 changes: 8 additions & 5 deletions tests/test.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php

require __DIR__ . '/../vendor/autoload.php';

// Uncomment to test
use Phayes\GeoPHP\GeoPHP;

if (getenv("GEOPHP_RUN_TESTS") == 1) {
//if (getenv("GEOPHP_RUN_TESTS") == 1) {
run_test();
}
else {
print "Skipping tests. Please set GEOPHP_RUN_TESTS=1 environment variable if you wish to run tests\n";
}
//}
//else {
// print "Skipping tests. Please set GEOPHP_RUN_TESTS=1 environment variable if you wish to run tests\n";
//}

function run_test() {
set_time_limit(0);
Expand Down Expand Up @@ -125,6 +127,7 @@ function test_adapters(\Phayes\GeoPHP\Geometry\Geometry $geometry, $format, $inp
if ($adapter_key != 'google_geocode') { //Don't test google geocoder regularily. Uncomment to test
$output = $geometry->out($adapter_key);
if ($output) {
$adapter_class = '\Phayes\GeoPHP\Adapters\\' . $adapter_class;
$adapter_loader = new $adapter_class();
$test_geom_1 = $adapter_loader->read($output);
$test_geom_2 = $adapter_loader->read($test_geom_1->out($adapter_key));
Expand Down
7 changes: 0 additions & 7 deletions tests/tests/bootstrap.php

This file was deleted.

0 comments on commit cb029dc

Please sign in to comment.