Question

I integrated PHPUnit into netbeans and now want to generate tests for my code.

<?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
    {

    }
?>

I tried to do that by right clicking and selecting Tools->Create PHPUnit Tests. But it gave this error :

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

Then I added dummy Frapi_Action class in file User.php and then it generated skeleton class.

<?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
    {

    }
?>

Why it gave that Class not found error? How do I solve it?

Was it helpful?

Solution

I solved it by adding path of the file containing Frapi_Action class.

require_once 'path/of/file';

OTHER TIPS

Your class is not in the source code in the original example. You either need to include/require the external file containing the class (recommended) or have the class in this code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top