From c8c2a173b2f064ebc2d218e91f0df92150ecd3e4 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Tue, 8 Jul 2025 18:46:55 -0400 Subject: [PATCH 1/3] feat: Enhance testing documentation with detailed instructions for database-specific testing and local development setup using docker. --- docs/testing.md | 101 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/docs/testing.md b/docs/testing.md index 2c92040..23ef47e 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -41,10 +41,107 @@ The code is statically analyzed with [PHPStan](https://phpstan.org/). To run sta composer run static ``` -## Unit tests +## Unit Tests The code is tested with [PHPUnit](https://phpunit.de/). To run tests. -``` +```shell composer run test ``` + +### Database Testing + +This package supports testing with multiple database systems to ensure compatibility across different environments. + +- **MySQL** (8.0, 8.4, latest). +- **Oracle** (23). +- **PostgreSQL** (15, 16, 17) . +- **SQL Server** (2022-latest). +- **SQLite** (default, in-memory) - No setup required. + +#### Database-Specific Testing + +Run tests against specific database systems using PHPUnit groups. + +```shell +# MySQL +./vendor/bin/phpunit --group mysql + +# Oracle +./vendor/bin/phpunit --group oci + +# PostgreSQL +./vendor/bin/phpunit --group pgsql + +# SQL Server +./vendor/bin/phpunit --group mssql + +# SQLite (default - in-memory database) +./vendor/bin/phpunit --group sqlite +``` + +#### Local Development Setup + +For local testing with real databases, you can use Docker. + +##### MySQL +```shell +docker run -d --name mysql-test \ + -e MYSQL_ROOT_PASSWORD=root \ + -e MYSQL_DATABASE=yiitest \ + -p 3306:3306 \ + mysql:8.4 + +# Configure your database connection and run. +./vendor/bin/phpunit --group mysql +``` + +##### Oracle +```shell +docker run -d --name oracle-test \ + -e ORACLE_PASSWORD=root \ + -e ORACLE_DATABASE=yiitest \ + -p 1521:1521 \ + gvenzl/oracle-free:23 + +# Configure your database connection and run. +./vendor/bin/phpunit --group oci +``` + +##### PostgreSQL +```shell +docker run -d --name pgsql-test \ + -e POSTGRES_PASSWORD=root \ + -e POSTGRES_DB=yiitest \ + -e POSTGRES_USER=root \ + -p 5432:5432 \ + postgres:17 + +# Configure your database connection and run. +./vendor/bin/phpunit --group pgsql +``` + +##### SQL Server +```shell +docker run -d --name mssql-test \ + -e ACCEPT_EULA=Y \ + -e SA_PASSWORD=YourStrong!Passw0rd \ + -e MSSQL_PID=Developer \ + -p 1433:1433 \ + mcr.microsoft.com/mssql/server:2022-latest + +# Create test database. +docker exec -it mssql-test /opt/mssql-tools18/bin/sqlcmd \ + -C -S localhost -U SA -P 'YourStrong!Passw0rd' \ + -Q "CREATE DATABASE yiitest;" + +# Configure your database connection and run. +./vendor/bin/phpunit --group mssql +``` + +##### SQLite +SQLite does not require any setup. It uses an in-memory database by default. You can run tests directly. + +```shell +./vendor/bin/phpunit --group sqlite +``` From 3b4cd6fb7c4d12eb29121a00b3c397a461754127 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Tue, 8 Jul 2025 18:52:46 -0400 Subject: [PATCH 2/3] fix: Update `CHANGELOG.md` date and improve formatting in testing documentation for database compatibility. --- CHANGELOG.md | 2 +- docs/testing.md | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a3fa4a..a4050d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # Change Log -## 0.1.0 July 4, 2025 +## 0.1.0 July 8, 2025 - Initial release diff --git a/docs/testing.md b/docs/testing.md index 23ef47e..f0d25a8 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -53,11 +53,11 @@ composer run test This package supports testing with multiple database systems to ensure compatibility across different environments. -- **MySQL** (8.0, 8.4, latest). -- **Oracle** (23). -- **PostgreSQL** (15, 16, 17) . -- **SQL Server** (2022-latest). -- **SQLite** (default, in-memory) - No setup required. +- **MySQL** (8.0, 8.4, latest) +- **Oracle** (23) +- **PostgreSQL** (15, 16, 17) +- **SQL Server** (2022-latest) +- **SQLite** (default, in-memory) - No setup required #### Database-Specific Testing @@ -125,7 +125,7 @@ docker run -d --name pgsql-test \ ```shell docker run -d --name mssql-test \ -e ACCEPT_EULA=Y \ - -e SA_PASSWORD=YourStrong!Passw0rd \ + -e 'SA_PASSWORD=YourStrong!Passw0rd' \ -e MSSQL_PID=Developer \ -p 1433:1433 \ mcr.microsoft.com/mssql/server:2022-latest From 03c884978d8b23b25e30cd28bfe7b36d318da739 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Tue, 8 Jul 2025 18:59:21 -0400 Subject: [PATCH 3/3] fix: Correct formatting in `SQLite` documentation and remove redundant setup note. --- docs/testing.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/testing.md b/docs/testing.md index f0d25a8..8d177b5 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -57,7 +57,7 @@ This package supports testing with multiple database systems to ensure compatibi - **Oracle** (23) - **PostgreSQL** (15, 16, 17) - **SQL Server** (2022-latest) -- **SQLite** (default, in-memory) - No setup required +- **SQLite** (default, in-memory) — No setup required #### Database-Specific Testing @@ -140,8 +140,6 @@ docker exec -it mssql-test /opt/mssql-tools18/bin/sqlcmd \ ``` ##### SQLite -SQLite does not require any setup. It uses an in-memory database by default. You can run tests directly. - ```shell ./vendor/bin/phpunit --group sqlite ```