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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Change Log

## 0.1.0 July 4, 2025
## 0.1.0 July 8, 2025

- Initial release
99 changes: 97 additions & 2 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,105 @@ 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
```shell
./vendor/bin/phpunit --group sqlite
```