/** * Constructor * * If $pass is false, the global Tulip config property "PASS" will be set to false * * @param boolean $pass * @param string $text */ public function Tulip_Test($pass, $text) { if (!$pass) { Tulip::config("PASS", false); } $this->pass = $pass; $this->text = $text; }
/** * Set/retrieve config information * * Usage: * - config( key ) => get the value associated with the key * - config( key , value ) => set the value for the given key to the given value * - config( array( key => value, ... ) ) => for each element, do config( key , value ) * * Keys are case insensitive strings. * * @param mixed $name the name or an array of values * @param array $value * @return mixed */ public static final function config($name, $value = NULL) { if (is_array($name)) { foreach ($name as $n => $v) { Tulip::config($n, $v); } } else { if (is_string($name)) { $name = strtoupper($name); if ($value !== NULL) { Tulip::$config[$name] = $value; } else { return Tulip::$config[$name]; } } } }
function Tulip_Output_shutdown() { // Report fatal errors $fatal_errors = array(); preg_match_all('/fatal\\s+error.*?:(.*)/i', $tmp = ob_get_clean(), $fatal_errors); $fatal_errors = $fatal_errors[1]; if (count($fatal_errors)) { $last = end(end(Tulip::modules())->units()); foreach ($fatal_errors as &$fatal_error) { $last->add(false, preg_replace('/^\\s+|\\s+$|<.*?>/', "", $fatal_error), false); } } // Get the template $template = Tulip::config("TEMPLATE"); if (substr($template, 0, 1) == "#") { $template = dirname(__FILE__) . DIRECTORY_SEPARATOR . "Output" . DIRECTORY_SEPARATOR . substr($template, 1) . ".php"; } // If template does not exist, try to get it from path if (!file_exists($template)) { $file = false; $dirs = explode(PATH_SEPARATOR, Tulip::config("PATH")); foreach ($dirs as $dir) { if (file_exists($dir . DIRECTORY_SEPARATOR . $template)) { $file = $dir . DIRECTORY_SEPARATOR . $template; break; } } if (!$file) { echo "Tulip: couldn't find template file {$template}"; exit; } $template = $file; } // Include the template and render require_once $template; }
?> </li> <?php } ?> </ol> </strong> </li> <?php } } ?> </ol> <p id="tulip-result"> Tests completed in <?php echo number_format(microtime(true) - Tulip::config("START_TIME"), 2); ?> seconds. <br /> <span class="passed"><?php echo $pass; ?> </span> out of <span class="total"><?php echo $pass + $fail; ?> </span> tests passed, <span class="failed"><?php echo $fail; ?> </span> failed.