1

For a given project I have two php files to run php unittests, which are located in subdirectories.

The first file (AllTestSuite.php) looks like this:

<?php
require_once dirname(__FILE__).'/unittest.inc.php';

class AllTestsSuite {
    public static function suite(){
        return new GlobTestsSuite(dirname(__FILE__), "/*/*Suite.php");
    }
}

?>

and the second file (unittest.inc.php) looks like this:

<? 
class GlobTestsSuite extends PHPUnit_Framework_TestSuite {

    public function __construct($sDirectory, $sExpression){
        parent::__construct();
        foreach (glob("$sDirectory/$sExpression") as $sTest){
            require_once($sTest);
            $this->addTestSuite(basename($sTest, ".php"));
        }
    }
}
?>

The tests itself are invoked (on Ubuntu, phpunit Version 3.7.27) as follows:

phpunit   AllTestsSuite ./AllTestsSuite.php

which gives the error message

PHP Fatal error:  Class 'GlobTestsSuite' not found in /home/.../AllTestsSuite.php on line 6

I do not understand what is going here. The file AllTestsSuite.php imports the other file in which the class GlobTestSuite is defined. How to fix this problem?

3
  • What is the reason for this unusual test call and require usage? Commented Dec 2, 2014 at 12:50
  • @SenseException: I cannot tell you. I only got this project with the unittests 'as-is'. I am not allowed to make major changes. Commented Dec 2, 2014 at 15:19
  • I don't have an answer, but found a similar problem with PHPUnit, see stackoverflow.com/questions/29232027/… Commented Mar 26, 2015 at 8:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.