Skip to content

sun-unit-test-training/php-unit-test-homework

Repository files navigation

PHP unit test training

Setup

cp .env.example .env
docker-compose up -d
docker-compose exec php composer install
docker-compose exec php chmod -R 777 storage bootstrap/cache
docker-compose exec php php artisan key:generate
docker-compose exec php php artisan migrate
docker-compose exec php php artisan module:seed Exercise03

Guide

To prevent conflict, each exercise is organized in its own folder with the help of package Laravel-Modules, for example Modules/Exercise01.

Start implementing and writing unit tests for each exercise.

Run phpunit

cp .env.testing.example .env.testing

Run all:

./phpunit.sh

Run all with coverage text:

./phpunit.sh --coverage-text

Run all with coverage html:

./phpunit.sh --coverage-html=coverage

Run only one module (see testsuites in phpunit.xml)

./phpunit.sh --coverage-html=coverage --testsuite=Exercise01

NOTE: You can edit file ./phpunit.sh to use other phpunit code coverage driver. pcov or phpdbg can generate code coverage much faster than xdebug. Please try!

Run infection

Run all:

./infection.sh

Run only one module:

./infection.sh --filter=Exercise01

Run only one file:

./infection.sh --filter=Modules/Exercise01/Http/Controllers/OrderController.php

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published