/** * need to supply me with $result and $profiler * first one being test result object of PHPUnit and second an instance of profiler */ function DumpResultRows($ResultArray, $Symbol, $Text, $Odd = false) { if (count($ResultArray)) { echo $Symbol . count($ResultArray) . " " . $Text . "\n"; $n = 0; foreach ($ResultArray as $test) { echo ++$n; echo ") "; $t = $test->failedTest(); echo get_class($t); echo " :: "; echo $t->getName(); echo "\t"; $e = new Exception(); echo $test->getExceptionAsString(); echo "\t"; $trace = $test->thrownException()->getTrace(); if ($Odd) { $file = $trace[0]['file']; } else { $file = $trace[3]['file']; } $dir = substr($file, 0, strlen(jf::root())); $dir = substr($file, 0, strpos($file, DIRECTORY_SEPARATOR, strlen($dir) + 1)); $dir = substr($file, 0, strpos($file, DIRECTORY_SEPARATOR, strlen($dir) + 1)); $filename = substr($file, strlen($dir) + 1); echo $filename; echo "\n"; } echo str_repeat("-", 80) . "\n"; } }
/** * this function adds rules for autoloading of core jframework modules */ private static function AddCoreModules() { $Array = array("Model" => "model/base/model", "Controller" => "model/base/control", "View" => "model/base/view", "Plugin" => "model/base/plugin", "Test" => "model/base/test", "ErrorHandler" => "model/core/errorhandler", "DownloadManager" => "model/core/download", "HttpRequest" => "model/core/http", "BaseLauncher" => "model/launcher/base", "ApplicationLauncher" => "model/launcher/application", "SystemLauncher" => "model/launcher/system", "FileLauncher" => "model/launcher/file", "TestLauncher" => "model/launcher/test", "DatabaseManager" => "model/lib/db", "Profiler" => "model/lib/profiler", "LogManager" => "model/lib/log", "UserManager" => "model/lib/user", "ExtendedUserManager" => "model/lib/xuser", "SessionManager" => "model/lib/session", "SecurityManager" => "model/lib/security", "SettingManager" => "model/lib/settings", "RBACManager" => "model/lib/rbac", "ServiceManager" => "model/service/manager", "Password" => "model/lib/security/password"); $RuleArray = array(); foreach ($Array as $k => $v) { $RuleArray[__NAMESPACE__ . "\\{$k}"] = realpath(jf::root() . "/_japp/{$v}.php"); $RuleArray["\\" . __NAMESPACE__ . "\\{$k}"] = realpath(jf::root() . "/_japp/{$v}.php"); } self::AddRuleArray($RuleArray); }
static function moduleFile($module) { if (strlen($module) > 3 && substr($module, 0, 3) == "jf/") { $module = "_japp/" . substr($module, 3); } else { $module = "app/" . $module; } $file = jf::root() . "/" . $module . ".php"; return $file; }
/** * Launches an application controller. Returns what the controller returns. * If it is false, a not found error is displayed. * @return boolean */ function Launch() { $Parts = explode("/", $this->Request); $Type = array_shift($Parts); if (!array_key_exists($Type, self::$StaticContentPrefix)) { return false; } $Type = self::$StaticContentPrefix[$Type]; array_unshift($Parts, $Type); $file = jf::root() . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $Parts); $FileMan = new DownloadManager(); return $FileMan->Feed($file); }
/** * returns module name for this object in format control/demo/__catch */ protected function ModuleName($Object = null) { if ($Object === null) { $Object = $this; } $reflector = new \ReflectionClass(get_class($Object)); $filename = $reflector->getFileName(); $filename_inside_jf = substr($filename, strlen(jf::root()) + 1); $Parts = explode(DIRECTORY_SEPARATOR, $filename_inside_jf); $Type = array_shift($Parts); if ($Type == "_japp") { array_unshift($Parts, "jf"); } return substr(implode("/", $Parts), 0, -4); //omit .php }
private function CLILauncher() { $command = "php '" . jf::root() . "/" . self::$PHPUnitPhar . "' '" . $this->ModuleFile("jf/test/main") . "'"; var_dump($command); $res = shell_exec($command); var_dump($res); return true; }
/** * need to supply me with $result and $profiler * first one being test result object of PHPUnit and second an instance of profiler */ function DumpResultRows($ResultArray, $BackgroundColor, $Color, $Text, $Odd = false) { if (count($ResultArray)) { ?> <tr style='background-color:<?php exho($BackgroundColor); ?> ;color:<?php exho($Color); ?> ;font-weight:bold;'> <td colspan='4' > <?php exho(count($ResultArray)); echo " {$Text}"; ?> </td> </tr> <?php $n = 0; foreach ($ResultArray as $test) { echo "<tr>"; echo "<td width='50' align='center'>\n\t\t"; echo ++$n; echo "\n</td>"; $t = $test->failedTest(); echo "<td>\n\t\t"; echo get_class($t); echo " :: "; echo $t->getName(); echo "\n</td>"; echo "<td>\n\t\t"; $e = new Exception(); echo $test->getExceptionAsString(); echo "</td>"; echo "<td>\n\t\t"; $trace = $test->thrownException()->getTrace(); if ($Odd) { $file = $trace[0]['file']; $line = $trace[0]['line']; } else { if (isset($trace[3]['file'])) { $file = $trace[3]['file']; $line = $trace[3]['line']; } else { $file = $line = null; } } if ($file !== null) { $dir = substr($file, 0, strlen(jf::root())); $dir = substr($file, 0, strpos($file, DIRECTORY_SEPARATOR, strlen($dir) + 1)); $dir = substr($file, 0, strpos($file, DIRECTORY_SEPARATOR, strlen($dir) + 1)); $filename = substr($file, strlen($dir) + 1); echo $dir . "/<strong>{$filename}</strong> :{$line}"; } else { echo "File: Could not determine, probably because of fatal error."; } echo "\n</td>\n"; echo "</tr>\n"; } ?> <?php } }