Serving resized S3 images on the fly
#3 Setting up PHPUnit and Psalm
Ensuring quality with unit tests and static analysis
3 min readAug 24, 2022
If you didn’t notice — this is part of a series
Setting up PHPUnit
With Flex it’s super easy to add PHPUnit to the project. Without further ado, let’s instruct the container do install the PHPUnit pack:
docker-compose exec php composer req --dev phpunit
That installed a bunch of libraries along with the PHPUnit. I don’t need the browser-kit
and the css-selector
and I’m going to ditch them:
docker-compose exec php composer rem symfony/browser-kit symfony/css-selector
The recipe for the PHPUnit pack added a number of additional files:
- the
bin/phpunit
script to execute tests phpunit.xml.dist
base configuration file- the
tests
directory with the bootstrap script
I have written some unit test already; let’s execute the suite:
docker-compose exec php bin/phpunit
That prints:
PHPUnit 9.5.23Testing
................... 19 / 19…