function scan_directory() { global $suite, $total_tests, $total_failures, $testRunner; $d = opendir("."); while ($entry = readdir($d)) { if ($entry == "." || $entry == "..") { /** ignore these directories **/ } else { if (is_dir($entry)) { chdir($entry); scan_directory(); chdir(".."); } else { if (preg_match("/^[T|t]est/", $entry) && (preg_match("/[.]php3?\$/", $entry) || preg_match("/[.]inc\$/", $entry))) { if (!defined("OPT_BE_BRIEF")) { print "Requiring file ... {$entry}<br>\n"; } require_once $entry; // because we run into memory problems if we include // all files and then run the tests, we run the test suite // after each include. $result = $testRunner->run($suite); mkdb_check_did_db_fail_calls(); $total_tests += $result->countTests(); $total_failures += $result->countFailures(); unset_global('queries'); $result = ''; $suite = new TestSuite(); } } } } closedir($d); }
function tearDown() { unset_global('bx', 'db'); }
function setup() { unset_global('bx', 'db'); }
function tearDown() { // remove the globally defined database object because it may // intefer with other tests unset_global('db', 'bx'); }
function tearDown() { // ensure that the next test does not have a predefined global // database object unset_global('db', 'bx'); }
function testConfigure_form() { global $bx, $t, $sess, $preview, $quorum, $other_tech_contents, $other_developing_proposals, $consultants, $auth, $queries; $uname = 'this is the usernmae'; $auth->set_uname($uname); $preview = 'this is the preview'; $quorum = 'this is the qurom'; $other_tech_contents = 'this is the other tech contents'; $other_developing_proposals = 'this is the other developing proposals'; $consultants = 'this is the consulants'; $db_config = new mock_db_configure(178); $args = $this->_generate_records(array('proid'), 50); $fname = 'configure_form'; $qs = array(0 => $queries[$fname]); // test1: configure_first_time(..) returns 1 (true) $db_config->add_query(sprintf($qs[0], $args[0]['proid']), 0); $db_config->add_num_row(0, 0); // test2: configure_first_time(..) returns 0 (false) $db_config->add_query(sprintf($qs[0], $args[1]['proid']), 1); $db_config->add_num_row(1, 1); // test one, all queries to is_sponsor and is_project_initiator and // is_developer return false because the perm attribute of auth // is empty. $auth->set_perm(''); unset_global('preview'); $bx = $this->_create_default_box(); $this->capture_call($fname, 1478 + strlen($sess->self_url()), $args[0]); $this->_configure_form_checkfor_form_and_box($args[0]); // test two: the same as above, except configure_first_time(..) returns // false and therefore it is necessary to set preview $auth->set_perm(''); $GLOBALS['preview'] = 'is set and not empty ...'; $bx = $this->_create_default_box(); $this->capture_call($fname, 1478 + strlen($sess->self_url()), $args[1]); $this->_configure_form_checkfor_form_and_box($args[1]); // switch authorisation for the tests to follow $auth->set_perm('hell yes!'); // now do an exhaustive test, i.e. test all possible combination // of query return values $qmask = array(0 => 0); $cfmask = array(); $sinst = 2; for ($idx = 0, $jdx = 2; $idx < 32; $idx++, $jdx++) { $cfmask[0] = $qmask[1] = ($idx & 0x1) > 0; $cfmask[1] = $qmask[2] = ($idx & 0x2) > 0; $cfmask[2] = $qmask[3] = ($idx & 0x4) > 0; $qmask[4] = ($idx & 0x8) > 0; $qmask[5] = ($idx & 0x10) > 0; $cfmask[3] = $qmask[4] && $qmask[5]; $this->set_msg('Test ' . $jdx . " 0=>" . $qmask[1] . " 1=>" . $qmask[2] . " 2=>" . $qmask[3] . " 3=>" . $qmask[4] . " 4=>" . $qmask[5]); $len = 1478 + ($cfmask[0] ? 724 : 0) + ($cfmask[1] ? 458 : 0) + ($cfmask[2] ? 535 : 0) + ($cfmask[3] ? 438 : 0); // FIXME: why do we add one more to the length if the second // FIXME: call to is_sponsor _or_ the second call to is_project_ // FIXME: initiator returns true *but* not when both are true!!! if ($qmask[4] && !$qmask[5] || !$qmask[4] && $qmask[5]) { $len++; } $sinst = $this->_configure_form_config_db($sinst, $db_config, $args[$jdx], $qs, $uname, $qmask); $bx = $this->_create_default_box(); $this->capture_call($fname, $len + strlen($sess->self_url()), $args[$jdx]); $this->_configure_form_checkfor_form_and_box($args[$jdx]); $this->_configure_form_checkfor_parts($cfmask); } $this->_check_db($db_config); }
function tearDown() { // remove the globally defined database object, it can affect // other tests unset_global('db', 'bx'); }
function unset_error_values() { unset_global('err_no', 'err_msg', 'err_line', 'err_file'); }
function tearDown() { // Ensure that the global db is predefined for the next test unset_global('db', 'bx'); }