From be63aee6e8bfdead83be1ba0a169761d72416b72 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 28 Feb 2023 07:57:12 +0100 Subject: [PATCH] Continued: - no need for redundant code for just test classes, it can be done in the application's 'classes' path --- application/tests/class_ApplicationHelper.php | 9 -- .../console/class_TestsConsoleMainCommand.php | 0 ...lass_TestsConsoleDefaultNewsController.php | 0 .../classes}/filter/class_BaseTestsFilter.php | 0 .../tests/classes}/filter/tests/class_Tests | 0 .../configuration/class_TestConfiguration | 0 ...TestConfigurationLoadableClassesFilter.php | 0 .../class_TestsPhpRequirementsFilter.php | 0 .../class_TestsConsoleCommandResolver.php | 0 .../class_TestsConsoleControllerResolver.php | 0 framework/loader/class_ClassLoader.php | 86 ------------------- 11 files changed, 95 deletions(-) rename {framework/main/tests => application/tests/classes}/commands/console/class_TestsConsoleMainCommand.php (100%) rename {framework/main/tests => application/tests/classes}/controller/console/class_TestsConsoleDefaultNewsController.php (100%) rename {framework/main/tests => application/tests/classes}/filter/class_BaseTestsFilter.php (100%) rename {framework/main/tests => application/tests/classes}/filter/tests/class_Tests (100%) rename {framework/main/tests => application/tests/classes}/filter/tests/configuration/class_TestConfiguration (100%) rename {framework/main/tests => application/tests/classes}/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php (100%) rename {framework/main/tests => application/tests/classes}/filter/tests/requirements/class_TestsPhpRequirementsFilter.php (100%) rename {framework/main/tests => application/tests/classes}/resolver/command/console/class_TestsConsoleCommandResolver.php (100%) rename {framework/main/tests => application/tests/classes}/resolver/controller/class_TestsConsoleControllerResolver.php (100%) diff --git a/application/tests/class_ApplicationHelper.php b/application/tests/class_ApplicationHelper.php index 3d531efd..52b49be7 100644 --- a/application/tests/class_ApplicationHelper.php +++ b/application/tests/class_ApplicationHelper.php @@ -97,9 +97,6 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication * @return void */ public function initApplication () { - // Get config instance - $cfg = FrameworkBootstrap::getConfigurationInstance(); - // Initialize output system self::createDebugInstance('ApplicationHelper'); @@ -108,12 +105,6 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication * method. */ FrameworkBootstrap::initDatabaseInstance(); - - // Register core tests - ClassLoader::registerTestsPath('framework/main/tests'); - - // Scan for them now - ClassLoader::scanTestsClasses(); } /** diff --git a/framework/main/tests/commands/console/class_TestsConsoleMainCommand.php b/application/tests/classes/commands/console/class_TestsConsoleMainCommand.php similarity index 100% rename from framework/main/tests/commands/console/class_TestsConsoleMainCommand.php rename to application/tests/classes/commands/console/class_TestsConsoleMainCommand.php diff --git a/framework/main/tests/controller/console/class_TestsConsoleDefaultNewsController.php b/application/tests/classes/controller/console/class_TestsConsoleDefaultNewsController.php similarity index 100% rename from framework/main/tests/controller/console/class_TestsConsoleDefaultNewsController.php rename to application/tests/classes/controller/console/class_TestsConsoleDefaultNewsController.php diff --git a/framework/main/tests/filter/class_BaseTestsFilter.php b/application/tests/classes/filter/class_BaseTestsFilter.php similarity index 100% rename from framework/main/tests/filter/class_BaseTestsFilter.php rename to application/tests/classes/filter/class_BaseTestsFilter.php diff --git a/framework/main/tests/filter/tests/class_Tests b/application/tests/classes/filter/tests/class_Tests similarity index 100% rename from framework/main/tests/filter/tests/class_Tests rename to application/tests/classes/filter/tests/class_Tests diff --git a/framework/main/tests/filter/tests/configuration/class_TestConfiguration b/application/tests/classes/filter/tests/configuration/class_TestConfiguration similarity index 100% rename from framework/main/tests/filter/tests/configuration/class_TestConfiguration rename to application/tests/classes/filter/tests/configuration/class_TestConfiguration diff --git a/framework/main/tests/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php b/application/tests/classes/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php similarity index 100% rename from framework/main/tests/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php rename to application/tests/classes/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php diff --git a/framework/main/tests/filter/tests/requirements/class_TestsPhpRequirementsFilter.php b/application/tests/classes/filter/tests/requirements/class_TestsPhpRequirementsFilter.php similarity index 100% rename from framework/main/tests/filter/tests/requirements/class_TestsPhpRequirementsFilter.php rename to application/tests/classes/filter/tests/requirements/class_TestsPhpRequirementsFilter.php diff --git a/framework/main/tests/resolver/command/console/class_TestsConsoleCommandResolver.php b/application/tests/classes/resolver/command/console/class_TestsConsoleCommandResolver.php similarity index 100% rename from framework/main/tests/resolver/command/console/class_TestsConsoleCommandResolver.php rename to application/tests/classes/resolver/command/console/class_TestsConsoleCommandResolver.php diff --git a/framework/main/tests/resolver/controller/class_TestsConsoleControllerResolver.php b/application/tests/classes/resolver/controller/class_TestsConsoleControllerResolver.php similarity index 100% rename from framework/main/tests/resolver/controller/class_TestsConsoleControllerResolver.php rename to application/tests/classes/resolver/controller/class_TestsConsoleControllerResolver.php diff --git a/framework/loader/class_ClassLoader.php b/framework/loader/class_ClassLoader.php index 9e9b7fef..3f4422cd 100644 --- a/framework/loader/class_ClassLoader.php +++ b/framework/loader/class_ClassLoader.php @@ -352,55 +352,6 @@ final class ClassLoader { //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__); } - /** - * Scans for test classes, etc. - * - * @return void - * @throws UnexpectedValueException If a given path isn't one or not readable - */ - public static function scanTestsClasses () { - // Get loader instance - //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__); - $loaderInstance = self::getSelfInstance(); - - // "Cache" root base path - $basePath = self::$configInstance->getConfigEntry('root_base_path'); - - // Load all classes for the application - //* NOISY-DEBUG: */ printf('[%s:%d]: self::testPaths()=%d,basePath=%s' . PHP_EOL, __METHOD__, __LINE__, count(self::$testPaths), $basePath); - foreach (self::$testPaths as $shortPath) { - // Construct path name - //* NOISY-DEBUG: */ printf('[%s:%d]: shortPath=%s' . PHP_EOL, __METHOD__, __LINE__, $shortPath); - $realPathName = realpath(sprintf( - '%s%s%s', - $basePath, - DIRECTORY_SEPARATOR, - $shortPath - )); - - // Is the path readable? - //* NOISY-DEBUG: */ printf('[%s:%d]: realPathName[%s]=%s - AFTER!' . PHP_EOL, __METHOD__, __LINE__, gettype($realPathName), $realPathName); - if (!is_string($realPathName)) { - // Skip this cone - //* NOISY-DEBUG: */ printf('[%s:%d]: realPathName[]=%s - SKIPPED!' . PHP_EOL, __METHOD__, __LINE__, gettype($realPathName)); - continue; - } elseif (!is_dir($realPathName)) { - // Is not a directory - throw new UnexpectedValueException(sprintf('realPathName=%s is not a directory', $realPathName), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE); - } elseif (!is_readable($realPathName)) { - // Not readable - throw new UnexpectedValueException(sprintf('realPathName=%s cannot be read from', $realPathName), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE); - } - - // Try to load the application classes - //* NOISY-DEBUG: */ printf('[%s:%d]: Scanning for classes/interfaces at realPathName=%s ...' . PHP_EOL, __METHOD__, __LINE__, $realPathName); - $loaderInstance->scanClassPath($realPathName); - } - - // Trace message - //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__); - } - /** * Enables or disables strict naming-convention tests on class loading * @@ -411,43 +362,6 @@ final class ClassLoader { self::$strictNamingConvention = $strictNamingConvention; } - /** - * 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 - * @throws InvalidArgumentException If a parameter is invalid or path not found - */ - public static function registerTestsPath (string $relativePath) { - // Validate parameter - //* NOISY-DEBUG: */ printf('[%s:%d]: relativePath=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $relativePath); - if (empty($relativePath)) { - // Should not be empty - throw new InvalidArgumentException('Parameter "relativePath" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); - } - - // Get real path from it - $fullQualifiedPath = self::$configInstance->getConfigEntry('root_base_path') . $relativePath; - - // Is it there? - //* NOISY-DEBUG: */ printf('[%s:%d]: fullQualifiedPath=%s' . PHP_EOL, __METHOD__, __LINE__, $fullQualifiedPath); - if (!is_dir($fullQualifiedPath)) { - // Not there - throw new InvalidArgumentException(sprintf('fullQualifiedPath=%s cannot be found', $fullQualifiedPath)); - } elseif (!is_readable($fullQualifiedPath)) { - // Not readable - throw new InvalidArgumentException(sprintf('fullQualifiedPath=%s is not readable', $fullQualifiedPath)); - } - - // "Register" it - //* NOISY-DEBUG: */ printf('[%s:%d]: Adding relativePath=%s ...' . PHP_EOL, __METHOD__, __LINE__, $relativePath); - self::$testPaths[$relativePath] = $relativePath; - - // Trace message - //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__); - } - /** * Autoload-function * -- 2.39.2