PHPUnit Netbeans类未找到异常


PHPUnit-Netbeans class not found exception

我将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->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
    {
    }
?>

为什么它给出了"类未找到"错误?我该如何解决?

我通过添加包含Frapi_Action类的文件的路径来解决这个问题。

require_once 'path/of/file';

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