From 8b7563e0de442492f93be4c24efdb902474fa86c Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sun, 26 Feb 2017 15:18:57 +0100 Subject: [PATCH] Continued: - added stub class for testing loadable configured class names - added "import" of ReflectionClass (SPL) - some tpzos fixed MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../console/class_TestsConsoleMainCommand.php | 7 +- ...lass_TestsConsoleDefaultNewsController.php | 2 +- .../tests/classes/filter/tests/class_Tests | 1 + .../filter/tests/configuration/.htaccess | 1 + .../configuration/class_TestConfiguration | 70 +++++++++++++++++++ .../tests/configuration/classes/.htaccess | 1 + ...TestConfigurationLoadableClassesFilter.php | 70 +++++++++++++++++++ application/tests/config.php | 7 +- framework/config.php | 30 ++++---- .../classes/class_BaseFrameworkSystem.php | 1 + .../controller/class_BaseController.php | 4 +- 11 files changed, 172 insertions(+), 22 deletions(-) create mode 100644 application/tests/classes/filter/tests/configuration/.htaccess create mode 100644 application/tests/classes/filter/tests/configuration/class_TestConfiguration create mode 100644 application/tests/classes/filter/tests/configuration/classes/.htaccess create mode 100644 application/tests/classes/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php diff --git a/application/tests/classes/commands/console/class_TestsConsoleMainCommand.php b/application/tests/classes/commands/console/class_TestsConsoleMainCommand.php index d6a5f389..ce512ff7 100644 --- a/application/tests/classes/commands/console/class_TestsConsoleMainCommand.php +++ b/application/tests/classes/commands/console/class_TestsConsoleMainCommand.php @@ -73,8 +73,11 @@ class TestsConsoleMainCommand extends BaseCommand implements Commandable { // Debug message self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Starting tests ... ---'); - // Get a registry and the application instance from it - $applicationInstance = Registry::getRegistry()->getInstance('app'); + // Get controller + $controllerInstance = Registry::getRegistry()->getInstance('controller'); + + // Run all tests + $controllerInstance->executeTestsFilters($requestInstance, $responseInstance); // Debug message self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main ... ---'); diff --git a/application/tests/classes/controller/console/class_TestsConsoleDefaultNewsController.php b/application/tests/classes/controller/console/class_TestsConsoleDefaultNewsController.php index cc86661b..d86ebf35 100644 --- a/application/tests/classes/controller/console/class_TestsConsoleDefaultNewsController.php +++ b/application/tests/classes/controller/console/class_TestsConsoleDefaultNewsController.php @@ -93,7 +93,7 @@ class TestsConsoleDefaultNewsController extends BaseController implements Contro // Execute the command $commandInstance->execute($requestInstance, $responseInstance); - // Run the pre filters + // Run the post filters $this->executePostFilters($requestInstance, $responseInstance); // Flush the response out diff --git a/application/tests/classes/filter/tests/class_Tests b/application/tests/classes/filter/tests/class_Tests index 9fa7bd8c..9f84cded 100644 --- a/application/tests/classes/filter/tests/class_Tests +++ b/application/tests/classes/filter/tests/class_Tests @@ -6,6 +6,7 @@ namespace CoreFramework\Tests\Filter\!!!; use CoreFramework\Filter\Filterable; use CoreFramework\Request\Requestable; use CoreFramework\Response\Responseable; +use CoreFramework\Tests\Filter\BaseTestsFilter; /** * A ??? filter for tests diff --git a/application/tests/classes/filter/tests/configuration/.htaccess b/application/tests/classes/filter/tests/configuration/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/application/tests/classes/filter/tests/configuration/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/tests/classes/filter/tests/configuration/class_TestConfiguration b/application/tests/classes/filter/tests/configuration/class_TestConfiguration new file mode 100644 index 00000000..76afc51a --- /dev/null +++ b/application/tests/classes/filter/tests/configuration/class_TestConfiguration @@ -0,0 +1,70 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 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 TestConfiguration???Filter extends BaseTestsFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected 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 createTestConfiguration???Filter () { + // Get a new instance + $filterInstance = new TestConfiguration???Filter(); + + // Return the instance + 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) { + // Implement this! + $this->partialStub('Please implement this method.'); + } + +} diff --git a/application/tests/classes/filter/tests/configuration/classes/.htaccess b/application/tests/classes/filter/tests/configuration/classes/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/application/tests/classes/filter/tests/configuration/classes/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/tests/classes/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php b/application/tests/classes/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php new file mode 100644 index 00000000..175f5173 --- /dev/null +++ b/application/tests/classes/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php @@ -0,0 +1,70 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 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 TestConfigurationLoadableClassesFilter extends BaseTestsFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected 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 createTestConfigurationLoadableClassesFilter () { + // Get a new instance + $filterInstance = new TestConfigurationLoadableClassesFilter(); + + // Return the instance + 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) { + // Implement this! + $this->partialStub('Please implement this method.'); + } + +} diff --git a/application/tests/config.php b/application/tests/config.php index 05b6268a..0574a8db 100644 --- a/application/tests/config.php +++ b/application/tests/config.php @@ -39,10 +39,10 @@ $cfg->setConfigEntry('default_tests_console_controller', 'main'); // CFG: TESTS-CONSOLE-CMD-MAIN-RESOLVER-CLASS $cfg->setConfigEntry('tests_console_cmd_main_resolver_class', 'CoreFramework\Tests\Resolver\Command\TestsConsoleCommandResolver'); -// CFG: NEWS-DOWNLOAD-FILTER +// CFG: NEWS-DOWNLOAD-FILTER-CLASS $cfg->setConfigEntry('news_download_filter_class', 'CoreFramework\Filter\News\NewsDownloadFilter'); -// CFG: NEWS-PROCESS-FILTER +// CFG: NEWS-PROCESS-FILTER-CLASS $cfg->setConfigEntry('news_process_filter_class', 'CoreFramework\Filter\News\NewsProcessFilter'); // CFG: NEWS-READER-MAIN-CLASS @@ -53,3 +53,6 @@ $cfg->setConfigEntry('news_main_limit', 5); // CFG: TESTS-PHP-REQUIREMENTS-FILTER $cfg->setConfigEntry('tests_php_requirements_filter_class', 'CoreFramework\Tests\Filter\Requirements\TestsPhpRequirementsFilter'); + +// CFG: TEST-CONFIGURATION-CLASSES-LOADABLE-TEST-FILTER-CLASS +$cfg->setConfigEntry('tests_configuration_classes_loadable_test_filter_class', 'CoreFramework\Tests\Filter\Configuration\Classes\TestConfigurationLoadableClassesFilter'); diff --git a/framework/config.php b/framework/config.php index f524cbfc..f389f4b5 100644 --- a/framework/config.php +++ b/framework/config.php @@ -193,49 +193,49 @@ $cfg->setConfigEntry('file_input_class', 'CoreFramework\Stream\Filesystem\FileIo // CFG: FILE-OUTPUT-CLASS $cfg->setConfigEntry('file_output_class', 'CoreFramework\Stream\Filesystem\FileIoStream'); -// CFG: EMAIL-VALIDATOR-FILTER +// CFG: EMAIL-VALIDATOR-FILTER-CLASS $cfg->setConfigEntry('email_validator_filter_class', 'EmailValidatorFilter'); -// CFG: USERNAME-VALIDATOR-FILTER +// CFG: USERNAME-VALIDATOR-FILTER-CLASS $cfg->setConfigEntry('username_validator_filter_class', 'UserNameValidatorFilter'); -// CFG: USERNAME-IS-GUEST-FILTER +// CFG: USERNAME-IS-GUEST-FILTER-CLASS $cfg->setConfigEntry('username_is_guest_filter_class', 'UserNameIsGuestFilter'); -// CFG: PASSWORD-VALIDATOR-FILTER +// CFG: PASSWORD-VALIDATOR-FILTER-CLASS $cfg->setConfigEntry('password_validator_filter_class', 'PasswordValidatorFilter'); -// CFG: RULES-ACCEPTED-FILTER +// CFG: RULES-ACCEPTED-FILTER-CLASS $cfg->setConfigEntry('rules_accepted_filter_class', 'RulesAcceptedFilter'); -// CFG: USERNAME-VERIFIER-FILTER +// CFG: USERNAME-VERIFIER-FILTER-CLASS $cfg->setConfigEntry('username_verifier_filter_class', 'UserNameVerifierFilter'); -// CFG: USER-GUEST-VERIFIER-FILTER +// CFG: USER-GUEST-VERIFIER-FILTER-CLASS $cfg->setConfigEntry('user_guest_verifier_filter_class', 'UserGuestVerifierFilter'); -// CFG: EMAIL-VERIFIER-FILTER +// CFG: EMAIL-VERIFIER-FILTER-CLASS $cfg->setConfigEntry('email_verifier_filter_class', 'EmailVerifierFilter'); -// CFG: PASSWORD-VERIFIER-FILTER +// CFG: PASSWORD-VERIFIER-FILTER-CLASS $cfg->setConfigEntry('password_verifier_filter_class', 'PasswordVerifierFilter'); -// CFG: PASSWD-GUEST-VERIFIER-FILTER +// CFG: PASSWD-GUEST-VERIFIER-FILTER-CLASS $cfg->setConfigEntry('passwd_guest_verifier_filter_class', 'PasswordGuestVerifierFilter'); -// CFG: EMAIL-CHANGE-FILTER +// CFG: EMAIL-CHANGE-FILTER-CLASS $cfg->setConfigEntry('email_change_filter_class', 'EmailChangeFilter'); -// CFG: PASSWORD-CHANGE-FILTER +// CFG: PASSWORD-CHANGE-FILTER-CLASS $cfg->setConfigEntry('password_change_filter_class', 'PasswordChangeFilter'); -// CFG: ACCOUNT-PASSWORD-FILTER +// CFG: ACCOUNT-PASSWORD-FILTER-CLASS $cfg->setConfigEntry('account_password_filter_class', 'AccountPasswordVerifierFilter'); -// CFG: USER-STATUS-FILTER +// CFG: USER-STATUS-FILTER-CLASS $cfg->setConfigEntry('user_status_filter_class', 'UserStatusVerifierFilter'); -// CFG: USER-UNCONFIRMED-FILTER +// CFG: USER-UNCONFIRMED-FILTER-CLASS $cfg->setConfigEntry('user_unconfirmed_filter_class', 'UserUnconfirmedVerifierFilter'); // CFG: CRYPTO-CLASS diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index 3ca59ca3..423fe296 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -33,6 +33,7 @@ use CoreFramework\Wrapper\Database\DatabaseWrapper; // Import SPL stuff use \stdClass; +use \ReflectionClass; /** * The simulator system class is the super class of all other classes. This diff --git a/framework/main/classes/controller/class_BaseController.php b/framework/main/classes/controller/class_BaseController.php index 6f8a1ec5..97349d5e 100644 --- a/framework/main/classes/controller/class_BaseController.php +++ b/framework/main/classes/controller/class_BaseController.php @@ -135,7 +135,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable { // Execute the command $commandInstance->execute($requestInstance, $responseInstance); - // Execute *very* generic ppost filters + // Execute *very* generic post filters $this->executePostFilters($requestInstance, $responseInstance); } // END - if @@ -176,7 +176,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable { // Execute the command $commandInstance->execute($requestInstance, $responseInstance); - // Run the pre filters + // Run the post filters $this->executePostFilters($requestInstance, $responseInstance); // Flush the response out -- 2.30.2