Commit 9bc39788 by Seldaek

* adds stuff in the test suite to allow easier test running on other setups

git-svn-id: svn://dwoo.org/dwoo/trunk@187 0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent f20cfc38
......@@ -565,7 +565,7 @@ class ProxyHelper implements Dwoo_IPluginProxy
$this->params = func_get_args();
}
public function loadPlugin($name)
public function handles($name)
{
return $name === 'TestProxy';
}
......@@ -575,9 +575,27 @@ class ProxyHelper implements Dwoo_IPluginProxy
return func_get_args() === $this->params ? 'valid' : 'fubar';
}
public function __call($m, $p)
public function getCode($m, $p)
{
return '$this->getPluginProxy()->check'.$m.'('.implode(',', $p).')';
if (isset($p['*'])) {
return '$this->getPluginProxy()->check'.$m.'('.implode(',', $p['*']).')';
} else {
return '$this->getPluginProxy()->check'.$m.'()';
}
}
public function getCallback($name)
{
return array($this, 'callbackHelper');
}
public function getLoader($name)
{
return '';
}
private function callbackHelper(array $rest = array()) {
}
}
......
......@@ -6,11 +6,23 @@ if (!ini_get('date.timezone'))
define('DWOO_CACHE_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR.'temp'.DIRECTORY_SEPARATOR.'cache');
define('DWOO_COMPILE_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR.'temp'.DIRECTORY_SEPARATOR.'compiled');
require dirname(dirname(__FILE__)) . '/lib/dwooAutoload.php';
require dirname(__FILE__) . '/'.DwooTests::getConfig('DWOO_PATH').'/dwooAutoload.php';
define('TEST_DIRECTORY', dirname(__FILE__));
class DwooTests extends PHPUnit_Framework_TestSuite {
protected static $cfg;
public static function getConfig($var, $default=null) {
if (self::$cfg == null) {
self::$cfg = parse_ini_file(dirname(__FILE__) . '/config.ini');
}
if (isset(self::$cfg[$var])) {
return self::$cfg[$var];
}
return $default;
}
public static function suite() {
PHPUnit_Util_Filter::addDirectoryToWhitelist(DWOO_DIRECTORY.'plugins/builtin');
PHPUnit_Util_Filter::addDirectoryToWhitelist(DWOO_DIRECTORY.'Dwoo');
......@@ -22,7 +34,13 @@ class DwooTests extends PHPUnit_Framework_TestSuite {
foreach (new DirectoryIterator(dirname(__FILE__)) as $file) {
if (!$file->isDot() && !$file->isDir() && (string) $file !== 'DwooTests.php' && substr((string) $file, -4) === '.php') {
require_once $file->getPathname();
$suite->addTestSuite(basename($file, '.php'));
$class = basename($file, '.php');
// to have an optional test suite, it should implement a public static function isRunnable
// that returns true only if all the conditions are met to run it successfully, for example
// it can check that an external library is present
if (!method_exists($file, 'isRunnable') || call_user_func(array($file, 'isRunnable'))) {
$suite->addTestSuite($class);
}
}
}
......
; this is a path to the Dwoo lib, relative to this file
DWOO_PATH=../lib/
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment