Undefined constant SUPPORTPATH

Hi there,

I have a PHP Project in PHPStorm 2022.2.4 on my iMac running OSX 12.6.1

When I run unittest from the terminal in my projects www directory, phpunit runs correctly.

When I try to run in the ide, it fails.

/usr/local/Cellar/php/8.1.12/bin/php /Users/wclark/Sites/option-chain/www/vendor/phpunit/phpunit/phpunit --no-configuration /Users/wclark/Sites/option-chain/www/ --teamcity --cache-result-file=/Users/wclark/Sites/option-chain/.phpunit.result.cache
Testing started at 1:19 pm ...
PHP Fatal error:  Uncaught Error: Undefined constant "CodeIgniter\Test\SUPPORTPATH" in /Users/wclark/Sites/option-chain/www/vendor/phpunit/phpunit/src/Framework/TestBuilder.php:138
Stack trace:
#0 /Users/wclark/Sites/option-chain/www/vendor/phpunit/phpunit/src/Framework/TestBuilder.php(117): PHPUnit\Framework\TestBuilder->buildTestWithoutData('Tests\\Support\\M...')
#1 /Users/wclark/Sites/option-chain/www/vendor/phpunit/phpunit/src/Framework/TestSuite.php(881): PHPUnit\Framework\TestBuilder->build(Object(ReflectionClass), 'testcalcMidPric...')
#2 /Users/wclark/Sites/option-chain/www/vendor/phpunit/phpunit/src/Framework/TestSuite.php(231): PHPUnit\Framework\TestSuite->addTestMethod(Object(ReflectionClass), Object(ReflectionMethod))
#3 /Users/wclark/Sites/option-chain/www/vendor/phpunit/phpunit/src/Framework/TestSuite.php(361): PHPUnit\Framework\TestSuite->__construct(Object(ReflectionClass))
#4 /Users/wclark/Sites/option-chain/www/vendor/phpunit/phpunit/src/Framework/TestSuite.php(502): PHPUnit\Framework\TestSuite->addTestSuite(Object(ReflectionClass))
#5 /Users/wclark/Sites/option-chain/www/vendor/phpunit/phpunit/src/Framework/TestSuite.php(527): PHPUnit\Framework\TestSuite->addTestFile('/Users/wclark/S...')

Here is my run configuration for unittest:

Any suggestions would be appreciated.

0
3 comments

I have adjusted the Directory to /Users/wclark/Sites/option-chain/www and it still gets the same error.

 

0

Having a PHPUnit executable directly in the project root is not common. What is this ./phpunit file? What's in it?
I assume that running the same command that PhpStorm executes in the terminal would lead to the same results?

/usr/local/Cellar/php/8.1.12/bin/php /Users/wclark/Sites/option-chain/www/vendor/phpunit/phpunit/phpunit --no-configuration /Users/wclark/Sites/option-chain/www/ --teamcity --cache-result-file=/Users/wclark/Sites/option-chain/.phpunit.result.cache

If so, is it expected that PhpStorm passes no configuration to PHPUnit? Do you have a phpunit.xml file in your project?

0

Thanks for your reply, Eugene.

For a mac, it was recommended in the phpunit docs to set up a soft link to my local phpunit. That is what the ./phpunit file is.

However, after following the following page more closely, I removed it.

https://www.jetbrains.com/help/phpstorm/using-phpunit-framework.html#generate_phpunit_test_for_a_class_in_a_separate_file

Configuring my /Users/wclark/Sites/option-chain/www/phpunit.xml.dist and using it as my alternate configuration file in each debug configuration fixed everything. It works now.

 

0

Please sign in to leave a comment.