mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
0328ff5c9d
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@65926 467b73ca-7a2a-4603-9d3b-597d59a354a9
46 lines
1.4 KiB
PHP
46 lines
1.4 KiB
PHP
<?php
|
|
|
|
class SSViewerTest extends SapphireTest {
|
|
/**
|
|
* Test that a template without a <head> tag still renders.
|
|
*/
|
|
function testTemplateWithoutHeadRenders() {
|
|
$data = new ArrayData(array(
|
|
'Var' => 'var value'
|
|
));
|
|
|
|
$result = $data->renderWith("SSViewerTestPartialTemplate");
|
|
$this->assertEquals('Test partial template: var value', $result);
|
|
}
|
|
|
|
function testRequirements() {
|
|
$requirements = $this->getMock("Requirements_Backend", array("javascript", "css"));
|
|
$jsFile = 'sapphire/tests/forms/a.js';
|
|
$cssFile = 'sapphire/tests/forms/a.js';
|
|
|
|
$requirements->expects($this->once())->method('javascript')->with($jsFile);
|
|
$requirements->expects($this->once())->method('css')->with($cssFile);
|
|
|
|
Requirements::set_backend($requirements);
|
|
|
|
$data = new ArrayData(array());
|
|
|
|
$viewer = SSViewer::fromString(<<<SS
|
|
<% require javascript($jsFile) %>
|
|
<% require css($cssFile) %>
|
|
SS
|
|
);
|
|
$template = $viewer->process($data);
|
|
$this->assertFalse((bool)trim($template), "Should be no content in this return.");
|
|
}
|
|
|
|
function testComments() {
|
|
$viewer = SSViewer::fromString(<<<SS
|
|
This is my template<%-- this is a comment --%>This is some content<%-- this is another comment --%>This is the final content
|
|
SS
|
|
);
|
|
$output = $viewer->process(new ArrayData(array()));
|
|
|
|
$this->assertEquals("This is my templateThis is some contentThis is the final content", $output);
|
|
}
|
|
} |