diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 00000000..48a83bdb --- /dev/null +++ b/.github/workflows/php.yml @@ -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 diff --git a/README.md b/README.md index 3a87f485..e9765a46 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/tests/unit/Geometry/LineStringTest.php b/tests/unit/Geometry/LineStringTest.php index 7038440a..fbbe07f6 100644 --- a/tests/unit/Geometry/LineStringTest.php +++ b/tests/unit/Geometry/LineStringTest.php @@ -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()]); @@ -66,7 +66,7 @@ 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'); } @@ -74,7 +74,7 @@ public function testConstructorNonArrayComponentThrowsException() 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)]); } @@ -82,7 +82,7 @@ public function testConstructorSinglePointThrowsException() 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()]); } @@ -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)] ]; } @@ -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], ]; } @@ -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], ]; } @@ -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); } /** @@ -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); } /** @@ -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()