public function testBaseTagGeneration() { // XHTML wil have a closed base tag $tmpl1 = '<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' . ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head><% base_tag %></head> <body><p>test</p><body> </html>'; $this->assertRegExp('/<head><base href=".*" \\/><\\/head>/', $this->render($tmpl1)); // HTML4 and 5 will only have it for IE $tmpl2 = '<!DOCTYPE html> <html> <head><% base_tag %></head> <body><p>test</p><body> </html>'; $this->assertRegExp('/<head><base href=".*"><!--\\[if lte IE 6\\]><\\/base><!\\[endif\\]--><\\/head>/', $this->render($tmpl2)); $tmpl3 = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head><% base_tag %></head> <body><p>test</p><body> </html>'; $this->assertRegExp('/<head><base href=".*"><!--\\[if lte IE 6\\]><\\/base><!\\[endif\\]--><\\/head>/', $this->render($tmpl3)); // Check that the content negotiator converts to the equally legal formats $negotiator = new ContentNegotiator(); $response = new SS_HTTPResponse($this->render($tmpl1)); $negotiator->html($response); $this->assertRegExp('/<head><base href=".*"><!--\\[if lte IE 6\\]><\\/base><!\\[endif\\]--><\\/head>/', $response->getBody()); $response = new SS_HTTPResponse($this->render($tmpl1)); $negotiator->xhtml($response); $this->assertRegExp('/<head><base href=".*" \\/><\\/head>/', $response->getBody()); }