protected function generateResponseForRequest($request = false) { if ($this->staticFile !== false) { $response = new Response(); LayoutModule::disableLayout(); if (substr($this->staticFile, -4) == ".css") { $mime = "text/css"; } else { $info = new \finfo(FILEINFO_MIME); $mime = $info->file($this->staticFile); } if ($mime !== false) { if (substr($this->staticFile, -3) == ".js") { $mime = str_replace("text/plain", "application/javascript", $mime); } HttpHeaders::setHeader("Content-type", $mime); $response->setHeader('Content-Type', $mime); } ob_start(); readfile($this->staticFile); $response->setContent(ob_get_clean()); return $response; } return false; }
protected function setUp() { parent::setUp(); $this->application->context()->simulateNonCli = true; $this->request = $this->application->request(); $this->request->IsWebRequest = true; LayoutModule::disableLayout(); }
public function generateResponse($request = null) { if (class_exists("Rhubarb\\Crown\\Layout\\LayoutModule")) { LayoutModule::disableLayout(); } $schemas = SolutionSchema::getAllSchemas(); foreach ($schemas as $schema) { $schema->checkModelSchemas(); } $response = new HtmlResponse(); $response->setContent("Done"); return $response; }
protected function createView() { LayoutModule::disableLayout(); return new ImgView(); }
protected function setUp() { $this->request = Context::CurrentRequest(); $this->request->IsWebRequest = true; LayoutModule::disableLayout(); }
public function testDisablingTrapping() { ExceptionHandler::disableExceptionTrapping(); try { // Enable layouts for this test as proof the URL handler has intercepted the response. LayoutModule::enableLayout(); $request = new WebRequest(); $request->UrlPath = "/test-exception/"; $response = Module::generateResponseForRequest($request); $this->fail("Without exception trapping this line should not be reached."); } catch (RhubarbException $er) { } ExceptionHandler::setExceptionHandlerClassName('\\Rhubarb\\Crown\\Tests\\Exceptions\\Handlers\\UnitTestDisobedientExceptionHandler'); try { // Enable layouts for this test as proof the URL handler has intercepted the response. LayoutModule::enableLayout(); $request = new WebRequest(); $request->UrlPath = "/test-exception/"; $response = Module::generateResponseForRequest($request); } catch (RhubarbException $er) { $this->fail("The extended exception handler should force handling of exceptions even if trapping is disabled."); } ExceptionHandler::enableExceptionTrapping(); LayoutModule::disableLayout(); }
public static function tearDownAfterClass() { parent::tearDownAfterClass(); LayoutModule::setLayoutClassName("Rhubarb\\Crown\\Tests\\Layout\\TestLayout"); LayoutModule::disableLayout(); }
public static function tearDownAfterClass() { parent::tearDownAfterClass(); LayoutModule::setLayoutClassName(TestLayout::class); LayoutModule::disableLayout(); }
public function testDisablingTrapping() { ExceptionHandler::disableExceptionTrapping(); try { // Enable layouts for this test as proof the URL handler has intercepted the response. LayoutModule::enableLayout(); $request = new WebRequest(); $request->urlPath = "/test-exception/"; $response = $this->application->generateResponseForRequest($request); $this->fail("Without exception trapping this line should not be reached."); } catch (RhubarbException $er) { } $this->application->container()->registerClass(ExceptionHandler::class, UnitTestDisobedientExceptionHandler::class); try { // Enable layouts for this test as proof the URL handler has intercepted the response. LayoutModule::enableLayout(); $request = new WebRequest(); $request->urlPath = "/test-exception/"; $response = $this->application->generateResponseForRequest($request); } catch (RhubarbException $er) { $this->fail("The extended exception handler should force handling of exceptions even if trapping is disabled."); } ExceptionHandler::enableExceptionTrapping(); LayoutModule::disableLayout(); }