dte29947 2011-03-10 23:13
浏览 71
已采纳

PHPUnit安装程序和PHP目录问题

I know this probably gets asked a lot, but I have not used PHP in a really long time and I find myself once again wrestling with its path behavior and includes.

I have installed PHPUnit via Pear as is recommended, I have the Pear directory added to my php.ini file so that I can include PHPUnit.php globally. However, PHPUnit.php needs to include several files within it's own directory, and when I reference PHPUnit.php within my test directory:

require_once 'PHPUnit.php';

it attempts to include those files either relative to the test directory, or to the Pear directory specified in php.ini.

Fatal error: require_once() [function.require]: Failed opening required 'PHPUnit/TestCase.php'
(include_path='.:/home/data/pear/php') in /[snip]/domains/test.domainname.com/html/project/tests/PHPUnit.php on line 47

I remember dealing with these issues back in the day with PHP but I feel like I shouldn;t have to modify the path to the PHPUnit include files to make this work...

  • 写回答

1条回答 默认 最新

  • doushun1904 2011-03-10 23:38
    关注

    PHPUnit uses the typical class name to path conversion autoloader that replaces the underscores in a class name with directory separators.

    So in your code you've referenced PHPUnit_TestCase which has automatically tried to include the TestCase.php file in the PHPUnit directory, however that file/class doesn't exist.

    As KingCrunch said in the comment, the class to use is PHPUnit_Framework_TestCase

    If you look in your PHPUnit directory, there is a Framework directory that contains TestCase.php

    See Writing Tests for PHPUnit

    <?php
    class StackTest extends PHPUnit_Framework_TestCase
    {
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度