示例#1
0
 public function testSubActions()
 {
     /* If a controller action returns another controller, ensure that the $action variable is correctly forwarded */
     $response = $this->get("ControllerTest_ContainerController/subcontroller/subaction");
     $this->assertEquals('subaction', $response->getBody());
     $request = new SS_HTTPRequest('GET', 'ControllerTest_ContainerController/subcontroller/substring/subvieweraction');
     /* Shift to emulate the director selecting the controller */
     $request->shift();
     /* Handle the request to create conditions where improperly passing the action to the viewer might fail */
     $controller = new ControllerTest_ContainerController();
     try {
         $controller->handleRequest($request, DataModel::inst());
     } catch (ControllerTest_SubController_Exception $e) {
         $this->fail($e->getMessage());
     }
 }
 public function testCommentedOutScriptTagIsIgnored()
 {
     $template = '<html><head></head><body><!--<script>alert("commented out");</script>-->' . '<h1>more content</h1></body></html>';
     $backend = Injector::inst()->create('Requirements_Backend');
     $this->setupRequirements($backend);
     $backend->setSuffixRequirements(false);
     $src = $this->getCurrentRelativePath() . '/RequirementsTest_a.js';
     $urlSrc = ControllerTest_ContainerController::join_links(Director::baseURL(), $src);
     $backend->javascript($src);
     $html = $backend->includeInHTML(false, $template);
     $this->assertEquals('<html><head></head><body><!--<script>alert("commented out");</script>-->' . '<h1>more content</h1><script type="text/javascript" src="' . $urlSrc . '"></script></body></html>', $html);
 }