【问题标题】:PHP Fatal error: Uncaught Error: Class 'CakeTestSuite' not found inPHP 致命错误:未捕获的错误:在中找不到类“CakeTestSuite”
【发布时间】:2018-02-08 04:21:58
【问题描述】:

我是 PHP 新手,我有现有的 CakePHP 项目,但我无法从 PHP Storm 启动它。每次我想运行应用程序时都会显示错误:

PHP 致命错误:未捕获的错误:在 C:\xampp\htdocs\dummy\dummy_app\Plugin\AclExtras\Test\Case\AllTestsTest.php:16 中找不到类“CakeTestSuite”

AllTestsTest.php文件:

require_once 'PHPUnit/Autoload.php';

class AllTestsTest extends PHPUnit_Framework_TestSuite {


    public static function suite() {
        $suite = new CakeTestSuite('All Tests');
        $suite->addTestDirectoryRecursive(App::pluginPath('AclExtras') . 'Test' . DS . 'Case' . DS);

        return $suite;
    }
}

错误设置为:$suite = new CakeTestSuite('All Tests');

任何想法为什么或如何解决这个问题?

【问题讨论】:

  • 出现该错误的最常见原因是未包含您尝试实例化的类。如果还没有,请尝试 include()require() 包含该类的文件。
  • 谢谢@ksjohn
  • 或者可以包含命名空间Path\File\CakeTestSuite

标签: php cakephp phpunit cakephp-2.x


【解决方案1】:

CakePHP 2.x 测试套件不能直接通过 PHPUnit 运行,它需要 CakePHP 的自定义自动加载器并使用自定义测试运行器。您必须改用 CakePHP 测试 shell。

./Console/cake test AclExtras

另见

【讨论】:

  • 我解决了我的问题,但这非常有用,谢谢:)
猜你喜欢
  • 2023-03-25
  • 2018-04-19
  • 1970-01-01
  • 1970-01-01
  • 2018-01-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多