Skip to content

Commit d888b20

Browse files
feat: Enhance testing documentation with detailed instructions for database-specific testing and local development setup using docker. (#82)
1 parent e9d49c4 commit d888b20

File tree

2 files changed

+98
-3
lines changed

2 files changed

+98
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Change Log
22

3-
## 0.1.0 July 4, 2025
3+
## 0.1.0 July 8, 2025
44

55
- Initial release

docs/testing.md

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,105 @@ The code is statically analyzed with [PHPStan](https://phpstan.org/). To run sta
4141
composer run static
4242
```
4343

44-
## Unit tests
44+
## Unit Tests
4545

4646
The code is tested with [PHPUnit](https://phpunit.de/). To run tests.
4747

48-
```
48+
```shell
4949
composer run test
5050
```
51+
52+
### Database Testing
53+
54+
This package supports testing with multiple database systems to ensure compatibility across different environments.
55+
56+
- **MySQL** (8.0, 8.4, latest)
57+
- **Oracle** (23)
58+
- **PostgreSQL** (15, 16, 17)
59+
- **SQL Server** (2022-latest)
60+
- **SQLite** (default, in-memory) — No setup required
61+
62+
#### Database-Specific Testing
63+
64+
Run tests against specific database systems using PHPUnit groups.
65+
66+
```shell
67+
# MySQL
68+
./vendor/bin/phpunit --group mysql
69+
70+
# Oracle
71+
./vendor/bin/phpunit --group oci
72+
73+
# PostgreSQL
74+
./vendor/bin/phpunit --group pgsql
75+
76+
# SQL Server
77+
./vendor/bin/phpunit --group mssql
78+
79+
# SQLite (default - in-memory database)
80+
./vendor/bin/phpunit --group sqlite
81+
```
82+
83+
#### Local Development Setup
84+
85+
For local testing with real databases, you can use Docker.
86+
87+
##### MySQL
88+
```shell
89+
docker run -d --name mysql-test \
90+
-e MYSQL_ROOT_PASSWORD=root \
91+
-e MYSQL_DATABASE=yiitest \
92+
-p 3306:3306 \
93+
mysql:8.4
94+
95+
# Configure your database connection and run.
96+
./vendor/bin/phpunit --group mysql
97+
```
98+
99+
##### Oracle
100+
```shell
101+
docker run -d --name oracle-test \
102+
-e ORACLE_PASSWORD=root \
103+
-e ORACLE_DATABASE=yiitest \
104+
-p 1521:1521 \
105+
gvenzl/oracle-free:23
106+
107+
# Configure your database connection and run.
108+
./vendor/bin/phpunit --group oci
109+
```
110+
111+
##### PostgreSQL
112+
```shell
113+
docker run -d --name pgsql-test \
114+
-e POSTGRES_PASSWORD=root \
115+
-e POSTGRES_DB=yiitest \
116+
-e POSTGRES_USER=root \
117+
-p 5432:5432 \
118+
postgres:17
119+
120+
# Configure your database connection and run.
121+
./vendor/bin/phpunit --group pgsql
122+
```
123+
124+
##### SQL Server
125+
```shell
126+
docker run -d --name mssql-test \
127+
-e ACCEPT_EULA=Y \
128+
-e 'SA_PASSWORD=YourStrong!Passw0rd' \
129+
-e MSSQL_PID=Developer \
130+
-p 1433:1433 \
131+
mcr.microsoft.com/mssql/server:2022-latest
132+
133+
# Create test database.
134+
docker exec -it mssql-test /opt/mssql-tools18/bin/sqlcmd \
135+
-C -S localhost -U SA -P 'YourStrong!Passw0rd' \
136+
-Q "CREATE DATABASE yiitest;"
137+
138+
# Configure your database connection and run.
139+
./vendor/bin/phpunit --group mssql
140+
```
141+
142+
##### SQLite
143+
```shell
144+
./vendor/bin/phpunit --group sqlite
145+
```

0 commit comments

Comments
 (0)