How to contribute
Running the Test Suite
The test suite of this library needs one or more databases, then it comes with a docker compose configuration.
[!NOTE] Docker and PHP installed locally (with
mysql
,pgsql
&mongodb
extensions) is required.
You can start the containers and run the test suite:
# start the container
$ docker compose up --detach
# install dependencies
$ composer update
# run test suite with all available permutations
$ composer test
# run only one permutation
$ vendor/bin/phpunit
# run test suite with dama/doctrine-test-bundle
$ vendor/bin/phpunit -c phpunit.dama.xml.dist
# run test suite with postgreSQL instead of MySQL
$ DATABASE_URL="postgresql://zenstruck:zenstruck@127.0.0.1:5433/zenstruck_foundry?serverVersion=15" vendor/bin/phpunit
Overriding the default configuration
You can override default environment variables by creating a .env.local
file, to easily enable permutations:
# .env.local
DATABASE_URL="postgresql://zenstruck:zenstruck@127.0.0.1:5433/zenstruck_foundry?serverVersion=15"
# run test suite with postgreSQL
$ vendor/bin/phpunit
The .env.local
file can also be used to override the port of the database containers,
if it does not meet your local requirements. You’ll also need to override docker compose configuration:
Here is an example to use MySQL on port 3308
:
# docker-compose.override.yml
version: '3.9'
services:
mysql:
ports:
- "3308:3306"
# .env.local
DATABASE_URL="mysql://root:1234@127.0.0.1:3308/foundry_test?serverVersion=5.7.42"
Credit
The AAA style of testing was first introduced to me by Adam Wathan’s excellent Test Driven Laravel Course. The inspiration for this libraries API comes from Laravel factories and christophrumpel/laravel-factories-reloaded.