Esempio n. 1
0
 public function bind(\Nethgui\Controller\RequestInterface $request)
 {
     parent::bind($request);
     $fileName = \Nethgui\array_head($request->getPath());
     if (preg_match('/[a-z][a-z0-9]+(.rst)/i', $fileName) == 0 && preg_match('/[a-z][a-z0-9]+(.html)/i', $fileName) == 0) {
         throw new \Nethgui\Exception\HttpException('Not found', 404, 1322148405);
     }
     // Now assuming a trailing ".rst" or ".html" suffix.
     if (substr($fileName, -3) == 'rst') {
         $this->module = $this->getModuleSet()->getModule(substr($fileName, 0, -4));
     } else {
         //html
         $this->module = $this->getModuleSet()->getModule(substr($fileName, 0, -5));
     }
     if (is_null($this->module)) {
         throw new \Nethgui\Exception\HttpException('Not found', 404, 1322148406);
     }
     $this->module->setPlatform($this->getPlatform());
     if (!$this->module->isInitialized()) {
         $this->module->initialize();
     }
 }
Esempio n. 2
0
 protected function runModuleTest(\Nethgui\Module\ModuleInterface $module, ModuleTestEnvironment $env)
 {
     $platform = $this->createPlatformMock($env);
     $module->setPlatform($platform);
     $module->initialize();
     if ($module instanceof \Nethgui\Controller\RequestHandlerInterface) {
         $request = $this->createRequestMock($env);
         $validationReport = $this->createValidationReportMock($env);
         $module->bind($request);
         $module->validate($validationReport);
         $module->process();
     }
     $view = $this->createViewMock($module, $env);
     $module->prepareView($view);
     $platform->signalFinalEvents();
     foreach ($env->getView() as $key => $value) {
         $this->assertEquals($value, $view[$key], "View parameter `{$key}`.");
     }
     $this->fullViewOutput = array();
     // obsolete: $view->getClientEvents();
     foreach ($this->dbObjectCheckList as $dbStubInfo) {
         $this->assertTrue($dbStubInfo[1]->getState()->isFinal(), sprintf('Database `%s` is not in final state! %s', $dbStubInfo[0], $dbStubInfo[1]->getState()));
     }
 }