* @return void
*/
public function initApplication () {
- // Get config instance
- $cfg = FrameworkBootstrap::getConfigurationInstance();
-
// Initialize output system
self::createDebugInstance('ApplicationHelper');
* method.
*/
FrameworkBootstrap::initDatabaseInstance();
-
- // Register core tests
- ClassLoader::registerTestsPath('framework/main/tests');
-
- // Scan for them now
- ClassLoader::scanTestsClasses();
}
/**
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Command;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Command\BaseCommand;
+use Org\Mxchange\CoreFramework\Command\Commandable;
+use Org\Mxchange\CoreFramework\Controller\Controller;
+use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
+use Org\Mxchange\CoreFramework\Request\Requestable;
+use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+
+/**
+ * A command for the 'main' routine
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @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.shipsimu.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 <http://www.gnu.org/licenses/>.
+ */
+class TestsConsoleMainCommand extends BaseCommand implements Commandable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ private function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $commandInstance An instance a prepared command class
+ */
+ public static final function createTestsConsoleMainCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new TestsConsoleMainCommand();
+
+ // Set the application instance
+ $commandInstance->setResolverInstance($resolverInstance);
+
+ // Return the prepared instance
+ return $commandInstance;
+ }
+
+ /**
+ * Executes the given command 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
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Debug message
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Starting tests ... ---');
+
+ // Get controller
+ $controllerInstance = ObjectRegistry::getRegistry('generic')->getInstance('controller');
+
+ // Run all tests
+ $controllerInstance->executeTestsFilters($requestInstance, $responseInstance);
+
+ // Debug message
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main ... ---');
+ }
+
+ /**
+ * Adds extra filters to the given controller instance
+ *
+ * @param $controllerInstance A controller instance
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @return void
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Add pre filters (e.g. for requirements checks)
+ $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'));
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Controller;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Controller\BaseController;
+use Org\Mxchange\CoreFramework\Controller\Controller;
+use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Filter\Filterable;
+use Org\Mxchange\CoreFramework\Request\Requestable;
+use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+
+/**
+ * The default controller with news for e.g. home or news page
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @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.shipsimu.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 <http://www.gnu.org/licenses/>.
+ */
+class TestsConsoleDefaultNewsController extends BaseController implements Controller {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ private function __construct () {
+ // Call parent constructor
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('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));
+ $this->initFilterChain($filterChain);
+ }
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: EXIT!');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $controllerInstance A prepared instance of this class
+ */
+ 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()));
+ $controllerInstance = new TestsConsoleDefaultNewsController();
+
+ // Set the command resolver
+ $controllerInstance->setResolverInstance($resolverInstance);
+
+ // Add news filters to this controller
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter_class'));
+ $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()));
+ return $controllerInstance;
+ }
+
+ /**
+ * Handles the given request and response
+ *
+ * @param $requestInstance An instance of a request class
+ * @param $responseInstance An instance of a response class
+ * @return void
+ */
+ 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()));
+ $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
+
+ // Add more filters by the command
+ $commandInstance->addExtraFilters($this, $requestInstance);
+
+ // Run the pre filters
+ $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) ...');
+ $requestInstance->setIsRequestValid(TRUE);
+
+ // Execute the command
+ $commandInstance->execute($requestInstance, $responseInstance);
+
+ // Run the post filters
+ $this->executePostFilters($requestInstance, $responseInstance);
+
+ // Flush the response out
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('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!');
+ }
+
+ /**
+ * Add a bootstrap filter
+ *
+ * @param $filterInstance A Filterable class
+ * @return void
+ */
+ public function addBootstrapFilter (Filterable $filterInstance) {
+ $this->addFilter('bootstrap', $filterInstance);
+ }
+
+ /**
+ * Add a tests filter
+ *
+ * @param $filterInstance A Filterable class
+ * @return void
+ */
+ public function addTestsFilter (Filterable $filterInstance) {
+ $this->addFilter('tests', $filterInstance);
+ }
+
+ /**
+ * Executes all bootstrap filters
+ *
+ * @param $requestInstance A Requestable class
+ * @param $responseInstance A Responseable class
+ * @return void
+ */
+ public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) {
+ $this->executeFilters('bootstrap', $requestInstance, $responseInstance);
+ }
+
+ /**
+ * Executes all tests filters
+ *
+ * @param $requestInstance A Requestable class
+ * @param $responseInstance A Responseable class
+ * @return void
+ */
+ public function executeTestsFilters (Requestable $requestInstance, Responseable $responseInstance) {
+ $this->executeFilters('tests', $requestInstance, $responseInstance);
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Filter;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Filter\BaseFilter;
+
+/**
+ * A generic filter for tests
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @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.shipsimu.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 <http://www.gnu.org/licenses/>.
+ */
+abstract class BaseTestsFilter extends BaseFilter {
+ /**
+ * Protected constructor
+ *
+ * @param $className Real name of class
+ * @return void
+ */
+ protected function __construct (string $className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Filter\!!!;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Filter\Filterable;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
+use Org\Mxchange\CoreFramework\Request\Requestable;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter;
+
+/**
+ * A ??? filter for tests
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class Tests???Filter 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 createTests???Filter () {
+ // Get a new instance
+ $filterInstance = new Tests???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!
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Filter\Configuration\!!!;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Filter\Filterable;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
+use Org\Mxchange\CoreFramework\Request\Requestable;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter;
+
+/**
+ * A ??? filter for tests
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class TestConfiguration???Filter 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 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!
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Filter\Configuration\Classes;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Filter\Filterable;
+use Org\Mxchange\CoreFramework\Request\Requestable;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter;
+
+// Import SPL stuff
+use \InvalidArgumentException;
+
+/**
+ * A LoadableClasses filter for tests
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class TestConfigurationLoadableClassesFilter 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 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
+ */
+ 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()));
+ $passed = 0;
+ $failed = 0;
+ $skipped = 0;
+
+ // 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));
+ 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
+ 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
+ $failed++;
+ continue;
+ } elseif (!class_exists($configValue)) {
+ // Class not found
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Class "%s" not found. FAILED!', $configValue));
+
+ // Skip further tests
+ $failed++;
+ continue;
+ }
+ } catch (InvalidArgumentException $e) {
+ // Maybe not conform?
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Class "%s" failed to load. Message: "%s"', $configValue, $e->getMessage()));
+
+ // Skip further tests
+ $failed++;
+ continue;
+ }
+
+ // class_exists() didn't fail
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(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));
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Filter\Requirements;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Filter\Filterable;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
+use Org\Mxchange\CoreFramework\Request\Requestable;
+use Org\Mxchange\CoreFramework\Response\Responseable;
+use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter;
+
+/**
+ * A PhpRequirements filter for tests
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class TestsPhpRequirementsFilter 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 createTestsPhpRequirementsFilter () {
+ // Get a new instance
+ $filterInstance = new TestsPhpRequirementsFilter();
+
+ // 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!
+ DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Resolver\Command;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Command\InvalidCommandException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+use Org\Mxchange\CoreFramework\Resolver\Command\BaseCommandResolver;
+use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
+
+// Import SPL stuff
+use \InvalidArgumentException;
+
+/**
+ * A command resolver for console commands
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @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.shipsimu.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 <http://www.gnu.org/licenses/>.
+ */
+class TestsConsoleCommandResolver extends BaseCommandResolver implements CommandResolver {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ private function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set prefix to "TestsConsole"
+ $this->setClassPrefix('tests_console');
+ }
+
+ /**
+ * Creates an instance of a TestsConsole command resolver with a given default command
+ *
+ * @param $commandName The default command we shall execute
+ * @return $resolverInstance The prepared command resolver instance
+ * @throws InvalidArgumentException Thrown if default command is not set
+ * @throws InvalidCommandException Thrown if default command is invalid
+ */
+ public static final function createTestsConsoleCommandResolver (string $commandName) {
+ // Create the new instance
+ $resolverInstance = new TestsConsoleCommandResolver();
+
+ // Is the variable $commandName set and the command is valid?
+ if (empty($commandName)) {
+ // Then thrown an exception here
+ throw new InvalidArgumentException('Parameter "commandName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ($resolverInstance->isCommandValid('Org\Mxchange\CoreFramework\Tests\Command', $commandName) === false) {
+ // Invalid command found
+ throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
+ }
+
+ // Set namespace for command
+ $resolverInstance->setNamespace('Org\Mxchange\CoreFramework\Tests\Command');
+ $resolverInstance->setCommandName($commandName);
+
+ // Return the prepared instance
+ return $resolverInstance;
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Tests\Resolver\Controller;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Controller\BaseController;
+use Org\Mxchange\CoreFramework\Controller\Controller;
+use Org\Mxchange\CoreFramework\Controller\InvalidControllerException;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+use Org\Mxchange\CoreFramework\Resolver\Controller\BaseControllerResolver;
+use Org\Mxchange\CoreFramework\Resolver\Controller\ControllerResolver;
+
+// Import SPL stuff
+use \InvalidArgumentException;
+
+/**
+ * A resolver for resolving controllers locally
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @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.shipsimu.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 <http://www.gnu.org/licenses/>.
+ */
+class TestsConsoleControllerResolver extends BaseControllerResolver implements ControllerResolver {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ private function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set prefix to "TestsConsole"
+ $this->setClassPrefix('tests_console');
+ }
+
+ /**
+ * Creates an instance of a resolver class with a given command
+ *
+ * @param $controllerName The controller we shall resolve
+ * @return $resolverInstance The prepared controller resolver instance
+ * @throws InvalidArgumentException Thrown if default command is not set
+ * @throws InvalidControllerException Thrown if default controller is invalid
+ */
+ public static final function createTestsConsoleControllerResolver (string $controllerName) {
+ // Create the new instance
+ $resolverInstance = new TestsConsoleControllerResolver();
+
+ // Is the variable $controllerName set and the command is valid?
+ if (empty($controllerName)) {
+ // Then thrown an exception here
+ throw new InvalidArgumentException('Parameter "controllerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+ } elseif ($resolverInstance->isControllerValid('Org\Mxchange\CoreFramework\Tests\Controller', $controllerName) === false) {
+ // Invalid command found
+ throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
+ }
+
+ // Set namespace and controller name
+ $resolverInstance->setNamespace('Org\Mxchange\CoreFramework\Tests\Controller');
+ $resolverInstance->setControllerName($controllerName);
+
+ // Return the prepared instance
+ return $resolverInstance;
+ }
+
+}
//* 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
*
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
*
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Command;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Command\BaseCommand;
-use Org\Mxchange\CoreFramework\Command\Commandable;
-use Org\Mxchange\CoreFramework\Controller\Controller;
-use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
-use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
-use Org\Mxchange\CoreFramework\Request\Requestable;
-use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
-use Org\Mxchange\CoreFramework\Response\Responseable;
-
-/**
- * A command for the 'main' routine
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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.shipsimu.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 <http://www.gnu.org/licenses/>.
- */
-class TestsConsoleMainCommand extends BaseCommand implements Commandable {
- /**
- * Protected constructor
- *
- * @return void
- */
- private function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @param $resolverInstance An instance of a command resolver class
- * @return $commandInstance An instance a prepared command class
- */
- public static final function createTestsConsoleMainCommand (CommandResolver $resolverInstance) {
- // Get new instance
- $commandInstance = new TestsConsoleMainCommand();
-
- // Set the application instance
- $commandInstance->setResolverInstance($resolverInstance);
-
- // Return the prepared instance
- return $commandInstance;
- }
-
- /**
- * Executes the given command 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
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Starting tests ... ---');
-
- // Get controller
- $controllerInstance = ObjectRegistry::getRegistry('generic')->getInstance('controller');
-
- // Run all tests
- $controllerInstance->executeTestsFilters($requestInstance, $responseInstance);
-
- // Debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main ... ---');
- }
-
- /**
- * Adds extra filters to the given controller instance
- *
- * @param $controllerInstance A controller instance
- * @param $requestInstance An instance of a class with an Requestable interface
- * @return void
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Add pre filters (e.g. for requirements checks)
- $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'));
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Controller;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Controller\BaseController;
-use Org\Mxchange\CoreFramework\Controller\Controller;
-use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
-use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Request\Requestable;
-use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
-use Org\Mxchange\CoreFramework\Response\Responseable;
-
-/**
- * The default controller with news for e.g. home or news page
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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.shipsimu.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 <http://www.gnu.org/licenses/>.
- */
-class TestsConsoleDefaultNewsController extends BaseController implements Controller {
- /**
- * Protected constructor
- *
- * @return void
- */
- private function __construct () {
- // Call parent constructor
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('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));
- $this->initFilterChain($filterChain);
- }
-
- // Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TEST-CONSOLE-DEFAULT-NEWS-CONTROLLER: EXIT!');
- }
-
- /**
- * Creates an instance of this class
- *
- * @param $resolverInstance An instance of a command resolver class
- * @return $controllerInstance A prepared instance of this class
- */
- 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()));
- $controllerInstance = new TestsConsoleDefaultNewsController();
-
- // Set the command resolver
- $controllerInstance->setResolverInstance($resolverInstance);
-
- // Add news filters to this controller
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter_class'));
- $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()));
- return $controllerInstance;
- }
-
- /**
- * Handles the given request and response
- *
- * @param $requestInstance An instance of a request class
- * @param $responseInstance An instance of a response class
- * @return void
- */
- 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()));
- $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
-
- // Add more filters by the command
- $commandInstance->addExtraFilters($this, $requestInstance);
-
- // Run the pre filters
- $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) ...');
- $requestInstance->setIsRequestValid(TRUE);
-
- // Execute the command
- $commandInstance->execute($requestInstance, $responseInstance);
-
- // Run the post filters
- $this->executePostFilters($requestInstance, $responseInstance);
-
- // Flush the response out
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('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!');
- }
-
- /**
- * Add a bootstrap filter
- *
- * @param $filterInstance A Filterable class
- * @return void
- */
- public function addBootstrapFilter (Filterable $filterInstance) {
- $this->addFilter('bootstrap', $filterInstance);
- }
-
- /**
- * Add a tests filter
- *
- * @param $filterInstance A Filterable class
- * @return void
- */
- public function addTestsFilter (Filterable $filterInstance) {
- $this->addFilter('tests', $filterInstance);
- }
-
- /**
- * Executes all bootstrap filters
- *
- * @param $requestInstance A Requestable class
- * @param $responseInstance A Responseable class
- * @return void
- */
- public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) {
- $this->executeFilters('bootstrap', $requestInstance, $responseInstance);
- }
-
- /**
- * Executes all tests filters
- *
- * @param $requestInstance A Requestable class
- * @param $responseInstance A Responseable class
- * @return void
- */
- public function executeTestsFilters (Requestable $requestInstance, Responseable $responseInstance) {
- $this->executeFilters('tests', $requestInstance, $responseInstance);
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Filter;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Filter\BaseFilter;
-
-/**
- * A generic filter for tests
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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.shipsimu.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 <http://www.gnu.org/licenses/>.
- */
-abstract class BaseTestsFilter extends BaseFilter {
- /**
- * Protected constructor
- *
- * @param $className Real name of class
- * @return void
- */
- protected function __construct (string $className) {
- // Call parent constructor
- parent::__construct($className);
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Filter\!!!;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
-use Org\Mxchange\CoreFramework\Request\Requestable;
-use Org\Mxchange\CoreFramework\Response\Responseable;
-use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter;
-
-/**
- * A ??? filter for tests
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class Tests???Filter 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 createTests???Filter () {
- // Get a new instance
- $filterInstance = new Tests???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!
- DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Filter\Configuration\!!!;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
-use Org\Mxchange\CoreFramework\Request\Requestable;
-use Org\Mxchange\CoreFramework\Response\Responseable;
-use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter;
-
-/**
- * A ??? filter for tests
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class TestConfiguration???Filter 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 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!
- DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Filter\Configuration\Classes;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Request\Requestable;
-use Org\Mxchange\CoreFramework\Response\Responseable;
-use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter;
-
-// Import SPL stuff
-use \InvalidArgumentException;
-
-/**
- * A LoadableClasses filter for tests
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class TestConfigurationLoadableClassesFilter 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 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
- */
- 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()));
- $passed = 0;
- $failed = 0;
- $skipped = 0;
-
- // 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));
- 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
- 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
- $failed++;
- continue;
- } elseif (!class_exists($configValue)) {
- // Class not found
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Class "%s" not found. FAILED!', $configValue));
-
- // Skip further tests
- $failed++;
- continue;
- }
- } catch (InvalidArgumentException $e) {
- // Maybe not conform?
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Class "%s" failed to load. Message: "%s"', $configValue, $e->getMessage()));
-
- // Skip further tests
- $failed++;
- continue;
- }
-
- // class_exists() didn't fail
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(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));
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Filter\Requirements;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Filter\Filterable;
-use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
-use Org\Mxchange\CoreFramework\Request\Requestable;
-use Org\Mxchange\CoreFramework\Response\Responseable;
-use Org\Mxchange\CoreFramework\Tests\Filter\BaseTestsFilter;
-
-/**
- * A PhpRequirements filter for tests
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-class TestsPhpRequirementsFilter 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 createTestsPhpRequirementsFilter () {
- // Get a new instance
- $filterInstance = new TestsPhpRequirementsFilter();
-
- // 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!
- DebugMiddleware::getSelfInstance()->partialStub('Please implement this method.');
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Resolver\Command;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Command\InvalidCommandException;
-use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
-use Org\Mxchange\CoreFramework\Resolver\Command\BaseCommandResolver;
-use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
-
-// Import SPL stuff
-use \InvalidArgumentException;
-
-/**
- * A command resolver for console commands
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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.shipsimu.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 <http://www.gnu.org/licenses/>.
- */
-class TestsConsoleCommandResolver extends BaseCommandResolver implements CommandResolver {
- /**
- * Protected constructor
- *
- * @return void
- */
- private function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Set prefix to "TestsConsole"
- $this->setClassPrefix('tests_console');
- }
-
- /**
- * Creates an instance of a TestsConsole command resolver with a given default command
- *
- * @param $commandName The default command we shall execute
- * @return $resolverInstance The prepared command resolver instance
- * @throws InvalidArgumentException Thrown if default command is not set
- * @throws InvalidCommandException Thrown if default command is invalid
- */
- public static final function createTestsConsoleCommandResolver (string $commandName) {
- // Create the new instance
- $resolverInstance = new TestsConsoleCommandResolver();
-
- // Is the variable $commandName set and the command is valid?
- if (empty($commandName)) {
- // Then thrown an exception here
- throw new InvalidArgumentException('Parameter "commandName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
- } elseif ($resolverInstance->isCommandValid('Org\Mxchange\CoreFramework\Tests\Command', $commandName) === false) {
- // Invalid command found
- throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
- }
-
- // Set namespace for command
- $resolverInstance->setNamespace('Org\Mxchange\CoreFramework\Tests\Command');
- $resolverInstance->setCommandName($commandName);
-
- // Return the prepared instance
- return $resolverInstance;
- }
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Tests\Resolver\Controller;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Controller\BaseController;
-use Org\Mxchange\CoreFramework\Controller\Controller;
-use Org\Mxchange\CoreFramework\Controller\InvalidControllerException;
-use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
-use Org\Mxchange\CoreFramework\Resolver\Controller\BaseControllerResolver;
-use Org\Mxchange\CoreFramework\Resolver\Controller\ControllerResolver;
-
-// Import SPL stuff
-use \InvalidArgumentException;
-
-/**
- * A resolver for resolving controllers locally
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @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.shipsimu.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 <http://www.gnu.org/licenses/>.
- */
-class TestsConsoleControllerResolver extends BaseControllerResolver implements ControllerResolver {
- /**
- * Protected constructor
- *
- * @return void
- */
- private function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Set prefix to "TestsConsole"
- $this->setClassPrefix('tests_console');
- }
-
- /**
- * Creates an instance of a resolver class with a given command
- *
- * @param $controllerName The controller we shall resolve
- * @return $resolverInstance The prepared controller resolver instance
- * @throws InvalidArgumentException Thrown if default command is not set
- * @throws InvalidControllerException Thrown if default controller is invalid
- */
- public static final function createTestsConsoleControllerResolver (string $controllerName) {
- // Create the new instance
- $resolverInstance = new TestsConsoleControllerResolver();
-
- // Is the variable $controllerName set and the command is valid?
- if (empty($controllerName)) {
- // Then thrown an exception here
- throw new InvalidArgumentException('Parameter "controllerName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
- } elseif ($resolverInstance->isControllerValid('Org\Mxchange\CoreFramework\Tests\Controller', $controllerName) === false) {
- // Invalid command found
- throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
- }
-
- // Set namespace and controller name
- $resolverInstance->setNamespace('Org\Mxchange\CoreFramework\Tests\Controller');
- $resolverInstance->setControllerName($controllerName);
-
- // Return the prepared instance
- return $resolverInstance;
- }
-
-}