]> git.mxchange.org Git - core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Fri, 17 Feb 2023 16:18:07 +0000 (17:18 +0100)
committerRoland Häder <roland@mxchange.org>
Fri, 17 Feb 2023 16:22:14 +0000 (17:22 +0100)
- also check if root_base_path + relative path from parameter is a
  readable directory
- applications/tests/tests/ is redudant here

application/tests/class_ApplicationHelper.php
framework/loader/class_ClassLoader.php

index 3d69f0fc1673b40e76b9e9767c98d2f2ea355a5a..bb32d2e08bb4995a311e5ce59371f689c703d64b 100644 (file)
@@ -111,9 +111,6 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication
                // Register core tests
                ClassLoader::registerTestsPath('framework/main/tests');
 
-               // Register own tests
-               ClassLoader::registerTestsPath('application/tests/tests');
-
                // Scan for them now
                ClassLoader::scanTestsClasses();
        }
index b31d21fbc455ab8531cf530f3261070eaaca2742..07dfd8420b77bfbbd01441bb9bac0ffb3f40ddec 100644 (file)
@@ -342,17 +342,31 @@ final class ClassLoader {
         *
         * @param       $relativePath   Relative path to test classes
         * @return      void
-        * @throws      InvalidArgumentException        If a parameter is invalid
+        * @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 = FrameworkBootstrap::getConfigurationInstance()->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]: relativePath=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $relativePath);
+               //* NOISY-DEBUG: */ printf('[%s:%d]: Adding relativePath=%s ...' . PHP_EOL, __METHOD__, __LINE__, $relativePath);
                self::$testPaths[$relativePath] = $relativePath;
 
                // Trace message