]> git.mxchange.org Git - core.git/blobdiff - application/tests/classes/commands/console/class_TestsConsoleMainCommand.php
Continued:
[core.git] / application / tests / classes / commands / console / class_TestsConsoleMainCommand.php
index 66c8147b569d3b3c680f25963efc2bdaee33674c..91bb107ec35b4b9f785ddbf7c4506dea5a929669 100644 (file)
@@ -1,22 +1,23 @@
 <?php
 // Own namespace
-namespace CoreFramework\Tests\Command;
+namespace Org\Mxchange\CoreFramework\Tests\Command;
 
 // Import framework stuff
-use CoreFramework\Command\BaseCommand;
-use CoreFramework\Command\Commandable;
-use CoreFramework\Controller\Controller;
-use CoreFramework\Factory\ObjectFactory;
-use CoreFramework\Request\Requestable;
-use CoreFramework\Resolver\Command\CommandResolver;
-use CoreFramework\Response\Responseable;
+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 - 2015 Core Developer Team
+ * @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
  *
@@ -39,7 +40,7 @@ class TestsConsoleMainCommand extends BaseCommand implements Commandable {
         *
         * @return      void
         */
-       protected function __construct () {
+       private function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
        }
@@ -67,14 +68,21 @@ class TestsConsoleMainCommand extends BaseCommand implements Commandable {
         * @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        Try to create a TestsActivationTask or so
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
-               // Get a registry and the application instance from it
-               $applicationInstance = Registry::getRegistry()->getInstance('app');
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONSOLE-MAIN-COMMAND: requestInstance=%s,responseInstance=%s - CALLED!', $requestInstance->__toString(), $responseInstance->__toString()));
+               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('MAIN: --- Starting tests ... ---');
+
+               // Get controller
+               $controllerInstance = ObjectRegistry::getRegistry('generic')->getInstance('controller');
+
+               // Run all tests
+               $controllerInstance->executeTestsFilters($requestInstance, $responseInstance);
 
                // Debug message
-               self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main ... ---');
+               self::createDebugInstance(__CLASS__, __LINE__)->debugMessage('MAIN: --- Leaving main ... ---');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONSOLE-MAIN-COMMAND: EXIT!');
        }
 
        /**
@@ -85,11 +93,15 @@ class TestsConsoleMainCommand extends BaseCommand implements Commandable {
         * @return      void
         */
        public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
-               // @TODO Unfinished
-               return;
+               // Add pre filters (e.g. for requirements checks)
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('TESTS-CONSOLE-MAIN-COMMAND: controllerInstance=%s,requestInstance=%s - CALLED!', $controllerInstance->__toString(), $requestInstance->__toString()));
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('tests_php_requirements_filter_class'));
+
+               // Add 'tests' filters which will run the actual tests
+               $controllerInstance->addTestsFilter(ObjectFactory::createObjectByConfiguredName('tests_configuration_classes_loadable_test_filter_class'));
 
-               // Add pre filters
-               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('node_php_requirements_filter'));
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('TESTS-CONSOLE-MAIN-COMMAND: EXIT!');
        }
 
 }