private function resetDatabase() { $db = Zend_Db_Table_Abstract::getDefaultAdapter(); foreach (QFrame_Db_Table::getTables() as $table) { $db->getConnection()->exec("TRUNCATE TABLE " . $table); QFrame_Db_Table::reset($table); } }
function runTests($tree, $branches) { $pid = pcntl_fork(); if ($pid != 0) { pcntl_waitpid($pid, $status); $failures = file_get_contents(PROJECT_PATH . '/tmp/.autotest'); return intval($failures); } /* * Prepare the database... */ require _path(CORE_PATH, 'database.php'); $db = Zend_Db_Table_Abstract::getDefaultAdapter(); foreach (QFrame_Db_Table::getTables() as $table) { $db->getConnection()->exec("TRUNCATE TABLE {$table}"); } if (is_array($branches)) { $tests = array(); $suite_name = implode(' && ', $branches); foreach ($branches as $branch) { $tests = array_merge($tests, collectBranchTests($tree, $branch)); } $tests = array_unique($tests); if (count($tests) <= 0) { return; } } elseif ($branches == 'all') { $suite_name = 'all'; $tests = collectAllTests($tree); } $suite = new PHPUnit_Framework_TestSuite($suite_name); foreach ($tests as $test) { require_once TEST_PATH . '/unit/' . $test; $class_name = preg_replace('/\\.php$/', '', $test); $suite_name = preg_replace('/^' . preg_quote(PROJECT_PATH . '/', '/') . '|\\.php$/', '', 'IGNORE'); $suite->addTestSuite(new PHPUnit_Framework_TestSuite('Test_Unit_' . $class_name, $suite_name)); } $result = new PHPUnit_Framework_TestResult(); $result->addListener(new QFrame_Test_Listener()); $suite->run($result); file_put_contents(PROJECT_PATH . '/tmp/.autotest', count($result->failures())); exit; }