diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 823ac00..3a57d64 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -32,6 +32,59 @@ jobs:
- name: Run tests
run: composer test
+ mariadb-test:
+ runs-on: ubuntu-latest
+
+ name: Test with MariaDB
+
+ services:
+ postgis:
+ image: mariadb:10
+ env:
+ MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: yes
+ MARIADB_DATABASE: sfa
+ MARIADB_USER: sfa
+ MARIADB_PASSWORD: sfa
+ ports:
+ - 3306:3306
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Install dependencies
+ uses: ramsey/composer-install@v2
+
+ - name: Run tests
+ run: composer test-maria
+
+
+ mysql-test:
+ runs-on: ubuntu-latest
+
+ name: Test with Mysql
+
+ services:
+ postgis:
+ image: mysql:8
+ env:
+ MYSQL_DATABASE: sfa
+ MYSQL_USER: sfa
+ MYSQL_PASSWORD: sfa
+ ports:
+ - 3306:3306
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Install dependencies
+ uses: ramsey/composer-install@v2
+
+ - name: Run tests
+ run: composer test-my
+
+
postgis-test:
runs-on: ubuntu-latest
@@ -49,7 +102,7 @@ jobs:
steps:
- name: Checkout code
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Install dependencies
uses: ramsey/composer-install@v2
diff --git a/composer.json b/composer.json
index 0a6b4ca..7bbfd0f 100644
--- a/composer.json
+++ b/composer.json
@@ -42,6 +42,8 @@
},
"scripts": {
"test": "XDEBUG_MODE=coverage phpunit --testsuite=DatabaseLess --coverage-text --colors --testdox",
+ "test-maria": "phpunit --testsuite=MariaIntegration --colors --testdox",
+ "test-my": "phpunit --testsuite=MyIntegration --colors --testdox",
"test-pg": "phpunit --testsuite=PGIntegration --colors --testdox",
"fix": "php-cs-fixer fix",
"cs": "@fix --dry-run --diff"
diff --git a/phpunit.xml b/phpunit.xml
index d091e69..0de756c 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -43,6 +43,12 @@
./tests/SQL
+
+ ./tests/Integration/MariaDB
+
+
+ ./tests/Integration/MySQL
+
./tests/Integration/PostGIS
diff --git a/tests/Integration/MariaDB/PDOTest.php b/tests/Integration/MariaDB/PDOTest.php
new file mode 100644
index 0000000..29198c7
--- /dev/null
+++ b/tests/Integration/MariaDB/PDOTest.php
@@ -0,0 +1,92 @@
+pdo = new PDO($dsn, 'sfa', 'sfa', [
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+ ]);
+ }
+
+ public function testConstructors(): void
+ {
+ $point = Sfc::point(23, 56, 4326);
+
+ $this->assertEquals(23, $this->selectVal($point->x()));
+ $this->assertEquals(56, $this->selectVal($point->y()));
+ $this->assertEquals(4326, $this->selectVal($point->srid()));
+ }
+
+ /**
+ * Let's produce a triangular hull around some points and check whether
+ * other geometries are inside the hull.
+ */
+ public function testComplexActions(): void
+ {
+ // Let's try various APIs
+ $points = [
+ Sfc::makePoint(0, 0),
+ new Point('ST_MakePoint(?, ?)', [0, 10]),
+ new Geometry("'POINT(5 5)'::geometry"),
+ ];
+
+ $hull = $points[0]->union($points[1])->union($points[2])->convexHull();
+
+ $this->assertSame('POLYGON((0 0,0 10,5 5,0 0))', $this->selectVal($hull->asText()));
+
+ $pointInside = Sfc::point(3, 5);
+ $pointOutside = Sfc::point(10, 10);
+ $this->assertTrue($this->selectVal(
+ $hull->contains($pointInside)
+ ));
+ $this->assertTrue($this->selectVal(
+ $pointInside->within($hull)
+ ));
+ $this->assertFalse($this->selectVal(
+ $hull->contains($pointOutside)
+ ));
+ $this->assertFalse($this->selectVal(
+ $pointOutside->within($hull)
+ ));
+
+ $line = Sfc::lineFromText('LINESTRING(3 3,10 10)');
+ $this->assertFalse($this->selectVal(
+ $hull->contains($line)
+ ));
+ $this->assertFalse($this->selectVal(
+ $line->within($hull)
+ ));
+ $this->assertTrue($this->selectVal(
+ $hull->intersects($line)
+ ));
+ $this->assertTrue($this->selectVal(
+ $line->intersects($hull)
+ ));
+ }
+
+
+ protected function selectVal(Expression $expression)
+ {
+ $query = $this->pdo->prepare("SELECT $expression as value");
+ $query->execute($expression->bindings);
+
+ return $query->fetch()['value'];
+ }
+}
diff --git a/tests/Integration/MySQL/PDOTest.php b/tests/Integration/MySQL/PDOTest.php
new file mode 100644
index 0000000..95bcf98
--- /dev/null
+++ b/tests/Integration/MySQL/PDOTest.php
@@ -0,0 +1,92 @@
+pdo = new PDO($dsn, 'sfa', 'sfa', [
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+ ]);
+ }
+
+ public function testConstructors(): void
+ {
+ $point = Sfc::point(23, 56, 4326);
+
+ $this->assertEquals(23, $this->selectVal($point->x()));
+ $this->assertEquals(56, $this->selectVal($point->y()));
+ $this->assertEquals(4326, $this->selectVal($point->srid()));
+ }
+
+ /**
+ * Let's produce a triangular hull around some points and check whether
+ * other geometries are inside the hull.
+ */
+ public function testComplexActions(): void
+ {
+ // Let's try various APIs
+ $points = [
+ Sfc::makePoint(0, 0),
+ new Point('ST_MakePoint(?, ?)', [0, 10]),
+ new Geometry("'POINT(5 5)'::geometry"),
+ ];
+
+ $hull = $points[0]->union($points[1])->union($points[2])->convexHull();
+
+ $this->assertSame('POLYGON((0 0,0 10,5 5,0 0))', $this->selectVal($hull->asText()));
+
+ $pointInside = Sfc::point(3, 5);
+ $pointOutside = Sfc::point(10, 10);
+ $this->assertTrue($this->selectVal(
+ $hull->contains($pointInside)
+ ));
+ $this->assertTrue($this->selectVal(
+ $pointInside->within($hull)
+ ));
+ $this->assertFalse($this->selectVal(
+ $hull->contains($pointOutside)
+ ));
+ $this->assertFalse($this->selectVal(
+ $pointOutside->within($hull)
+ ));
+
+ $line = Sfc::lineFromText('LINESTRING(3 3,10 10)');
+ $this->assertFalse($this->selectVal(
+ $hull->contains($line)
+ ));
+ $this->assertFalse($this->selectVal(
+ $line->within($hull)
+ ));
+ $this->assertTrue($this->selectVal(
+ $hull->intersects($line)
+ ));
+ $this->assertTrue($this->selectVal(
+ $line->intersects($hull)
+ ));
+ }
+
+
+ protected function selectVal(Expression $expression)
+ {
+ $query = $this->pdo->prepare("SELECT $expression as value");
+ $query->execute($expression->bindings);
+
+ return $query->fetch()['value'];
+ }
+}