I just work on a new Joomla 3 extension (I know Joomla 4 is out dont worry) and I would like to create unittests for several of my helper methods. Now I've spend the last two days reading all kind of documentations I could find, but I cant get it to work.
Main Problem: I cant get the phpunit to work so it recognizes my Joomla classes.
What I did so far:
I've setup a folder with some very easy phpunit tests to make the system run. I tryed the "phpunit" command with a phpunit.xml, but this always result in the following error:
Code: Select all
PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\php\pear\PHPUnit\TextUI\Command.php on line 277
I also try to bootstrap Joomla with files like those here:
https://github.com/joomla/test-integrat ... tstrap.php
Which I adjust for my personal usage, but all of those bootstrap files are several years old and might not work properly, even with my changes.
Since the "phpunit" command didnt work, I load this with ".\vendor\bin\phpunit .\tests\ --bootstrap .\bootstrap.php" or add a "require_once(__DIR__ . '/../../bootstrap.php');" to my PHPUnit Test files.
However... the class loading of Joomla Classes in the Testfiles don't work. I try to establish a very simple example with this Joomla method: "FilterOutput::stringURLSafe($test)", Just to see if the classes are loaded, but I cant get it to work.
Any input for any mentioned point here would be very helpful since I'm really kinda lost..
Thanks already ^^