'middleware' // The middleware
);
+ /**
+ * Registered paths where test classes can be found. These are all relative
+ * to base_path .
+ */
+ private static $testPaths = array();
/**
* The protected constructor. Please use the factory method below, or use
* @return void
*/
protected function __construct () {
- // Is currently empty
+ // This is empty for now
}
/**
$loaderInstance = self::getSelfInstance();
// Load all classes
- foreach (self::$frameworkPaths as $pathName) {
+ foreach (self::$frameworkPaths as $shortPath) {
// Debug message
- //* NOISY-DEBUG: */ printf('[%s:%d]: pathName=%s' . PHP_EOL, __METHOD__, __LINE__, $pathName);
+ //* NOISY-DEBUG: */ printf('[%s:%d]: shortPath=%s' . PHP_EOL, __METHOD__, __LINE__, $shortPath);
// Try to load the framework classes
- $loaderInstance->scanClassPath('framework/main/' . $pathName . '/');
+ $loaderInstance->scanClassPath(sprintf('framework/main/%s/', $shortPath));
} // END - foreach
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
/**
$cfg = FrameworkConfiguration::getSelfInstance();
// Load all classes for the application
- foreach (self::$frameworkPaths as $class) {
+ foreach (self::$frameworkPaths as $shortPath) {
+ // Debug message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: shortPath=%s' . PHP_EOL, __METHOD__, __LINE__, $shortPath);
+
// Create path name
- $pathName = sprintf('%s/%s/%s', $cfg->getConfigEntry('application_path'), $cfg->getConfigEntry('app_name'), $class);
+ $pathName = realpath(sprintf(
+ '%s/%s/%s',
+ $cfg->getConfigEntry('application_path'),
+ $cfg->getConfigEntry('app_name'),
+ $shortPath
+ ));
// Debug message
- //* NOISY-DEBUG: */ printf('[%s:%d]: pathName=%s' . PHP_EOL, __METHOD__, __LINE__, $pathName);
+ //* NOISY-DEBUG: */ printf('[%s:%d]: pathName[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($pathName), $pathName);
// Is the path readable?
if (is_dir($pathName)) {
ClassLoader::getSelfInstance()->scanClassPath($pathName);
} // END - if
} // END - foreach
+
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
}
/**
- * Initializes our loader class
+ * Scans for test classes, etc.
*
- * @param $configInstance Configuration class instance
* @return void
*/
- protected function initLoader (FrameworkConfiguration $configInstance) {
- // Set configuration instance
- $this->configInstance = $configInstance;
-
- // Construct the FQFN for the cache
- if (!defined('DEVELOPER')) {
- $this->listCacheFQFN = $this->configInstance->getConfigEntry('local_db_path') . 'list-' . $this->configInstance->getConfigEntry('app_name') . '.cache';
- $this->classCacheFQFN = $this->configInstance->getConfigEntry('local_db_path') . 'class-' . $this->configInstance->getConfigEntry('app_name') . '.cache';
- } // END - if
-
- // Set suffix and prefix from configuration
- $this->suffix = $configInstance->getConfigEntry('class_suffix');
- $this->prefix = $configInstance->getConfigEntry('class_prefix');
+ public static function scanTestsClasses () {
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
- // Set own instance
- self::$selfInstance = $this;
+ // Get config instance
+ $cfg = FrameworkConfiguration::getSelfInstance();
- // Skip here if no dev-mode
- if (defined('DEVELOPER')) {
- return;
- } // END - if
+ // Load all classes for the application
+ foreach (self::$testPaths as $shortPath) {
+ // Debug message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: shortPath=%s' . PHP_EOL, __METHOD__, __LINE__, $shortPath);
- // IS the cache there?
- if (BaseFrameworkSystem::isReadableFile($this->listCacheFQFN)) {
- // Get content
- $cacheContent = file_get_contents($this->listCacheFQFN);
+ // Create path name
+ $pathName = realpath(sprintf(
+ '%s/%s',
+ $cfg->getConfigEntry('base_path'),
+ $shortPath
+ ));
- // And convert it
- $this->foundClasses = json_decode($cacheContent);
+ // Debug message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: pathName[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($pathName), $pathName);
- // List has been restored from cache!
- $this->listCached = TRUE;
- } // END - if
+ // Is the path readable?
+ if (is_dir($pathName)) {
+ // Try to load the application classes
+ ClassLoader::getSelfInstance()->scanClassPath($pathName);
+ } // END - if
+ } // END - foreach
- // Does the class cache exist?
- if (BaseFrameworkSystem::isReadableFile($this->listCacheFQFN)) {
- // Then include it
- require($this->classCacheFQFN);
+ // Trace message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
+ }
- // Mark the class cache as loaded
- $this->classesCached = TRUE;
- } // END - if
+ /**
+ * Registeres given relative path where test classes reside. For regular
+ * framework uses, they should not be loaded (and used).
+ *
+ * @param $relativePath Relative path to test classes
+ * @return void
+ */
+ public static function registerTestsPath ($relativePath) {
+ // "Register" it
+ self::$testPaths[$relativePath] = $relativePath;
}
/**
$this->prefix = $oldPrefix;
}
+ /**
+ * Initializes our loader class
+ *
+ * @param $configInstance Configuration class instance
+ * @return void
+ */
+ private function initLoader (FrameworkConfiguration $configInstance) {
+ // Set configuration instance
+ $this->configInstance = $configInstance;
+
+ // Construct the FQFN for the cache
+ if (!defined('DEVELOPER')) {
+ $this->listCacheFQFN = $this->configInstance->getConfigEntry('local_db_path') . 'list-' . $this->configInstance->getConfigEntry('app_name') . '.cache';
+ $this->classCacheFQFN = $this->configInstance->getConfigEntry('local_db_path') . 'class-' . $this->configInstance->getConfigEntry('app_name') . '.cache';
+ } // END - if
+
+ // Set suffix and prefix from configuration
+ $this->suffix = $configInstance->getConfigEntry('class_suffix');
+ $this->prefix = $configInstance->getConfigEntry('class_prefix');
+
+ // Set own instance
+ self::$selfInstance = $this;
+
+ // Skip here if no dev-mode
+ if (defined('DEVELOPER')) {
+ return;
+ } // END - if
+
+ // IS the cache there?
+ if (BaseFrameworkSystem::isReadableFile($this->listCacheFQFN)) {
+ // Get content
+ $cacheContent = file_get_contents($this->listCacheFQFN);
+
+ // And convert it
+ $this->foundClasses = json_decode($cacheContent);
+
+ // List has been restored from cache!
+ $this->listCached = TRUE;
+ } // END - if
+
+ // Does the class cache exist?
+ if (BaseFrameworkSystem::isReadableFile($this->listCacheFQFN)) {
+ // Then include it
+ require($this->classCacheFQFN);
+
+ // Mark the class cache as loaded
+ $this->classesCached = TRUE;
+ } // END - if
+ }
+
/**
* Tries to find the given class in our list. This method ignores silently
* missing classes or interfaces. So if you use class_exists() this method