lundi 28 octobre 2019

Writing PHPUnit test for a class which extends another class produces a 'Class not found' error

What I have:

  1. AbstractFunction Abstract Class;
  2. class Functions extends AbstractFunctions Class;
  3. FunctionsTest Class;

In the FunctionsTest class I have this:

require_once dirname(__FILE__) . "/../../modules/quiz/Functions.php";

class QuizFunctionsTest extends TestCase {
    public function testGetQuizByID() {
        # some code
    }
}

Which gives me the following error:

PHP Fatal error: Class '%path%\AbstractFunctions' not found in %path%/modules/quiz/Functions.php on line 18

I tried require_once the missing class but it didn't help. Outside the test class my code works just fine. Any thoughts?

Aucun commentaire:

Enregistrer un commentaire