From def3387cce94074b6d4c6b73d33b0672dfd04f83 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 2 Mar 2023 02:44:37 +0100 Subject: [PATCH] Continued: - overall improval of framework tests (they aren't unit tests) - added framework test for is_*_enabled configuration keys - turned some Y/N into boolean (isEnabled() invoked instead of getConfigKey() == 'Y') --- .../console/class_TestsConsoleMainCommand.php | 3 +- .../tests/classes/filter/tests/class_Tests | 21 +++- ...Configuration => class_TestsConfiguration} | 29 ++++- ...TestConfigurationLoadableClassesFilter.php | 20 +-- ...lass_TestsConfigurationIsEnabledFilter.php | 119 ++++++++++++++++++ .../class_TestsPhpRequirementsFilter.php | 21 +++- application/tests/config.php | 7 +- framework/config-global.php | 12 +- .../binary/class_BaseBinaryFile.php | 2 +- .../debug/class_DebugMiddleware.php | 46 +++++-- 10 files changed, 248 insertions(+), 32 deletions(-) rename application/tests/classes/filter/tests/configuration/{class_TestConfiguration => class_TestsConfiguration} (59%) create mode 100644 application/tests/classes/filter/tests/configuration/is_enabled/class_TestsConfigurationIsEnabledFilter.php diff --git a/application/tests/classes/commands/console/class_TestsConsoleMainCommand.php b/application/tests/classes/commands/console/class_TestsConsoleMainCommand.php index 91bb107e..a88b0971 100644 --- a/application/tests/classes/commands/console/class_TestsConsoleMainCommand.php +++ b/application/tests/classes/commands/console/class_TestsConsoleMainCommand.php @@ -98,7 +98,8 @@ class TestsConsoleMainCommand extends BaseCommand implements Commandable { $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')); + $controllerInstance->addTestsFilter(ObjectFactory::createObjectByConfiguredName('tests_configuration_classes_loadable_filter_class')); + $controllerInstance->addTestsFilter(ObjectFactory::createObjectByConfiguredName('tests_configuration_is_enabled_filter_class')); // Trace message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONSOLE-MAIN-COMMAND: EXIT!'); diff --git a/application/tests/classes/filter/tests/class_Tests b/application/tests/classes/filter/tests/class_Tests index ed4ff6d5..a5a1bc4e 100644 --- a/application/tests/classes/filter/tests/class_Tests +++ b/application/tests/classes/filter/tests/class_Tests @@ -1,14 +1,18 @@ traceMessage('TESTS-|||-FILTER: CALLED!'); $filterInstance = new Tests???Filter(); // Return the instance + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-|||-FILTER: filterInstance=%s - EXIT!', $filterInstance->__toString())); return $filterInstance; } @@ -64,8 +70,21 @@ class Tests???Filter extends BaseTestsFilter implements Filterable { * @todo 0% done */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Init counter + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-|||-FILTER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString())); + $passed = $failed = $skipped = $warning = 0; + // Implement this! DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.'); + + // Calculate percentage + $percent = (($passed + $failed) > 0 ? ($passed / ($passed + $failed) * 100) : 0); + + // Output result + self::createDebugInstance(__CLASS__, __LINE__)->infoMessage(sprintf('Test result: %d okay, %d failed (%0.02f%% passed), %d skipped, %d warnings', $passed, $failed, $percent, $skipped, $warning)); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-|||-FILTER: EXIT!'); } } diff --git a/application/tests/classes/filter/tests/configuration/class_TestConfiguration b/application/tests/classes/filter/tests/configuration/class_TestsConfiguration similarity index 59% rename from application/tests/classes/filter/tests/configuration/class_TestConfiguration rename to application/tests/classes/filter/tests/configuration/class_TestsConfiguration index f3205439..e6240ea9 100644 --- a/application/tests/classes/filter/tests/configuration/class_TestConfiguration +++ b/application/tests/classes/filter/tests/configuration/class_TestsConfiguration @@ -1,16 +1,20 @@ * @version 0.0.0 @@ -31,7 +35,7 @@ use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class TestConfiguration???Filter extends BaseTestsFilter implements Filterable { +class TestsConfiguration???Filter extends BaseTestsFilter implements Filterable { /** * Protected constructor * @@ -47,11 +51,13 @@ class TestConfiguration???Filter extends BaseTestsFilter implements Filterable { * * @return $filterInstance An instance of this filter class */ - public final static function createTestConfiguration???Filter () { + public final static function createTestsConfiguration???Filter () { // Get a new instance - $filterInstance = new TestConfiguration???Filter(); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONFIGURATION-|||-FILTER: CALLED!'); + $filterInstance = new TestsConfiguration???Filter(); // Return the instance + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONFIGURATION-|||-FILTER: filterInstance=%s - EXIT!', $filterInstance->__toString())); return $filterInstance; } @@ -64,8 +70,21 @@ class TestConfiguration???Filter extends BaseTestsFilter implements Filterable { * @todo 0% done */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Init counter + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONFIGURATION-|||-FILTER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString())); + $passed = $failed = $skipped = $warning = 0; + // Implement this! DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.'); + + // Calculate percentage + $percent = (($passed + $failed) > 0 ? ($passed / ($passed + $failed) * 100) : 0); + + // Output result + self::createDebugInstance(__CLASS__, __LINE__)->infoMessage(sprintf('Test result: %d okay, %d failed (%0.02f%% passed), %d skipped, %d warning - EXIT!', $passed, $failed, $percent, $skipped, $warning)); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONFIGURATION-|||-FILTER: EXIT!'); } } diff --git a/application/tests/classes/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php b/application/tests/classes/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php index 4d7ce58e..38990d15 100644 --- a/application/tests/classes/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php +++ b/application/tests/classes/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php @@ -70,14 +70,12 @@ class TestConfigurationLoadableClassesFilter extends BaseTestsFilter implements public function execute (Requestable $requestInstance, Responseable $responseInstance) { // Init counter /* 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; + $passed = $failed = $skipped = $warning = 0; // Loop through all configuration keys foreach (FrameworkBootstrap::getConfigurationInstance()->getConfigurationArray() as $configKey => $configValue) { // Key must end with _class - /* 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)); + //* 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++; @@ -90,18 +88,18 @@ class TestConfigurationLoadableClassesFilter extends BaseTestsFilter implements // Is the config entry valid and class is there? if (!is_string($configValue)) { // Skip further tests - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('configValue=%s has unexpected type "%s", required: string - FAILED!', $configValue, gettype($configValue))); + self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('configValue=%s has unexpected type "%s", required: string - FAILED!', $configValue, gettype($configValue))); $failed++; continue; } elseif (!class_exists($configValue)) { // Skip further tests - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('Class "%s" not found. FAILED!', $configValue)); + self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('Class "%s" not found. FAILED!', $configValue)); $failed++; continue; } } catch (InvalidArgumentException $e) { // Maybe not conform? - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('Class "%s" failed to load. Message: "%s"', $configValue, $e->getMessage())); + self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('Class "%s" failed to load. Message: "%s"', $configValue, $e->getMessage())); // Skip further tests $failed++; @@ -113,8 +111,14 @@ class TestConfigurationLoadableClassesFilter extends BaseTestsFilter implements $passed++; } + // Calculate percentage + $percent = (($passed + $failed) > 0 ? ($passed / ($passed + $failed) * 100) : 0); + // Output result - /* 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)); + self::createDebugInstance(__CLASS__, __LINE__)->infoMessage(sprintf('Test result: %d okay, %d failed (%0.02f%% passed), %d skipped, %d warning - EXIT!', $passed, $failed, $percent, $skipped, $warning)); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONFIGURATION-LOADABLE-CLASSES-FILTER: EXIT!'); } } diff --git a/application/tests/classes/filter/tests/configuration/is_enabled/class_TestsConfigurationIsEnabledFilter.php b/application/tests/classes/filter/tests/configuration/is_enabled/class_TestsConfigurationIsEnabledFilter.php new file mode 100644 index 00000000..1e4ae6ad --- /dev/null +++ b/application/tests/classes/filter/tests/configuration/is_enabled/class_TestsConfigurationIsEnabledFilter.php @@ -0,0 +1,119 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class TestsConfigurationIsEnabledFilter extends BaseTestsFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + private function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createTestsConfigurationIsEnabledFilter () { + // Get a new instance + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONFIGURATION-IS-ENABLED-FILTER: CALLED!'); + $filterInstance = new TestsConfigurationIsEnabledFilter(); + + // Return the instance + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONFIGURATION-IS-ENABLED-FILTER: filterInstance=%s - EXIT!', $filterInstance->__toString())); + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Init counter + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONFIGURATION-IS-ENABLED-FILTER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString())); + $passed = $failed = $skipped = $warning = 0; + + // Loop through all configuration keys + foreach (FrameworkBootstrap::getConfigurationInstance()->getConfigurationArray() as $configKey => $configValue) { + // Key must end with _class + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TESTS-CONFIGURATION-IS-ENABLED-FILTER: configKey[%s]=%s,configValue[%s]=%s', gettype($configKey), $configKey, gettype($configValue), $configValue)); + if (substr($configKey, 0, 3) != 'is_' && substr($configKey, -8, 8) != '_enabled') { + // Is this a boolean value? + if (is_bool($configValue)) { + // Issue a warning + self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('TESTS-CONFIGURATION-IS-ENABLED-FILTER: comnfigKey=%s has a boolean value[]=%s', $configKey, gettype($configValue))); + $warning++; + } else { + // Mark as skipped + self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('TESTS-CONFIGURATION-IS-ENABLED-FILTER: comnfigKey=%s is not wanted here - SKIPPED!', $configKey)); + $skipped++; + } + + // Skip this + continue; + } + + // Is it boolean? + if (!is_bool($configValue)) { + // Failed! + self::createDebugInstance(__CLASS__, __LINE__)->warningMessage(sprintf('Configuration key "%s" is NOT boolean. FAILED', $configKey)); + $failed++; + } else { + // Count as success + self::createDebugInstance(__CLASS__, __LINE__)->debugMessage(sprintf('Configuration key "%s" is a boolean feature. OKAY', $configKey)); + $passed++; + } + } + + // Calculate percentage + $percent = (($passed + $failed) > 0 ? ($passed / ($passed + $failed) * 100) : 0); + + // Output result + self::createDebugInstance(__CLASS__, __LINE__)->infoMessage(sprintf('Test result: %d okay, %d failed (%0.02f%% passed), %d skipped, $d warnings', $passed, $failed, $percent, $skipped, $warning)); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONFIGURATION-IS-ENABLED-FILTER: EXIT!'); + } + +} diff --git a/application/tests/classes/filter/tests/requirements/class_TestsPhpRequirementsFilter.php b/application/tests/classes/filter/tests/requirements/class_TestsPhpRequirementsFilter.php index f390e7f4..2d8b9916 100644 --- a/application/tests/classes/filter/tests/requirements/class_TestsPhpRequirementsFilter.php +++ b/application/tests/classes/filter/tests/requirements/class_TestsPhpRequirementsFilter.php @@ -1,14 +1,18 @@ traceMessage('TESTS-PHP-REQUIREMENTS-FILTER: CALLED!'); $filterInstance = new TestsPhpRequirementsFilter(); // Return the instance + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-PHP-REQUIREMENTS-FILTER: filterInstance=%s - EXIT!', $filterInstance->__toString())); return $filterInstance; } @@ -64,8 +70,21 @@ class TestsPhpRequirementsFilter extends BaseTestsFilter implements Filterable { * @todo 0% done */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Init counter + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-PHP-REQUIREMENTS-FILTER: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString())); + $passed = $failed = $skipped = $warning = 0; + // Implement this! DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.'); + + // Calculate percentage + $percent = (($passed + $failed) > 0 ? ($passed / ($passed + $failed) * 100) : 0); + + // Output result + self::createDebugInstance(__CLASS__, __LINE__)->infoMessage(sprintf('Test result: %d okay, %d failed (%0.02f%% passed), %d skipped, %d warnings', $passed, $failed, $percent, $skipped, $warning)); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-PHP-REQUIREMENTS-FILTER: EXIT!'); } } diff --git a/application/tests/config.php b/application/tests/config.php index af8d854f..17ffa867 100644 --- a/application/tests/config.php +++ b/application/tests/config.php @@ -52,10 +52,13 @@ $cfg->setConfigEntry('news_reader_main_class', 'Org\Mxchange\CoreFramework\Reade $cfg->setConfigEntry('news_main_limit', 5); // CFG: TESTS-PHP-REQUIREMENTS-FILTER -$cfg->setConfigEntry('tests_php_requirements_filter_class', 'Org\Mxchange\CoreFramework\Tests\Filter\Requirements\TestsPhpRequirementsFilter'); +$cfg->setConfigEntry('tests_php_requirements_filter_class', 'Org\Mxchange\CoreFramework\Tests\Filter\PhpRequirements\TestsPhpRequirementsFilter'); // CFG: TEST-CONFIGURATION-CLASSES-LOADABLE-TEST-FILTER-CLASS -$cfg->setConfigEntry('tests_configuration_classes_loadable_test_filter_class', 'Org\Mxchange\CoreFramework\Tests\Filter\Configuration\Classes\TestConfigurationLoadableClassesFilter'); +$cfg->setConfigEntry('tests_configuration_classes_loadable_filter_class', 'Org\Mxchange\CoreFramework\Tests\Filter\Configuration\Classes\TestConfigurationLoadableClassesFilter'); + +// CFG: TEST-CONFIGURATION-IS-ENABLED-TEST-FILTER-CLASS +$cfg->setConfigEntry('tests_configuration_is_enabled_filter_class', 'Org\Mxchange\CoreFramework\Tests\Filter\Configuration\IsEnabled\TestsConfigurationIsEnabledFilter'); // CFG: TEST-CONSOLE-CONTROLLER-RESOLVER-CLASS $cfg->setConfigEntry('tests_console_controller_resolver_class', 'Org\Mxchange\CoreFramework\Tests\Resolver\Controller\TestsConsoleControllerResolver'); diff --git a/framework/config-global.php b/framework/config-global.php index 6d8608de..6f019d43 100644 --- a/framework/config-global.php +++ b/framework/config-global.php @@ -337,18 +337,12 @@ $cfg->setConfigEntry('csv_input_file_class', 'Org\Mxchange\CoreFramework\Filesys // CFG: FILE-ITERATOR-CLASS $cfg->setConfigEntry('file_iterator_class', 'Org\Mxchange\CoreFramework\Iterator\File\FileIterator'); -// CFG: FILE-STACK-PRE-ALLOCATE-ENABLED -$cfg->setConfigEntry('file_stack_pre_allocate_enabled', 'Y'); - // CFG: FILE-STACK-PRE-ALLOCATE-COUNT $cfg->setConfigEntry('file_stack_pre_allocate_count', 10000); // CFG: INDEX-INDEX-CLASS $cfg->setConfigEntry('file_stack_index_class', 'Org\Mxchange\CoreFramework\Index\File\Stack\FileStackIndex'); -// CFG: INDEX-PRE-ALLOCATE-ENABLED -$cfg->setConfigEntry('index_pre_allocate_enabled', 'Y'); - // CFG: INDEX-PRE-ALLOCATE-COUNT $cfg->setConfigEntry('index_pre_allocate_count', 10000); @@ -498,3 +492,9 @@ $cfg->setConfigEntry('is_db_update_primary_forced_enabled', true); // CFG: IS-QUIET-DNS-RESOLVER-ENABLED $cfg->setConfigEntry('is_quiet_dns_resolver_enabled', false); + +// CFG: IS-FILE-STACK-PRE-ALLOCATE-ENABLED +$cfg->setConfigEntry('is_file_stack_pre_allocate_enabled', true); + +// CFG: IS-INDEX-PRE-ALLOCATE-ENABLED +$cfg->setConfigEntry('is_index_pre_allocate_enabled', true); diff --git a/framework/main/classes/file_directories/binary/class_BaseBinaryFile.php b/framework/main/classes/file_directories/binary/class_BaseBinaryFile.php index b7ddafcd..a7a1dcfd 100644 --- a/framework/main/classes/file_directories/binary/class_BaseBinaryFile.php +++ b/framework/main/classes/file_directories/binary/class_BaseBinaryFile.php @@ -903,7 +903,7 @@ abstract class BaseBinaryFile extends BaseAbstractFile implements BinaryFile { } elseif ($minimumBlockLength < 1) { // Invalid block length throw new InvalidArgumentException(sprintf('Parameter minimumBlockLength=%d is not valid', $minimumBlockLength)); - } elseif (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($type . '_pre_allocate_enabled') != 'Y') { + } elseif (!FrameworkBootstrap::getConfigurationInstance()->isEnabled($type . '_pre_allocate')) { // Don't continue here. self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Not pre-allocating file.')); return; diff --git a/framework/main/middleware/debug/class_DebugMiddleware.php b/framework/main/middleware/debug/class_DebugMiddleware.php index 13fe73da..dae80dbb 100644 --- a/framework/main/middleware/debug/class_DebugMiddleware.php +++ b/framework/main/middleware/debug/class_DebugMiddleware.php @@ -199,7 +199,7 @@ class DebugMiddleware extends BaseMiddleware implements Registerable { // Use debug output handler //* NOISY-DEBUG: */ printf('[%s:%d]: Invoking this->output(%s,%d) ...' . PHP_EOL, __METHOD__, __LINE__, $message, intval($stripTags)); - $this->output($message, $stripTags); + $this->output(sprintf('TRACE: %s', $message), $stripTags); // Trace message //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__); @@ -231,7 +231,39 @@ class DebugMiddleware extends BaseMiddleware implements Registerable { // Use debug output handler //* NOISY-DEBUG: */ printf('[%s:%d]: Invoking this->output(%s,%d) ...' . PHP_EOL, __METHOD__, __LINE__, $message, intval($stripTags)); - $this->output($message, $stripTags); + $this->output(sprintf('DEBUG: %s', $message), $stripTags); + + // Trace message + //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__); + } + + /** + * Outputs an informational message whether to debug instance (should be set!) or + * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to + * ApplicationEntryPoint::app_exit(), this would cause an endless loop. + * + * @param $message Message we shall send out... + * @param $doPrint Whether print or die here (default: print) + * @paran $stripTags Whether to strip tags (default: false) + * @return void + * @throws InvalidArgumentException If a parameter has an invalid value + * @throws NullPointerException If this->outputInstance is NULL + * @todo Remove $doPrint parameter + */ + public function infoMessage (string $message, bool $doPrint = true, bool $stripTags = false) { + // Check parameter + //* NOISY-DEBUG: */ printf('[%s:%d]: message=%s,doPrint=%d,stripTags=%d - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $message, intval($doPrint), intval($stripTags)); + if (empty($message)) { + // Throw IAE + throw new InvalidArgumentException('Parameter "message" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT); + } elseif (is_null($this->getOutputInstance())) { + // Should not be NULL + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } + + // Use debug output handler + //* NOISY-DEBUG: */ printf('[%s:%d]: Invoking this->output(%s,%d) ...' . PHP_EOL, __METHOD__, __LINE__, $message, intval($stripTags)); + $this->output(sprintf('INFO: %s', $message), $stripTags); // Trace message //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__); @@ -263,7 +295,7 @@ class DebugMiddleware extends BaseMiddleware implements Registerable { // Use debug output handler //* NOISY-DEBUG: */ printf('[%s:%d]: Invoking this->output(%s,%d) ...' . PHP_EOL, __METHOD__, __LINE__, $message, intval($stripTags)); - $this->output($message, $stripTags); + $this->output(sprintf('WARNING: %s', $message), $stripTags); // Trace message //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__); @@ -294,7 +326,7 @@ class DebugMiddleware extends BaseMiddleware implements Registerable { } /** - * Outputs a debug message whether to debug instance (should be set!) or + * Outputs a deprecated message whether to debug instance (should be set!) or * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to * ApplicationEntryPoint::app_exit(), this would cause an endless loop. * @@ -305,7 +337,7 @@ class DebugMiddleware extends BaseMiddleware implements Registerable { * @throws InvalidArgumentException If a parameter has an invalid value * @throws NullPointerException If this->outputInstance is NULL * @todo Remove $doPrint parameter - * @deprecated Rewrite to "new" methods above + * @todo When all old method invocations are fixed, renamed this do deprecatedMessage */ public function debugOutput (string $message, bool $doPrint = true, bool $stripTags = false) { // Check parameter @@ -318,8 +350,8 @@ class DebugMiddleware extends BaseMiddleware implements Registerable { throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); } - // Invoke new version - $this->debugMessage($message, $doPrint, $stripTags); + // Invoke Inner method + $this->outputMessage(sprintf('DEPRECATED: %s', $message), $doPrint, $stripTags); // Trace message //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__); -- 2.39.5