2008-07-21 13:59:24 +02:00
|
|
|
<?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);
|
|
|
|
}
|
2008-11-10 02:01:55 +01:00
|
|
|
|
|
|
|
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.");
|
|
|
|
}
|
2008-07-21 13:59:24 +02:00
|
|
|
}
|