Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/pest-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Tests coverage

on: [ push, pull_request ]

jobs:
test:
name: Pest - coverage

runs-on: ubuntu-latest

services:
mysql:
image: mysql:8.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: laravel_eloquent_spatial_test
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
coverage: xdebug

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

- name: Execute tests
env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
run: XDEBUG_MODE=coverage ./vendor/bin/pest --coverage --min=100
4 changes: 2 additions & 2 deletions .github/workflows/phpunit.yml → .github/workflows/pest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [ push, pull_request ]

jobs:
test:
name: PHPUnit - PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-version }}
name: Pest - PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-version }}

runs-on: ubuntu-latest

Expand Down Expand Up @@ -49,4 +49,4 @@ jobs:
- name: Execute tests
env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
run: vendor/bin/phpunit
run: vendor/bin/pest
26 changes: 0 additions & 26 deletions .github/workflows/phpinsights.yml

This file was deleted.

16 changes: 7 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"jubeki/laravel-code-style": "^1.0",
"nunomaduro/phpinsights": "^1.0|^2.0",
"nunomaduro/larastan": "^1.0|^2.0",
"orchestra/testbench": "^6.23|^7.0",
"phpunit/phpunit": "^9.3"
"pestphp/pest": "^1.21",
"pestphp/pest-plugin-laravel": "^1.2"
},
"autoload": {
"psr-4": {
"MatanYadaev\\EloquentSpatial\\": "src",
"MatanYadaev\\EloquentSpatial\\Database\\Factories\\": "database/factories"
"MatanYadaev\\EloquentSpatial\\": "src"
}
},
"autoload-dev": {
Expand All @@ -37,15 +36,14 @@
"scripts": {
"php-cs-fixer": "./vendor/bin/php-cs-fixer fix --allow-risky=yes",
"phpstan": "./vendor/bin/phpstan analyse --memory-limit=2G",
"phpunit": "./vendor/bin/phpunit --colors=always",
"phpunit-coverage": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-html coverage",
"phpinsights": "./vendor/bin/phpinsights",
"phpinsights-fix": "./vendor/bin/phpinsights fix"
"pest": "./vendor/bin/pest",
"pest-coverage": "XDEBUG_MODE=coverage ./vendor/bin/pest --coverage --min=100"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": false
"dealerdirect/phpcodesniffer-composer-installer": false,
"pestphp/pest-plugin": true
}
},
"minimum-stability": "dev",
Expand Down
157 changes: 0 additions & 157 deletions phpinsights.php

This file was deleted.

10 changes: 9 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ parameters:
- tests
level: max
ignoreErrors:
-
message: '#^Undefined variable\: \$this$#'
path: tests/*.php
-
message: '#^Call to an undefined method Pest\\Expectation\|Pest\\Support\\Extendable\:\:.+\(\)\.$#'
path: tests/*.php
-
message: '#^Access to an undefined property Pest\\Expectation\|Pest\\Support\\Extendable\:\:\$.+\.$#'
path: tests/*.php
excludePaths:
- ./src/Factory.php
checkMissingIterableValueType: true
checkGenericClassInNonGenericObjectType: false

10 changes: 10 additions & 0 deletions src/Objects/Geometry.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace MatanYadaev\EloquentSpatial\Objects;

use geoPHP;
use Illuminate\Contracts\Database\Eloquent\Castable;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Illuminate\Contracts\Support\Arrayable;
Expand All @@ -13,6 +14,7 @@
use JsonSerializable;
use MatanYadaev\EloquentSpatial\Factory;
use MatanYadaev\EloquentSpatial\GeometryCast;
use WKB as geoPHPWkb;

abstract class Geometry implements Castable, Arrayable, Jsonable, JsonSerializable
{
Expand All @@ -29,6 +31,14 @@ public function toJson($options = 0): string
return json_encode($this, $options | JSON_THROW_ON_ERROR);
}

public function toWkb(): string
{
$geoPHPGeometry = geoPHP::load($this->toWkt());

// @phpstan-ignore-next-line
return (new geoPHPWkb)->write($geoPHPGeometry, true);
}

/**
* @param string $wkb
* @return static
Expand Down
59 changes: 0 additions & 59 deletions tests/GeometryTest.php

This file was deleted.

Loading