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?

Alex
  • 41,580
  • 88
  • 260
  • 469
  • What is the reason for this unusual test call and require usage? – SenseException Dec 02 '14 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. – Alex Dec 02 '14 at 15:19
  • I don't have an answer, but found a similar problem with PHPUnit, see http://stackoverflow.com/questions/29232027/phpunit-cannot-find-source-code?noredirect=1#comment46670144_29232027 – physicalattraction Mar 26 '15 at 08:23

0 Answers0