I am working on a CodeIgniter project and have installed PHPUnit to run unit tests. However, when I execute the tests, I encounter the following error for each test, including the example tests provided by PHPUnit:
Error: Call to undefined function CodeIgniter\Test\helper()
Here is an example of the error message:
There was 1 error:
Error: Call to undefined function CodeIgniter\Test\helper()
C:\xampp\htdocs\moduloNoticias\vendor\codeigniter4\framework\system\Test\CIUnitTestCase.php:234
I have followed the standard installation procedure for PHPUnit in a CodeIgniter project. I have also ensured that PHPUnit is properly installed and configured.
What I have tried:
- Double-checked my composer.json and reinstalled dependencies using composer install.
- Verified that the helper function is defined and works correctly outside of the test environment.
- Checked the autoload configuration in app/Config/Autoload.php to ensure the helper is listed.
- Added the helpers as attributes in the CIUnitTestCase class and in my test class.
- Included the helpers in the PHPUnit XML configuration file (phpunit.xml.dist).
Is there any additional configuration I need to perform, or is there something I might be missing that could cause this error? Any guidance would be greatly appreciated.