Exemplo n.º 1
0
 /**
 	Initialize automatically the various components of the application
 	according to the configuration data.
 
 	@param $aConfig The configuration data for this application.
 */
 public function __construct($aConfig)
 {
     $this->aConfig = $aConfig;
     // Add path to autoload
     // - All path are separated by : like in PATH environment variable
     // - A // in the path means ROOT_PATH
     if (!empty($this->aConfig['app.autoload.path'])) {
         $aPath = explode(':', $this->aConfig['app.autoload.path']);
         foreach ($aPath as $s) {
             weeAutoload::addPath(str_replace('//', ROOT_PATH, $s));
         }
     }
     // Timezone settings
     if (!empty($this->aConfig['app.timezone'])) {
         date_default_timezone_set($this->aConfig['app.timezone']);
     }
     // Define the default error page from the configuration
     if (!empty($this->aConfig['app.error.default'])) {
         weeException::setErrorPage(str_replace('//', ROOT_PATH, $this->aConfig['app.error.default']));
     }
     // Force selected drivers to start
     $aStart = $this->cnfArray('start');
     foreach ($aStart as $sName => $b) {
         if (!empty($b)) {
             $this->__get($sName);
         }
     }
 }
Exemplo n.º 2
0
<?php

weeException::setErrorPage(ROOT_PATH . 'app/tpl/error_page.tpl');
Exemplo n.º 3
0
 /**
 	Defines a custom error page to be shown when an error or an exception occur.
 	The page can be a PHP script, an HTML page or a plain-text file.
 
 	The $aDebug array is available in the code of this page. You can check if
 	DEBUG is defined and print the debug information if needed.
 
 	The $aDebug array contains the following values:
 		* type: either 'error' or 'exception'
 		* name: name of the error/exception
 		* message: message associated with it
 		* trace: complete trace leading to the uncatched exception
 		* file: the file where the error occurred
 		* line: the line where the error occurred
 
 	An error also has this value:
 		* number: error's number
 
 	@param $sPath The path to the new error page.
 */
 public static function setErrorPage($sPath)
 {
     self::$sErrorPagePath = $sPath;
 }
Exemplo n.º 4
0
 /**
 	Add a result to the result array.
 
 	Results must be either "success" or "skip" or an Exception.
 
 	@param	$sFile			The filename of the unit test case.
 	@param	$mResult		The result of the unit test case.
 	@param	$fTime			Execution time of the test.
 	@throw	DomainException	$mResult is not a valid result.
 */
 protected function addResult($sFile, $mResult, $fTime = 0, $iMemoryUsed = 0)
 {
     $mResult == 'success' or $mResult == 'skip' or is_object($mResult) and $mResult instanceof Exception or burn('DomainException', _WT('$mResult is not a valid result.'));
     $this->aResults[$sFile] = $mResult;
     // Shorten the filename by limiting it to ROOT_PATH when we are inside ROOT_PATH
     // Just improves the display, don't change it for the $aResults array
     $sFile = str_replace(realpath(ROOT_PATH) . '/', '', $sFile);
     if (!is_string($this->mLastResult) || !is_string($mResult)) {
         echo "--\n";
     }
     echo $sFile . ': ';
     if ($mResult === 'success') {
         echo _WT('success') . ' [' . round($fTime, 2) . "s]\n";
         $this->aMemoryResults[$sFile] = $iMemoryUsed;
         $this->aTimeResults[$sFile] = $fTime;
     } elseif ($mResult === 'skip') {
         echo _WT('skip') . "\n";
     } elseif ($mResult instanceof UnitTestException) {
         $aTrace = $mResult->getTrace();
         echo _WT('failure') . "\n" . sprintf(_WT("Message: %s\nLine: %s\n"), $mResult->getMessage(), array_value($aTrace[0], 'line', '?'));
         if ($mResult instanceof ComparisonTestException) {
             echo sprintf(_WT("Expected: %s\nActual: %s\n"), var_export($mResult->getExpected(), true), var_export($mResult->getActual(), true));
         }
     } elseif ($mResult instanceof ErrorException) {
         echo _WT('error') . "\n" . sprintf(_WT("Class: ErrorException\nMessage: %s\nLevel: %s\nFile: %s\nLine: %s\n"), $mResult->getMessage(), weeException::getLevelName($mResult->getSeverity()), $mResult->getFile(), $mResult->getLine());
     } else {
         echo _WT('error') . "\n" . sprintf(_WT("Class: %s\nMessage: %s\nFile: %s\nLine: %s\nTrace:\n%s\n"), get_class($mResult), $mResult->getMessage(), $mResult->getFile(), $mResult->getLine(), $mResult->getTraceAsString());
     }
     $this->mLastResult = $mResult;
 }