PHPUnit 已安装,但未找到 PHPUnit_TestCase 类

发布于 2024-08-29 03:32:07 字数 1321 浏览 3 评论 0原文

谈论在第一个障碍时摔倒的情况。我的测试脚本:

<?php

require_once('PHPUnit/Framework.php');

class TransferResponseTest extends PHPUnit_TestCase {

    ...

}

运行我的测试用例:

$ phpunit TransferResponseTest

Fatal error: Class 'PHPUnit_TestCase' not found in 
/Volumes/Data/greg/code/syndicate/tests/TransferResponseTest.php on line 5
$ php -i | grep include_path
include_path => .:/usr/lib/php => .:/usr/lib/php
$ ls -l /usr/lib/php/PHPUnit/
total 8
drwxr-xr-x  16 root  wheel   544 27 Mar 19:03 Extensions
drwxr-xr-x  28 root  wheel   952 27 Mar 19:03 Framework
-rw-r--r--   1 root  wheel  3193 27 Mar 19:03 Framework.php
drwxr-xr-x   8 root  wheel   272 27 Mar 19:03 Runner
drwxr-xr-x   5 root  wheel   170 27 Mar 19:03 TextUI
drwxr-xr-x  32 root  wheel  1088 27 Mar 19:03 Util

我将 /etc/php.ini-default 复制到 /etc/php.ini 并明确指定包含路径为 /usr/lib/php/ 结束 / 但仍然没有成功。

$ php -i | grep include_path
include_path => .:/usr/lib/php/ => .:/usr/lib/php/
$ phpunit TransferResponseTest.php 
PHP Fatal error:  Class 'PHPUnit_TestCase' not found in 
/Volumes/Data/greg/code/syndicate/tests/TransferResponseTest.php on line 5
$ phpunit --version
PHPUnit 3.4.11 by Sebastian Bergmann.

有什么想法吗?

Talk about falling at the first hurdle. My test script:

<?php

require_once('PHPUnit/Framework.php');

class TransferResponseTest extends PHPUnit_TestCase {

    ...

}

Running my test case:

$ phpunit TransferResponseTest

Fatal error: Class 'PHPUnit_TestCase' not found in 
/Volumes/Data/greg/code/syndicate/tests/TransferResponseTest.php on line 5
$ php -i | grep include_path
include_path => .:/usr/lib/php => .:/usr/lib/php
$ ls -l /usr/lib/php/PHPUnit/
total 8
drwxr-xr-x  16 root  wheel   544 27 Mar 19:03 Extensions
drwxr-xr-x  28 root  wheel   952 27 Mar 19:03 Framework
-rw-r--r--   1 root  wheel  3193 27 Mar 19:03 Framework.php
drwxr-xr-x   8 root  wheel   272 27 Mar 19:03 Runner
drwxr-xr-x   5 root  wheel   170 27 Mar 19:03 TextUI
drwxr-xr-x  32 root  wheel  1088 27 Mar 19:03 Util

I copied /etc/php.ini-default to /etc/php.ini and explicitly specified the include path as /usr/lib/php/ with an end / but still no success.

$ php -i | grep include_path
include_path => .:/usr/lib/php/ => .:/usr/lib/php/
$ phpunit TransferResponseTest.php 
PHP Fatal error:  Class 'PHPUnit_TestCase' not found in 
/Volumes/Data/greg/code/syndicate/tests/TransferResponseTest.php on line 5
$ phpunit --version
PHPUnit 3.4.11 by Sebastian Bergmann.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

享受孤独 2024-09-05 03:32:07

它不是 PHPUnit_TestCase,而是 PHPUnit_Framework_TestCase。并且您不必需要“PHPUnit/Framework.php”,它在运行测试时已由 PHPUnit 加载。

It's not PHPUnit_TestCase, but PHPUnit_Framework_TestCase. And you don't have to require 'PHPUnit/Framework.php' which is already loaded by PHPUnit by the time your tests are run.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文