Exercises for unit testing. This is a Symfony project, run on php 8. You should only focus on testing CalculatorController.
Tests should be written in tests/Calculator/CalculatorControllerTest.php
, where tests/Calculator/CalculatorControllerSolvedTest.php
is here if you get really stuck. You should be able to reach 94% coverage. More than that should not really possible in this controller.
But that's okay, as long as we get at least 80%. Note that you will have to make changes to the controller.
If you want to see code coverage, i highly suggest installing xdebug. This will display to you (un)covered lines.
- Install xdebug:
$ pecl install xdebug
- Open your
php.ini
file mine was in/usr/local/etc/php/8.0/php.ini
- Find
[xdebug]
-> if it's not there, just add it - Also add following lines under
[xdebug]
:zend_extension="xdebug.so"
,xdebug.mode="coverage"
I ran tests via PhpStorm IDE. I used local interpreter: /usr/local/Cellar/php@8.0/8.0.23_1/bin/php
. Right click on tests and select
run with code coverage
.