Skip to content

Commit 810f526

Browse files
committed
Add functional test cases for spatial type support in PostgreSQL
This commit adds functional testing for PostGIS spatial types (GEOMETRY and GEOGRAPHY) with schema introspection and CI integration. The implementation leverages PostgreSQL's native type system for introspection, making it compatible with any PostgreSQL instance without requiring PostGIS system tables to be accessible during schema operations.
1 parent 0c067f4 commit 810f526

File tree

8 files changed

+926
-2
lines changed

8 files changed

+926
-2
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,30 @@ jobs:
133133
extension: "pdo_pgsql"
134134
config-file-suffix: "-stringify_fetches"
135135

136+
phpunit-postgis:
137+
name: "PHPUnit with PostGIS"
138+
needs: "phpunit-smoke-check"
139+
uses: ./.github/workflows/phpunit-postgis.yml
140+
with:
141+
php-version: ${{ matrix.php-version }}
142+
postgis-version: ${{ matrix.postgis-version }}
143+
extension: ${{ matrix.extension }}
144+
145+
strategy:
146+
matrix:
147+
php-version:
148+
- "8.3"
149+
- "8.4"
150+
postgis-version:
151+
- "17-3.5"
152+
extension:
153+
- "pgsql"
154+
- "pdo_pgsql"
155+
include:
156+
- php-version: "8.2"
157+
postgis-version: "17-3.5"
158+
extension: "pgsql"
159+
136160
phpunit-mariadb:
137161
name: "PHPUnit with MariaDB"
138162
needs: "phpunit-smoke-check"
@@ -288,6 +312,7 @@ jobs:
288312
- "phpunit-smoke-check"
289313
- "phpunit-oracle"
290314
- "phpunit-postgres"
315+
- "phpunit-postgis"
291316
- "phpunit-mariadb"
292317
- "phpunit-mysql"
293318
- "phpunit-mssql"
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: PHPUnit with PostGIS
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
php-version:
7+
required: true
8+
type: string
9+
postgis-version:
10+
required: true
11+
type: string
12+
extension:
13+
required: true
14+
type: string
15+
postgres-locale-provider:
16+
required: true
17+
type: string
18+
config-file-suffix:
19+
required: false
20+
type: string
21+
default: ''
22+
23+
jobs:
24+
phpunit-postgis:
25+
runs-on: ubuntu-24.04
26+
27+
services:
28+
postgres:
29+
image: postgis/postgis:${{ inputs.postgis-version }}
30+
ports:
31+
- '5432:5432'
32+
env:
33+
POSTGRES_PASSWORD: postgres
34+
POSTGRES_INITDB_ARGS: ${{ inputs.postgres-locale-provider == 'icu' && '--locale-provider=icu --icu-locale=en-US' || '' }}
35+
options: >-
36+
--health-cmd pg_isready
37+
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
42+
- name: Install PHP
43+
uses: shivammathur/setup-php@v2
44+
with:
45+
php-version: ${{ inputs.php-version }}
46+
extensions: ${{ inputs.extension }}
47+
coverage: pcov
48+
ini-values: zend.assertions=1
49+
env:
50+
fail-fast: true
51+
52+
- name: Install dependencies with Composer
53+
uses: ramsey/composer-install@v3
54+
with:
55+
composer-options: '--ignore-platform-req=php+'
56+
57+
- name: Run PHPUnit
58+
run: vendor/bin/phpunit -c ci/github/phpunit/${{ inputs.extension }}${{ inputs.config-file-suffix }}.xml --coverage-clover=coverage.xml
59+
60+
- name: Upload coverage file
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: ${{ github.job }}-${{ inputs.postgis-version }}-php-${{ inputs.php-version }}-${{ inputs.extension }}${{ inputs.config-file-suffix }}.coverage
64+
path: coverage.xml

src/Schema/PostgreSQLSchemaManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ protected function _getPortableTableColumnDefinition(array $tableColumn): Column
313313
/**
314314
* Parses the parameters between parenthesis in the data type.
315315
*
316-
* @return list<int>
316+
* @return list<int|string>
317317
*/
318318
private function parseColumnTypeParameters(string $type): array
319319
{
@@ -328,7 +328,7 @@ private function parseColumnTypeParameters(string $type): array
328328
}
329329

330330
// Cast numeric strings to int automatically
331-
$parameters = array_map(function ($param) {
331+
$parameters = array_map(static function ($param) {
332332
return ctype_digit($param) ? (int) $param : $param;
333333
}, $parameters);
334334

0 commit comments

Comments
 (0)