Arbit - project tracking

Dwoo

History

Diff

f20cfc 9bc397 a/tests/CompilerTests.php
566 566 $this->params = func_get_args();
567 567 }
568 568
569 - public function loadPlugin($name)
569 + public function handles($name)
570 570 {
571 571 return $name === 'TestProxy';
572 572 }
576 576 return func_get_args() === $this->params ? 'valid' : 'fubar';
577 577 }
578 578
579 - public function __call($m, $p)
579 + public function getCode($m, $p)
580 580 {
581 - return '$this->getPluginProxy()->check'.$m.'('.implode(',', $p).')';
581 + if (isset($p['*'])) {
582 + return '$this->getPluginProxy()->check'.$m.'('.implode(',', $p['*']).')';
583 + } else {
584 + return '$this->getPluginProxy()->check'.$m.'()';
585 + }
586 + }
587 +
588 + public function getCallback($name)
589 + {
590 + return array($this, 'callbackHelper');
591 + }
592 +
593 + public function getLoader($name)
594 + {
595 + return '';
596 + }
597 +
598 + private function callbackHelper(array $rest = array()) {
599 +
582 600 }
583 601 }
584 602
f20cfc 9bc397 a/tests/DwooTests.php
7 7 define('DWOO_CACHE_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR.'temp'.DIRECTORY_SEPARATOR.'cache');
8 8 define('DWOO_COMPILE_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR.'temp'.DIRECTORY_SEPARATOR.'compiled');
9 9
10 -require dirname(dirname(__FILE__)) . '/lib/dwooAutoload.php';
10 +require dirname(__FILE__) . '/'.DwooTests::getConfig('DWOO_PATH').'/dwooAutoload.php';
11 11 define('TEST_DIRECTORY', dirname(__FILE__));
12 12
13 13 class DwooTests extends PHPUnit_Framework_TestSuite {
14 14
15 + protected static $cfg;
16 +
17 + public static function getConfig($var, $default=null) {
18 + if (self::$cfg == null) {
19 + self::$cfg = parse_ini_file(dirname(__FILE__) . '/config.ini');
20 + }
21 + if (isset(self::$cfg[$var])) {
22 + return self::$cfg[$var];
23 + }
24 + return $default;
25 + }
26 +
15 27 public static function suite() {
16 28 PHPUnit_Util_Filter::addDirectoryToWhitelist(DWOO_DIRECTORY.'plugins/builtin');
17 29 PHPUnit_Util_Filter::addDirectoryToWhitelist(DWOO_DIRECTORY.'Dwoo');
23 35 foreach (new DirectoryIterator(dirname(__FILE__)) as $file) {
24 36 if (!$file->isDot() && !$file->isDir() && (string) $file !== 'DwooTests.php' && substr((string) $file, -4) === '.php') {
25 37 require_once $file->getPathname();
26 - $suite->addTestSuite(basename($file, '.php'));
38 + $class = basename($file, '.php');
39 + // to have an optional test suite, it should implement a public static function isRunnable
40 + // that returns true only if all the conditions are met to run it successfully, for example
41 + // it can check that an external library is present
42 + if (!method_exists($file, 'isRunnable') || call_user_func(array($file, 'isRunnable'))) {
43 + $suite->addTestSuite($class);
44 + }
27 45 }
28 46 }
29 47
f20cfc 9bc397 /dev/null
2 +; this is a path to the Dwoo lib, relative to this file
3 +DWOO_PATH=../lib/