Hello, I solved some exercises on PHP online and wanted to test them locally before uploading them to my GitHub. Unfortunately, my code works on the online editor but not locally. I also used community solutions, but I still get the same error message on two different exercises (LuckyNumbers and Gigasecond).
I believe the issue comes from my PHPUnit installation. I tried following the instructions provided in the HELP.md file, but the command lines don’t work.
Here’s how I installed PHPUnit:
I downloaded version 12.0.0 from the official website https://phar.phpunit.de/
I created a folder called phpunit
at C:\phpunit, where I placed and renamed phpunit.phar
.
I created a phpunit.bat
file containing:
@echo off
php C:\phpunit\phpunit.phar %*
I added a new environment variable in the PATH.
I can now call PHPUnit from anywhere on my PC.
I’ve tested phpunit --version
from several locations without any issues.
I’ve already tested and uploaded 18 exercises without any problems.
Here’s the error message when I run the tests:
PS C:\Users\Florian\Desktop\exercism\php\gigasecond> phpunit .\GigasecondTest.php
PHPUnit 12.0.0 by Sebastian Bergmann and contributors.
Runtime: PHP 8.4.5
EE 2 / 2 (100%)
Time: 00:00.001, Memory: 26.00 MB
There were 2 errors:
1) GigasecondTest::testFrom
ArgumentCountError: Too few arguments to function GigasecondTest::testFrom(), 0 passed in phar://C:/phpunit/phpunit.phar/phpunit/Framework/TestCase.php on line 902 and exactly 2 expected
C:\Users\Florian\Desktop\exercism\php\gigasecond\GigasecondTest.php:67
2) GigasecondTest::testFromReturnType
ArgumentCountError: Too few arguments to function GigasecondTest::testFromReturnType(), 0 passed in phar://C:/phpunit/phpunit.phar/phpunit/Framework/TestCase.php on line 902 and exactly 1 expected
C:\Users\Florian\Desktop\exercism\php\gigasecond\GigasecondTest.php:79
ERRORS!
Tests: 2, Assertions: 0, Errors: 2.
PS C:\Users\Florian\Desktop\exercism\php\gigasecond>
And I get the same ArgumentCountError on the other exercise.
PHP :
PHP 8.4.5 (cli) (built: Mar 12 2025 12:17:53) (NTS Visual C++ 2022 x64)
Copyright (c) The PHP Group
Zend Engine v4.4.5, Copyright (c) Zend Technologies
phpunit :
PHPUnit 12.0.0 by Sebastian Bergmann and contributors.
Thank you in advance for your help!