Commit bc5247fd authored by Taddeus Kroes's avatar Taddeus Kroes

Added assertion of constant existance.

parent e4ec329a
...@@ -273,10 +273,28 @@ class pQuery { ...@@ -273,10 +273,28 @@ class pQuery {
include_once $path; include_once $path;
} }
} }
/**
* Assert that the given constants have been defined. Add the prefix 'PQUERY_' to each constant name.
*/
static function assert_defined(/* $constant1 [ , $constant2, ... ] */) {
$constants = func_get_args();
$undefined = array();
foreach( $constants as $constant ) {
$constant = 'PQUERY_'.$constant;
if( !defined($constant) )
$undefined[] = $constant;
}
count($undefined) && self::error('The following constants have'
.' not been defined: %s', implode(', ', $undefined));
}
} }
/** /**
* Exception class for error throwing * Exception class for error throwing.
*/ */
class pQueryException extends Exception { class pQueryException extends Exception {
...@@ -331,4 +349,6 @@ class_alias('pQuery', '__p'); ...@@ -331,4 +349,6 @@ class_alias('pQuery', '__p');
*/ */
set_exception_handler('__p::exception_handler'); set_exception_handler('__p::exception_handler');
__p::assert_defined('DEBUG', 'ROOT');
?> ?>
\ No newline at end of file
<?php <?php
/**
* Base and plugin config for pQuery utility framework.
*
* @package pQuery
*/
/** /**
* Indicates whether the framework is in debug mode, which right * Indicates whether the framework is in debug mode, which right
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
include_once '../../simpletest/autorun.php'; include_once '../../simpletest/autorun.php';
include_once 'config.php'; include_once 'config.php';
include_once PQUERY_ROOT.'pquery.php'; include_once '../pquery.php';
function is_test_file($filename) { function is_test_file($filename) {
return preg_match('/^test_\w+\.php$/', $filename); return preg_match('/^test_\w+\.php$/', $filename);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment