public function testLayoutCanBeDisabled() { LayoutModule::disableLayout(); $this->assertTrue(LayoutModule::isDisabled()); LayoutModule::enableLayout(); $this->assertFalse(LayoutModule::isDisabled()); }
public function testUrlExtractedFromHandler() { LayoutModule::enableLayout(); $request = new WebRequest(); $request->urlPath = "/computed-url/test/"; $response = $this->application->generateResponseForRequest($request); $this->assertEquals("TopComputed URL ResponseTail", $response->getContent()); }
public function testStaticFileDisablesLayout() { LayoutModule::enableLayout(); $handler = new StaticResourceUrlHandler(__DIR__ . "/../../Fixtures/UrlHandlers/test.txt"); $handler->setUrl("/test.txt"); $this->request->urlPath = "/test.txt"; $handler->generateResponse($this->request); $this->assertTrue(LayoutModule::isDisabled()); }
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 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(); }