Continued:
authorRoland Haeder <roland@mxchange.org>
Sun, 26 Feb 2017 18:58:40 +0000 (19:58 +0100)
committerRoland Haeder <roland@mxchange.org>
Tue, 28 Feb 2017 21:11:02 +0000 (22:11 +0100)
- added generic test on loading classes configured in some_foo_class entries
- now you can see, why "_class" must be set
- added method getConfigurationArray() in FrameworkConfiguration which returns
  the whole configuration array ...
- added "import" of XmlParser + fixed config entry with namespace
- added "import" of BaseParser and Parseable

Signed-off-by: Roland H├Ąder <roland@mxchange.org>
framework/config.php
framework/config/class_FrameworkConfiguration.php
framework/main/classes/class_BaseFrameworkSystem.php
framework/main/classes/decorator/xml/class_XmlCompactorDecorator.php
framework/main/classes/parser/xml/class_XmlParser.php
framework/main/classes/template/image/class_ImageTemplateEngine.php
framework/main/classes/template/mail/class_MailTemplateEngine.php
framework/main/classes/template/menu/class_MenuTemplateEngine.php
framework/main/tests/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php

index f389f4b..89fd2f3 100644 (file)
@@ -266,7 +266,7 @@ $cfg->setConfigEntry('image_cmd_code_captcha_resolver_class', 'ImageCommandResol
 $cfg->setConfigEntry('mailer_class', 'DebugMailer');
 
 // CFG: XML-PARSER-CLASS
-$cfg->setConfigEntry('xml_parser_class', 'XmlParser');
+$cfg->setConfigEntry('xml_parser_class', 'CoreFramework\Parser\Xml\XmlParser');
 
 // CFG: DECO-COMPACTING-XML-PARSER-CLASS
 $cfg->setConfigEntry('deco_compacting_xml_parser_class', 'XmlCompactorDecorator');
index ee7439e..733ba9e 100644 (file)
@@ -210,6 +210,16 @@ class FrameworkConfiguration implements Registerable {
        }
 
        /**
+        * Getter for whole configuration array
+        *
+        * @return      $config         Configuration array
+        */
+       public final function getConfigurationArray () {
+               // Return it
+               return $this->config;
+       }
+
+       /**
         * Unset a configuration key, the entry must be there or else an
         * exception is thrown.
         *
index 423fe29..7185309 100644 (file)
@@ -20,6 +20,7 @@ use CoreFramework\Loader\ClassLoader;
 use CoreFramework\Manager\ManageableApplication;
 use CoreFramework\Middleware\Compressor\CompressorChannel;
 use CoreFramework\Middleware\Debug\DebugMiddleware;
+use CoreFramework\Parser\Parseable;
 use CoreFramework\Registry\Register;
 use CoreFramework\Registry\Registry;
 use CoreFramework\Request\Requestable;
index 152eb9f..50fba45 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Parser\Xml;
 
 // Import framework stuff
 use CoreFramework\Factory\ObjectFactory;
+use CoreFramework\Parser\Parseable;
 
 /**
  * A XML compacting decorator class for XML parsers
index 318e344..7a84119 100644 (file)
@@ -3,6 +3,8 @@
 namespace CoreFramework\Parser\Xml;
 
 // Import framework stuff
+use CoreFramework\Parser\BaseParser;
+use CoreFramework\Parser\Parseable;
 use CoreFramework\Template\CompileableTemplate;
 
 /**
index c438b04..950b886 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Template\Engine;
 
 // Import framework stuff
 use CoreFramework\Factory\ObjectFactory;
+use CoreFramework\Parser\Xml\XmlParser;
 use CoreFramework\Registry\Registry;
 use CoreFramework\Response\Responseable;
 use CoreFramework\Template\CompileableTemplate;
index 8f031a8..2c73e33 100644 (file)
@@ -3,6 +3,7 @@
 namespace CoreFramework\Template\Engine;
 
 // Import framework stuff
+use CoreFramework\Parser\Xml\XmlParser;
 use CoreFramework\Registry\Registry;
 use CoreFramework\Response\Responseable;
 use CoreFramework\Template\CompileableTemplate;
index 64ab5b3..6663f8a 100644 (file)
@@ -4,6 +4,7 @@ namespace CoreFramework\Template\Engine;
 
 // Import framework stuff
 use CoreFramework\Factory\ObjectFactory;
+use CoreFramework\Parser\Xml\XmlParser;
 use CoreFramework\Registry\Registry;
 use CoreFramework\Template\CompileableTemplate;
 
index 175f517..b6f49a7 100644 (file)
@@ -8,6 +8,9 @@ use CoreFramework\Request\Requestable;
 use CoreFramework\Response\Responseable;
 use CoreFramework\Tests\Filter\BaseTestsFilter;
 
+// Import SPL stuff
+use \InvalidArgumentException;
+
 /**
  * A LoadableClasses filter for tests
  *
@@ -63,6 +66,39 @@ class TestConfigurationLoadableClassesFilter extends BaseTestsFilter implements
         * @todo        0% done
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Loop through all configuration keys
+               foreach ($this->getConfigInstance()->getConfigurationArray() as $configKey => $configValue) {
+                       // Key must end with _class
+                       if (substr($configKey, -6, 6) != '_class') {
+                               // Skip this
+                               continue;
+                       } // END - if
+
+                       // Output message
+                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Testing configKey=%s,configValue[%s]=%s', $configKey, gettype($configValue), $configValue));
+
+                       // This may throw exceptions
+                       try {
+                               // Is the class there?
+                               if (!class_exists($configValue)) {
+                                       // Class not found
+                                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Class "%s" not found. FAILED', $configValue));
+
+                                       // Skip further tests
+                                       continue;
+                               } // END - if
+                       } 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
+                               continue;
+                       }
+
+                       // class_exists() didn't fail
+                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Class "%s" loaded successfully. OKAY', $configValue));
+               } // END - foreach
+
                // Implement this!
                $this->partialStub('Please implement this method.');
        }