Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: GeoPHP tests

on:
push:
branches: ["development", "setup-github-action"]
pull_request:
branches: ["development", "setup-github-action"]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
php:
[
"5.6",
"7.0",
"7.1",
"7.2",
"7.3",
"7.4",
"8.0",
"8.1",
"8.2",
"8.3",
"nightly",
]

steps:
- uses: actions/checkout@v3

# - name: Validate composer.json and composer.lock
# run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

# want the ability to remove certain items for other flags ...

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run tests
run: |
mkdir -p build/logs
if [[ -z $DISABLE_UNIT ]]; then composer unit-clover; fi
composer test-input
composer performance
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/funiq/geoPHP.svg?branch=master)](https://travis-ci.org/funiq/geoPHP)
[![Build Status](https://github.com/funiq/geoPHP/actions/workflows/php/badge.svg)](https://github.com/waterfluence/geoPHP/actions/workflows/php.yml)

GeoPHP is a open-source native PHP library for doing geometry operations. It is a fork of famous [geoPHP](https://github.com/phayes/geoPHP) library by Patrick Hayes.

Expand Down
22 changes: 11 additions & 11 deletions tests/unit/Geometry/LineStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testConstructor($points)
public function testConstructorEmptyComponentThrowsException()
{
$this->expectException(InvalidGeometryException::class);
$this->expectExceptionMessageRegExp('/Cannot create a collection of empty Points.+/');
$this->expectExceptionMessageMatches('/Cannot create a collection of empty Points.+/');

// Empty points
new LineString([new Point(), new Point(), new Point()]);
Expand All @@ -66,23 +66,23 @@ public function testConstructorEmptyComponentThrowsException()
public function testConstructorNonArrayComponentThrowsException()
{
$this->expectException(InvalidGeometryException::class);
$this->expectExceptionMessageRegExp('/Component geometries must be passed as array/');
$this->expectExceptionMessageMatches('/Component geometries must be passed as array/');

new LineString('foo');
}

public function testConstructorSinglePointThrowsException()
{
$this->expectException(InvalidGeometryException::class);
$this->expectExceptionMessageRegExp('/Cannot construct a [a-zA-Z_\\\\]+LineString with a single point/');
$this->expectExceptionMessageMatches('/Cannot construct a [a-zA-Z_\\\\]+LineString with a single point/');

new LineString([new Point(1, 2)]);
}

public function testConstructorWrongComponentTypeThrowsException()
{
$this->expectException(InvalidGeometryException::class);
$this->expectExceptionMessageRegExp('/Cannot create a collection of [a-zA-Z_\\\\]+ components, expected type is.+/');
$this->expectExceptionMessageMatches('/Cannot create a collection of [a-zA-Z_\\\\]+ components, expected type is.+/');

new LineString([new LineString(), new LineString()]);
}
Expand Down Expand Up @@ -168,7 +168,7 @@ public function providerCentroid()
[42.5390625, 41.77131167976407],
[-13.359375, 38.8225909761771],
[18.984375, 17.644022027872726]
], new Point(8.71798087550578, 31.1304531386738)],
], new Point(8.717980875505775, 31.130453138673776)],
'crossing the antimeridian' => [[[170, 47], [-170, 47]], new Point(0, 47)]
];
}
Expand Down Expand Up @@ -217,7 +217,7 @@ public function testIsSimple($points, $result)
public function providerLength() {
return [
[[[0, 0], [10, 0]], 10.0],
[[[1, 1], [2, 2], [2, 3.5], [1, 3], [1, 2], [2, 1]], 6.44646111349608],
[[[1, 1], [2, 2], [2, 3.5], [1, 3], [1, 2], [2, 1]], 6.446461113496085],
];
}

Expand All @@ -236,8 +236,8 @@ public function testLength($points, $result)

public function providerLength3D() {
return [
[[[0, 0, 0], [10, 0, 10]], 14.142135623731],
[[[1, 1, 0], [2, 2, 2], [2, 3.5, 0], [1, 3, 2], [1, 2, 0], [2, 1, 2]], 11.926335310544],
[[[0, 0, 0], [10, 0, 10]], 14.142135623730951],
[[[1, 1, 0], [2, 2, 2], [2, 3.5, 0], [1, 3, 2], [1, 2, 0], [2, 1, 2]], 11.926335310544065],
];
}

Expand Down Expand Up @@ -305,7 +305,7 @@ public function testGreatCircleLength($points, $results)
{
$line = LineString::fromArray($points);

$this->assertEquals($line->greatCircleLength(), $results['greatCircle'], '', 1e-8);
$this->assertEqualsWithDelta($line->greatCircleLength(), $results['greatCircle'], 1e-8);
}

/**
Expand All @@ -318,7 +318,7 @@ public function testHaversineLength($points, $results)
{
$line = LineString::fromArray($points);

$this->assertEquals($line->haversineLength(), $results['haversine'], '', 1e-7);
$this->assertEqualsWithDelta($line->haversineLength(), $results['haversine'], 1e-7);
}

/**
Expand All @@ -331,7 +331,7 @@ public function testVincentyLength($points, $results)
{
$line = LineString::fromArray($points);

$this->assertEquals($line->vincentyLength(), $results['vincenty'], '', 1e-8);
$this->assertEqualsWithDelta($line->vincentyLength(), $results['vincenty'], 1e-8);
}

public function testVincentyLengthAntipodalPoints()
Expand Down