rather than using the main() method.
It is not sufficient to setup the static AllTests class via the main method.
This only allows to directly execute the AllTests.php file by parsing it
with php. Using phpunit is not possible as this will only use the suite()
method to grab the test suite.
It would still be better to use late static binding here but the added
method should be enough to allow running the tests in both ways.
The AllTests.php in Kolab_Session demonstrates how to use the init() method.
{
}
+Horde_Kolab_Session_AllTests::init('Horde_Kolab_Session', __FILE__);
+
if (PHPUnit_MAIN_METHOD == 'Horde_Kolab_Session_AllTests::main') {
- Horde_Kolab_Session_AllTests::main('Horde_Kolab_Session', __FILE__);
+ Horde_Kolab_Session_AllTests::main();
}
}
/**
+ * Initialize the test suite class.
+ *
+ * @param string $package The name of the package tested by this suite.
+ * @param string $file The path of the AllTests class.
+ *
+ * @return NULL
+ */
+ public static function init($package, $file)
+ {
+ self::$_package = $package;
+ self::$_file = $file;
+ }
+
+ /**
* Collect the unit tests of this directory into a new suite.
*
* @return PHPUnit_Framework_TestSuite The test suite.