【问题标题】:PHPUnit-Netbeans class not found exceptionPHPUnit-Netbeans 类未找到异常
【发布时间】:2013-07-18 11:43:37
【问题描述】:

我将 PHPUnit 集成到 netbeans 中,现在想为我的代码生成测试。

<?php

/**
     * Action User
     *
     * user api
     *
     * @link http://getfrapi.com
     * @author Frapi <frapi@getfrapi.com>
     * @link rsmobile/user/:id
     */
    class Action_User extends Frapi_Action implements Frapi_Action_Interface
    {

    }
?>

我尝试通过右键单击和selecting Tools-&gt;Create PHPUnit Tests 来做到这一点。但它给出了这个错误:

Fatal error: Class 'Frapi_Action' not found in /Users/username/Documents/.../src/   
frapi/custom/Action/User.php on line 12

然后我在文件 User.php 中添加了虚拟Frapi_Action 类,然后它生成了骨架类。

<?php

/**
     * Action User
     *
     * user api
     *
     * @link http://getfrapi.com
     * @author Frapi <frapi@getfrapi.com>
     * @link rsmobile/user/:id
     */

    class  Frapi_Action {} 

    class Action_User extends Frapi_Action implements Frapi_Action_Interface
    {

    }
?>

为什么它给出了 Class not found 错误?我该如何解决?

【问题讨论】:

    标签: php netbeans phpunit netbeans-7.3


    【解决方案1】:

    我通过添加包含Frapi_Action 类的文件的路径来解决它。

    require_once 'path/of/file';
    

    【讨论】:

      【解决方案2】:

      您的课程不在原始示例的源代码中。您要么需要包含/要求包含该类的外部文件(推荐),要么在此代码中包含该类。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-01-12
        • 2013-11-30
        • 2016-09-09
        • 1970-01-01
        • 2016-11-28
        • 2013-04-09
        相关资源
        最近更新 更多