registerTestingTemplate('/tags/core/include/terminal.html', $template, 'terminal.html');
$template = 'Nested--Nested';
$this->registerTestingTemplate('/tags/core/include/nested.html', $template, 'nested.html');
}
function testInclude()
{
$page = $this->initTemplate('nested.html');
$output = $page->capture();
$this->assertEqual($output, 'Nested-Terminal-Nested');
}
function testIncludeMissingFile()
{
$template = '';
$this->registerTestingTemplate('/tags/core/include/missing_file.html', $template);
try
{
$page = $this->initTemplate('/tags/core/include/missing_file.html');
$this->assertTrue(false);
}
catch(WactException $e)
{
$this->assertWantedPattern('/Template source file not found/', $e->getMessage());
}
}
function testMissingFileAttribute()
{
$template = 'Include--Include';
$this->registerTestingTemplate('/tags/core/include/missing_file_attribute.html', $template);
try
{
$page = $this->initTemplate('/tags/core/include/missing_file_attribute.html');
$this->assertTrue(false);
}
catch(WactException $e)
{
$this->assertWantedPattern('/Missing required attribute/', $e->getMessage());
}
}
function testNestedInclude()
{
$template = 'Include--Include';
$this->registerTestingTemplate('/tags/core/include/nested_include.html', $template);
$page = $this->initTemplate('/tags/core/include/nested_include.html');
$output = $page->capture();
$this->assertEqual($output, 'Include-Nested-Terminal-Nested-Include');
}
function testIncludeFileAttributeVariable()
{
$template = '';
$this->registerTestingTemplate('/tags/core/include/file_attribute_variable.html', $template);
$page = $this->initTemplate('/tags/core/include/file_attribute_variable.html');
$output = $page->capture();
$this->assertEqual($output, 'Terminal');
}
function testIncludedVariableReference()
{
$template = '{$Variable}';
$this->registerTestingTemplate('/tags/core/include/varref.html', $template);
$template = 'Include--Include';
$this->registerTestingTemplate('/tags/core/include/includedvarref.html', $template);
$page = $this->initTemplate('/tags/core/include/includedvarref.html');
$page->set('Variable', 'Here');
$output = $page->capture();
$this->assertEqual($output, 'Include-Here-Include');
}
function testIncludeLiteral()
{
$literal_template = '{$Ref}{$Ref}';
$this->registerTestingTemplate('/tags/core/include/literal.html', $literal_template);
$template = '';
$this->registerTestingTemplate('/tags/core/include/includeliteral.html', $template);
$page = $this->initTemplate('/tags/core/include/includeliteral.html');
$output = $page->capture();
$this->assertEqual($output, $literal_template);
}
function testIncludedTemplateWithNonClosedTagGeneratesProperErrorException()
{
$include_template = '
';
$this->registerTestingTemplate('/tags/core/include/included_template.html', $include_template);
$template = '
';
$this->registerTestingTemplate('/tags/core/include/main_template.html', $template);
try
{
$page = $this->initTemplate('/tags/core/include/main_template.html');
$this->assertTrue(false);
}
catch(WactException $e)
{
$this->assertWantedPattern('/Missing close tag/', $e->getMessage());
$this->assertEqual($e->getParam('file'), '/tags/core/include/included_template.html');
$this->assertEqual($e->getParam('line'), 1);
}
}
function testIncludeAndSetVariablesInCurrentDatasource()
{
$child_template = '
{$Ref}';
$this->registerTestingTemplate('/tags/core/include/child.html', $child_template);
$template = '
{$Ref}';
$this->registerTestingTemplate('/tags/core/include/parent.html', $template);
$page = $this->initTemplate('/tags/core/include/parent.html');
$output = $page->capture();
$this->assertEqual($output, '
aa');
}
function testIncludeAndSetVariablesWithDBEInCurrentDatasource()
{
$child_template = '
{$Ref}';
$this->registerTestingTemplate('/tags/core/include/child2.html', $child_template);
$template = '
';
$this->registerTestingTemplate('/tags/core/include/parent_with_dbe_var.html', $template);
$page = $this->initTemplate('/tags/core/include/parent_with_dbe_var.html');
$page->set('a', 'value');
$output = $page->capture();
$this->assertEqual($output, '
value');
}
function testSkipSettingReservedVars()
{
$child_template = '{$file}
{$Ref}';
$this->registerTestingTemplate('/tags/core/include/child3.html', $child_template);
$template = '
';
$this->registerTestingTemplate('/tags/core/include/parent_skip_setting_reserved_vars.html', $template);
$page = $this->initTemplate('/tags/core/include/parent_skip_setting_reserved_vars.html');
$output = $page->capture();
$this->assertEqual($output, '
a');
}
function testIncludeAndSetVariablesInNewDatasource()
{
$child_template = '
{$Ref}';
$this->registerTestingTemplate('/tags/core/include/child_in_datasource.html', $child_template);
$template = '
{$Ref}';
$this->registerTestingTemplate('/tags/core/include/parent_creates_new_datasource.html', $template);
$page = $this->initTemplate('/tags/core/include/parent_creates_new_datasource.html');
$page->set('Ref', 'value');
$output = $page->capture();
$this->assertEqual($output, '
avalue');
}
}
?>