/**
  * Constructor. Please use only getInstance to retrieve the single instance.
  * 
  * @see Context#getInstance
  */
 private function __construct()
 {
     $this->request = new Request();
     $this->response = new Response();
     $this->viewData = array();
     $this->behaviors = array();
     if (PHP_SAPI != 'cli') {
         try {
             $resolver = new Resolver();
             $this->extensionName = $resolver->getExtensionFromURL();
             $this->moduleName = Camelizer::firstToUpper($resolver->getModule());
             $this->actionName = Camelizer::firstToLower($resolver->getAction());
         } catch (ResolverException $re) {
             $this->extensionName = 'tao';
         }
     }
 }
Esempio n. 2
0
 public function __construct()
 {
     if (PHP_SAPI != 'cli') {
         try {
             $resolver = new Resolver();
             $this->extension = $resolver->getExtensionFromURL();
             $this->module = Camelizer::firstToUpper($resolver->getModule());
             $this->action = Camelizer::firstToLower($resolver->getAction());
         } catch (ResolverException $re) {
             $this->extension = 'tao';
         }
     }
     $this->epoch = time();
     $this->user = common_session_SessionManager::getSession()->getUserUri();
     $this->script = $_SERVER['PHP_SELF'];
     $this->system = new common_profiler_System();
 }
 public function testDefinitions()
 {
     $serviceDefinitionClass = new core_kernel_classes_Class(CLASS_SERVICESDEFINITION);
     foreach ($serviceDefinitionClass->getInstances(true) as $serviceDefinition) {
         if ($serviceDefinition->getUri() == 'http://www.tao.lu/Ontologies/TAODelivery.rdf#ServiceTestContainer' || $serviceDefinition->getUri() == 'http://www.tao.lu/Ontologies/TAOTest.rdf#FakeItemRunner') {
             // don't test the item / testcontainer since it's not a real service
             continue;
         }
         $serviceDefinitionUrl = $serviceDefinition->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_SUPPORTSERVICES_URL));
         $this->assertNotNull($serviceDefinitionUrl);
         $this->assertTrue(!empty($serviceDefinitionUrl));
         $fullUri = ROOT_URL . ltrim($serviceDefinitionUrl, '/');
         $resolver = new Resolver($fullUri);
         $ext = common_ext_ExtensionsManager::singleton()->getExtensionById($resolver->getExtensionFromURL());
         $controller = $ext->getModule($resolver->getModule());
         $this->assertTrue(method_exists($controller, $resolver->getAction()), 'action of service definition "' . $serviceDefinition->getLabel() . '" does not exist');
     }
 }
Esempio n. 4
0
 /**
  * Some actions should not be redirected (such as retrieving requireJs config)
  * @return array
  */
 private function getExcludedRoutes()
 {
     $result = $this->excludedRoutes;
     $resolver = new \Resolver($this->url);
     $result[] = ['extension' => $resolver->getExtensionFromURL(), 'module' => $resolver->getModule(), 'action' => $resolver->getAction()];
     return $result;
 }
 /**
  * Some actions should not be redirected (such as retrieving requireJs config)
  *
  * @return array
  */
 protected function getExcludedRoutes()
 {
     $result = $this->excludedRoutes;
     $resolver = new \Resolver($this->getTransformedUrl());
     $result[] = ['extension' => $resolver->getExtensionFromURL(), 'module' => $resolver->getModule(), 'action' => $resolver->getAction()];
     return $result;
 }
 /**
  * Get current test session meta data array
  * 
  * @return array test session meta data.
  */
 protected function getSessionMeta()
 {
     $fromRequest = $this->getRequestParameter('metaData');
     $data = empty($fromRequest) ? array() : $fromRequest;
     $resolver = new Resolver();
     if (in_array($resolver->getAction(), array('moveForward', 'skip'))) {
         $route = $this->getTestSession()->getRoute();
         if (!isset($data['SECTION']['SECTION_EXIT_CODE'])) {
             $currentSection = $this->getTestSession()->getCurrentAssessmentSection();
             $lastInSection = $route->isLast() || $route->getNext()->getAssessmentSection()->getIdentifier() !== $currentSection->getIdentifier();
             if ($lastInSection) {
                 $data['SECTION']['SECTION_EXIT_CODE'] = TestSessionMetaData::SECTION_CODE_COMPLETED_NORMALLY;
             }
         }
         if ($route->isLast()) {
             $data['TEST']['TEST_EXIT_CODE'] = TestSessionMetaData::TEST_CODE_COMPLETE;
         }
     }
     return $data;
 }