diff --git a/tests/view/SSViewerTest.php b/tests/view/SSViewerTest.php index aae7951b0..225773c0d 100644 --- a/tests/view/SSViewerTest.php +++ b/tests/view/SSViewerTest.php @@ -898,6 +898,41 @@ after') ); } + protected function useTestTheme($theme, $callback) { + global $project; + + $themeBaseDir = dirname(__FILE__); + $manifest = new SS_TemplateManifest($themeBaseDir, $project, true, true); + + SS_TemplateLoader::instance()->pushManifest($manifest); + + $origTheme = SSViewer::current_theme(); + SSViewer::set_theme($theme); + + $e = null; + + try { $callback(); } + catch (Exception $e) { /* NOP for now, just save $e */ } + + // Remove all the test themes we created + SS_TemplateLoader::instance()->popManifest(); + SSViewer::set_theme($origTheme); + + if ($e) throw $e; + } + + public function testLayout() { + $self = $this; + + $this->useTestTheme('layouttest', function() use ($self) { + $template = new SSViewer(array('Page')); + $self->assertEquals('Foo', $template->process(new ArrayData(array()))); + + $template = new SSViewer(array('Shortcodes', 'Page')); + $self->assertEquals('[file_link]', $template->process(new ArrayData(array()))); + }); + } + /** * @covers SSViewer::get_themes() */ @@ -929,7 +964,7 @@ after') // Remove all the test themes we created Filesystem::removeFolder($testThemeBaseDir); } - + public function testRewriteHashlinks() { $oldRewriteHashLinks = SSViewer::getOption('rewriteHashlinks'); SSViewer::setOption('rewriteHashlinks', true); diff --git a/tests/view/themes/layouttest/Layout/Page.ss b/tests/view/themes/layouttest/Layout/Page.ss new file mode 100644 index 000000000..9f26b637f --- /dev/null +++ b/tests/view/themes/layouttest/Layout/Page.ss @@ -0,0 +1 @@ +Foo \ No newline at end of file diff --git a/tests/view/themes/layouttest/Layout/Shortcodes.ss b/tests/view/themes/layouttest/Layout/Shortcodes.ss new file mode 100644 index 000000000..d0f2184cd --- /dev/null +++ b/tests/view/themes/layouttest/Layout/Shortcodes.ss @@ -0,0 +1 @@ +[file_link] \ No newline at end of file diff --git a/tests/view/themes/layouttest/Page.ss b/tests/view/themes/layouttest/Page.ss new file mode 100644 index 000000000..7ab05d93a --- /dev/null +++ b/tests/view/themes/layouttest/Page.ss @@ -0,0 +1 @@ +$Layout \ No newline at end of file diff --git a/view/SSViewer.php b/view/SSViewer.php index 177f48753..701fd50d4 100644 --- a/view/SSViewer.php +++ b/view/SSViewer.php @@ -909,7 +909,12 @@ class SSViewer { $subtemplateViewer->includeRequirements(false); $subtemplateViewer->setPartialCacheStore($this->getPartialCacheStore()); - $underlay[$subtemplate] = $subtemplateViewer->process($item, $arguments); + $underlay[$subtemplate] = DBField::create_field( + 'HTMLText', + $subtemplateViewer->process($item, $arguments), + $subtemplate, + array('shortcodes' => false) + ); } }