首页 > 解决方案 > 找不到类 PHPUnit_Testframework_TestCase

问题描述

我正在尝试使用 Xdebug/phpStorm 来测试 Drupal 项目。安装似乎工作(经过相当多的工作!)。但是,在 phpStorm 中设置断点并执行“运行”时,出现错误

PHP Fatal error:  Uncaught Error: Class 'PHPUnit_Framework_TestCase' not found in /home/hs/hellm/vendor/albertofem/rsync-lib/tests/AFM/Rsync/Tests/CommandTest.php:16
Stack trace:
#0 /home/hs/hellm/vendor/phpunit/phpunit/src/Util/FileLoader.php(65): include_once()
#1 /home/hs/hellm/vendor/phpunit/phpunit/src/Util/FileLoader.php(49): PHPUnit\Util\FileLoader::load()
#2 /home/hs/hellm/vendor/phpunit/phpunit/src/Framework/TestSuite.php(402): PHPUnit\Util\FileLoader::checkAndLoad()
#3 /home/hs/hellm/vendor/phpunit/phpunit/src/Framework/TestSuite.php(530): PHPUnit\Framework\TestSuite->addTestFile()
#4 /home/hs/hellm/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php(98): PHPUnit\Framework\TestSuite->addTestFiles()
#5 /home/hs/hellm/vendor/phpunit/phpunit/src/TextUI/Command.php(120): PHPUnit\Runner\BaseTestRunner->getTest()
#6 /home/hs/hellm/vendor/phpunit/phpunit/src/TextUI/Command.php(96): PHPUnit\TextUI\Command->run()
#7 /home/hs/hellm/vendor/phpunit/phpunit/phpunit(61): PHPUnit\TextUI\Command::main()
#8 {main}

我在 PHP 7.4,使用 PHPUnit 9.5.4,Drupal 9.1.8

标签: phpunit

解决方案


PHPUnit 9 没有PHPUnit_Framework_TestCase了。您的测试可能是为不再支持的过时版本的 PHPUnit 编写的。


推荐阅读