<?php
-// Own namespace
+// Must be this namespace, else the launcher cannot find the class.
namespace CoreFramework\Helper\Application;
// Import framework stuff
+use CoreFramework\Bootstrap\FrameworkBootstrap;
+use CoreFramework\Configuration\FrameworkConfiguration;
+use CoreFramework\Factory\ObjectFactory;
+use CoreFramework\Loader\ClassLoader;
use CoreFramework\Manager\ManageableApplication;
use CoreFramework\Object\BaseFrameworkSystem;
-use CoreFramework\Factory\ObjectFactory;
use CoreFramework\Registry\Registerable;
-use CoreFramework\Registry\Generic\Registry;
+use CoreFramework\Registry\Registry;
use CoreFramework\Template\CompileableTemplate;
/**
}
/**
- * Launches the test suite
+ * 1) Setups application data
+ *
+ * @return void
+ */
+ public function setupApplicationData () {
+ // Set all application data
+ $this->setAppName('Unit tests and more');
+ $this->setAppVersion('0.0.0');
+ $this->setAppShortName('tests');
+ }
+
+ /**
+ * 2) Does initial stuff before starting the application
*
* @return void
*/
- public final function entryPoint () {
- // Set this application in registry
- Registry::getRegistry()->addInstance('app', $this);
+ public function initApplication () {
+ // Get config instance
+ $cfg = FrameworkConfiguration::getSelfInstance();
- // Default response is console
- $response = self::getResponseTypeFromSystem();
- $responseType = self::getResponseTypeFromSystem();
+ // Initialize output system
+ self::createDebugInstance('ApplicationHelper');
- // Create a new request object
- $requestInstance = ObjectFactory::createObjectByName(sprintf('\CoreFramework\Request\%sRequest', self::convertToClassName($response)));
+ /*
+ * This application needs a database connection then simply call init
+ * method.
+ */
+ FrameworkBootstrap::initDatabaseInstance();
- // Remember request instance here
- $this->setRequestInstance($requestInstance);
+ // Register core tests
+ ClassLoader::registerTestsPath('framework/main/tests');
- // Do we have another response?
- if ($requestInstance->isRequestElementSet('request')) {
- // Then use it
- $response = strtolower($requestInstance->getRequestElement('request'));
- $responseType = $response;
- } // END - if
+ // Register own tests
+ ClassLoader::registerTestsPath('application/tests/tests');
- // ... and a new response object
- $responseClass = sprintf('\CoreFramework\Response\%sResponse', self::convertToClassName($response));
- $responseInstance = ObjectFactory::createObjectByName($responseClass, array($this));
+ // Scan for them now
+ ClassLoader::scanTestsClasses();
+ }
- // Remember response instance here
- $this->setResponseInstance($responseInstance);
+ /**
+ * 3) Launches the application
+ *
+ * @return void
+ */
+ public function launchApplication () {
+ // Get request/response instances
+ $requestInstance = FrameworkBootstrap::getRequestInstance();
+ $responseInstance = FrameworkBootstrap::getResponseInstance();
// Get the parameter from the request
$commandName = $requestInstance->getRequestElement('command');
} // END - if
// Get a controller resolver
- $resolverClass = self::convertToClassName($this->getAppShortName() . '_' . $responseType . '_controller_resolver');
+ $resolverClass = sprintf(
+ 'CoreFramework\Tests\Resolver\Controller\%s',
+ self::convertToClassName(sprintf(
+ '%s_%s_controller_resolver',
+ $this->getAppShortName(),
+ FrameworkBootstrap::getRequestTypeFromSystem()
+ ))
+ );
$resolverInstance = ObjectFactory::createObjectByName($resolverClass, array($commandName, $this));
// Get a controller instance as well
$this->getControllerInstance()->handleRequest($requestInstance, $responseInstance);
// -------------------------- Shutdown phase --------------------------
- // Shutting down the hub by saying "good bye" to all connected peers
- // and other hubs, flushing all queues and caches.
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: Shutdown in progress, main loop exited.');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: Shutdown in progress ...');
$this->getControllerInstance()->executeShutdownFilters($requestInstance, $responseInstance);
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: Shutdown completed. (This is the last line.)');
}
* @return $masterTemplateName Name of the master template
*/
public function buildMasterTemplateName () {
- return 'node_main';
+ return 'tests_main';
}
/**