X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=application%2Ftests%2Fclass_ApplicationHelper.php;h=6b234b436defa8a230624c09df15676c49ebe1b7;hp=5d3c60dc181e9128c43d84e74161d168eb441f7e;hb=146c8b3c929a1b0ab17d6605e5ae949ac44899c1;hpb=d5dc929cca6a35725ff7af3446e2764e6c739d81 diff --git a/application/tests/class_ApplicationHelper.php b/application/tests/class_ApplicationHelper.php index 5d3c60dc..6b234b43 100644 --- a/application/tests/class_ApplicationHelper.php +++ b/application/tests/class_ApplicationHelper.php @@ -1,11 +1,14 @@ 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'); @@ -205,7 +225,7 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica self::convertToClassName(sprintf( '%s_%s_controller_resolver', $this->getAppShortName(), - $responseType + FrameworkBootstrap::getRequestTypeFromSystem() )) ); $resolverInstance = ObjectFactory::createObjectByName($resolverClass, array($commandName, $this)); @@ -242,7 +262,7 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica * @return $masterTemplateName Name of the master template */ public function buildMasterTemplateName () { - return 'node_main'; + return 'tests_main'; } /**