I’ve installed PhpUnit.phar and also in arch linux that I use I installed PHPUnit,. restarted VSCode but I always get this "PHP Fatal error: Uncaught Error: Class “PHPUnit\Framework\TestCase” not found in /home/owner/exercism/php/lasagna/LasagnaTest.php:20
Stack trace: #0 {main}
thrown in /home/owner/exercism/php/lasagna/LasagnaTest.php on line 20
"
Yes, i can do the exercises in the web browser but as I make progress maybe I’ll prefer to work in vscode. So … basically I want to configure vscode to seach and use the " use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\TestDox;"
statements correctly.
In VSCode, how do you “get this error”? Do you click on “execute this file”? You cannot run PHPUnit that way in VSCode…
PHPUnit is a standalone test-runner application, that must be run from the command line: php path/to/PhpUnit.phar LasagnaTest.php. If you followed the installation instructions and made the PHAR a global executable, you can shorten this to: phpunit LasagnaTest.php.
If you made PHPUnit run like that in a VSCode terminal, you are ready for the next step. You can add a task to VSCode that executes PHPUnit. Or you install one of many PHPUnit test explorer extensions (I use PHPUnit & Pest Test Explorer), that do the invocation part for you. But they all require, that PHPUnit can run from the commandline first.
It helps - now i’m much further along.
I now run the tests with phpunit xxxTest.php and i got the paths set up in the settings. I just didn’t see all the help files for it, but eventually I did. Just seemed at first like something was broken.
I also figured out exercism submit xxxx.php to come back if I don’t follow the test fail feedback well enough in CLI.