]> git.mxchange.org Git - core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 28 Feb 2023 08:13:31 +0000 (09:13 +0100)
committerRoland Häder <roland@mxchange.org>
Tue, 28 Feb 2023 08:13:31 +0000 (09:13 +0100)
- improved/added debug messages

application/tests/class_ApplicationHelper.php
application/tests/classes/commands/console/class_TestsConsoleMainCommand.php
application/tests/classes/controller/console/class_TestsConsoleDefaultNewsController.php
application/tests/classes/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php

index 52b49be71382ccc09d07e06cb6a01d3ed42556a5..161f9fc2faa71748d86fbf8bc26f91236918520d 100644 (file)
@@ -148,9 +148,9 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication
                $this->getControllerInstance()->handleRequest($requestInstance, $responseInstance);
 
                // -------------------------- Shutdown phase --------------------------
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: Shutdown in progress ...');
+               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('MAIN: Shutdown in progress ...');
                $this->getControllerInstance()->executeShutdownFilters($requestInstance, $responseInstance);
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: Shutdown completed. (This is the last line.)');
+               self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('MAIN: Shutdown completed. (This is the last line.)');
        }
 
        /**
index c4072c88d6fc781dc6e6d33c0db3d76f2a9a8c46..91bb107ec35b4b9f785ddbf7c4506dea5a929669 100644 (file)
@@ -71,7 +71,8 @@ class TestsConsoleMainCommand extends BaseCommand implements Commandable {
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Debug message
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Starting tests ... ---');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONSOLE-MAIN-COMMAND: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
+               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('MAIN: --- Starting tests ... ---');
 
                // Get controller
                $controllerInstance = ObjectRegistry::getRegistry('generic')->getInstance('controller');
@@ -80,7 +81,8 @@ class TestsConsoleMainCommand extends BaseCommand implements Commandable {
                $controllerInstance->executeTestsFilters($requestInstance, $responseInstance);
 
                // Debug message
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main ... ---');
+               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('MAIN: --- Leaving main ... ---');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONSOLE-MAIN-COMMAND: EXIT!');
        }
 
        /**
@@ -92,10 +94,14 @@ class TestsConsoleMainCommand extends BaseCommand implements Commandable {
         */
        public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
                // Add pre filters (e.g. for requirements checks)
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONSOLE-MAIN-COMMAND: controllerInstance=%s,requestInstance=%s - CALLED!', $controllerInstance->__toString(), $requestInstance->__toString()));
                $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('tests_php_requirements_filter_class'));
 
                // Add 'tests' filters which will run the actual tests
                $controllerInstance->addTestsFilter(ObjectFactory::createObjectByConfiguredName('tests_configuration_classes_loadable_test_filter_class'));
+
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONSOLE-MAIN-COMMAND: EXIT!');
        }
 
 }
index 589c80d5cbb0f0b27c8bb49d66e7b0f2d3baa867..630cf65ac8aa9dcc4cb09f293bed05b6b0b3d787 100644 (file)
@@ -41,17 +41,18 @@ class TestsConsoleDefaultNewsController extends BaseController implements Contro
         */
        private function __construct () {
                // Call parent constructor
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: CONSTRUCTED!');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: CONSTRUCTED!');
                parent::__construct(__CLASS__);
 
                // Init additional filter chains
                foreach (['bootstrap', 'tests', BaseController::FILTER_CHAIN_SHUTDOWN] as $filterChain) {
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: Initializing filterChain=%s ...', $filterChain));
+                       // Init filter chain
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: Initializing filterChain=%s ...', $filterChain));
                        $this->initFilterChain($filterChain);
                }
 
                // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: EXIT!');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: EXIT!');
        }
 
        /**
@@ -62,7 +63,7 @@ class TestsConsoleDefaultNewsController extends BaseController implements Contro
         */
        public static final function createTestsConsoleDefaultNewsController (CommandResolver $resolverInstance) {
                // Create the instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: resolverInstance=%s - CALLED!', $resolverInstance->__toString()));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: resolverInstance=%s - CALLED!', $resolverInstance->__toString()));
                $controllerInstance = new TestsConsoleDefaultNewsController();
 
                // Set the command resolver
@@ -73,7 +74,7 @@ class TestsConsoleDefaultNewsController extends BaseController implements Contro
                $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter_class'));
 
                // Return the prepared instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: controllerInstance=%s - EXIT!', $controllerInstance->__toString()));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: controllerInstance=%s - EXIT!', $controllerInstance->__toString()));
                return $controllerInstance;
        }
 
@@ -86,7 +87,7 @@ class TestsConsoleDefaultNewsController extends BaseController implements Contro
         */
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
                // Get the command instance from the resolver by sending a request instance to the resolver
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
                $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
 
                // Add more filters by the command
@@ -96,7 +97,7 @@ class TestsConsoleDefaultNewsController extends BaseController implements Contro
                $this->executePreFilters($requestInstance, $responseInstance);
 
                // This request was valid! :-D
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: Invoking requestInstance->setIsRequestValid(TRUE) ...');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: Invoking requestInstance->setIsRequestValid(TRUE) ...');
                $requestInstance->setIsRequestValid(TRUE);
 
                // Execute the command
@@ -106,11 +107,11 @@ class TestsConsoleDefaultNewsController extends BaseController implements Contro
                $this->executePostFilters($requestInstance, $responseInstance);
 
                // Flush the response out
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: Invoking responseInstance->flushBuffer() ...');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: Invoking responseInstance->flushBuffer() ...');
                $responseInstance->flushBuffer();
 
                // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: EXIT!');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: EXIT!');
        }
 
        /**
index 5ae43556a357e7bc034f54dfc0ef19bf3e134a08..4d7ce58e5079249b5d546ecc589ef3ad3f03fcd2 100644 (file)
@@ -52,9 +52,11 @@ class TestConfigurationLoadableClassesFilter extends BaseTestsFilter implements
         */
        public final static function createTestConfigurationLoadableClassesFilter () {
                // Get a new instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONFIGURATION-LOADABLE-CLASSES-FILTER: CALLED!');
                $filterInstance = new TestConfigurationLoadableClassesFilter();
 
                // Return the instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONFIGURATION-LOADABLE-CLASSES-FILTER: filterInstance=%s - EXIT!', $filterInstance->__toString()));
                return $filterInstance;
        }
 
@@ -67,7 +69,7 @@ class TestConfigurationLoadableClassesFilter extends BaseTestsFilter implements
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Init counter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TESTS-CONFIGURATION-LOADABLE-CLASSES-FILTER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONFIGURATION-LOADABLE-CLASSES-FILTER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
                $passed = 0;
                $failed = 0;
                $skipped = 0;
@@ -75,37 +77,31 @@ class TestConfigurationLoadableClassesFilter extends BaseTestsFilter implements
                // Loop through all configuration keys
                foreach (FrameworkBootstrap::getConfigurationInstance()->getConfigurationArray() as $configKey => $configValue) {
                        // Key must end with _class
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TESTS-CONFIGURATION-LOADABLE-CLASSES-FILTER: configKey[%s]=%s,configValue[%s]=%s', gettype($configKey), $configKey, gettype($configValue), $configValue));
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TESTS-CONFIGURATION-LOADABLE-CLASSES-FILTER: configKey[%s]=%s,configValue[%s]=%s', gettype($configKey), $configKey, gettype($configValue), $configValue));
                        if (substr($configKey, -6, 6) != '_class') {
                                // Skip this
                                $skipped++;
                                continue;
                        }
 
-                       // Output message
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Testing configKey[%s]=%s,configValue[%s]=%s', gettype($configKey), $configKey, gettype($configValue), $configValue));
-
                        // This may throw exceptions
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('Testing configKey[%s]=%s,configValue[%s]=%s', gettype($configKey), $configKey, gettype($configValue), $configValue));
                        try {
                                // Is the config entry valid and class is there?
                                if (!is_string($configValue)) {
-                                       // Is not a string
-                                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('configValue=%s has unexpected type "%s", required: string - FAILED!', $configValue, gettype($configValue)));
-
                                        // Skip further tests
+                                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('configValue=%s has unexpected type "%s", required: string - FAILED!', $configValue, gettype($configValue)));
                                        $failed++;
                                        continue;
                                } elseif (!class_exists($configValue)) {
-                                       // Class not found
-                                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Class "%s" not found. FAILED!', $configValue));
-
                                        // Skip further tests
+                                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('Class "%s" not found. FAILED!', $configValue));
                                        $failed++;
                                        continue;
                                }
                        } catch (InvalidArgumentException $e) {
                                // Maybe not conform?
-                               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Class "%s" failed to load. Message: "%s"', $configValue, $e->getMessage()));
+                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('Class "%s" failed to load. Message: "%s"', $configValue, $e->getMessage()));
 
                                // Skip further tests
                                $failed++;
@@ -113,12 +109,12 @@ class TestConfigurationLoadableClassesFilter extends BaseTestsFilter implements
                        }
 
                        // class_exists() didn't fail
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Class "%s" loaded successfully. OKAY', $configValue));
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('Class "%s" loaded successfully. OKAY', $configValue));
                        $passed++;
                }
 
                // Output result
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Test result: %d okay, %d failed (%0.02f%% passed), %d skipped - EXIT!', $passed, $failed, ($passed / ($passed + $failed) * 100), $skipped));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('Test result: %d okay, %d failed (%0.02f%% passed), %d skipped - EXIT!', $passed, $failed, ($passed / ($passed + $failed) * 100), $skipped));
        }
 
 }