(solved) Same error : ArgumentCountError on 2 php exercises

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!

Hi @ZayraK and welcome!

We currently support only PHPUnit 10 (for supporting the required range of PHP versions from 8.1). You can follow the instructions on the PHP track documentation to download the PHP phar: Installing PHP locally | Exercism's Docs

You may not be able to use PHPUnit 10 with PHP8.4 (I haven’t tested it). You should then downgrade to PHP8.3, that is supported for sure.

If you still experience problems running the tests locally, please make your code available to us. You can post it here or publish it in Exercism and link it here.

Hi @mk-mxp thanks you so much for your answer and your help !
I have installed PHP 8.3, reinstalled Composer, and installed PHPUnit 10, and now everything works perfectly. Thank you very much for your help.

PS: I don’t know if topics on this forum should be closed once resolved, and if so, how to do it? I will add (solved) to the title for now.

You can mark an answer as “Solution” to show what helped you.

1 Like