I'm testing a set of classes that are loaded by a WordPress theme. ( autoload.php ) is included in functions.php. In production, everything works fine and all classes are loaded correctly.
I have the theme's folder mapped to a folder in VVV in the test WordPresssite. The composer.json uses PSR-4 to load the classes:
"autoload": {
"psr-4": {
"Compeer\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Compeer\\": "tests/wpunit/"
}
},
I have a series of tests that use the static methods from a class that lives inside src.
In order for these tests to work, I need to include:
require 'src/class-entitystates.php';
I can love with that, but when I try to use a class that relies on another class, I get an error:
PHP Fatal error: Class 'Compeer\Participant' not found in /srv/www/compeer-dev/public_html/wp-content/themes/compeer/vendor/scorpiotek/compeer-wordpress-classes-library/src/class-volunteer.php on line 14
This line is the definition of the Volunteer class:
class Volunteer extends Participant {
The participant class does exist, and like I said, works 100% in production.
If I include a line to load class directly:
require 'src/class-participant.php';
It works, but I don't want to do that, this is the sole reason of the autoload.
I'm clearly not loading the autoload.php file for my tests...I thought the theme loading the autoload.php would take care of this but clearly it's not.
Any ideas?