Update file resource tests

This commit is contained in:
Uwe Tews
2015-07-07 17:11:05 +02:00
parent a0f18578e2
commit 62d0c170a0
19 changed files with 106 additions and 0 deletions

View File

@@ -0,0 +1 @@
include_test2

View File

@@ -0,0 +1 @@
include_test4

View File

@@ -0,0 +1 @@
{include 'include_test4.tpl'}

View File

@@ -0,0 +1,64 @@
<?php
/**
* Smarty PHPunit tests for File resources
*
* @package PHPunit
* @author Rodney Rehm
* @backupStaticAttributes enabled
*/
class FileIncludePathTest extends PHPUnit_Smarty
{
public function setUp()
{
$this->setUpSmarty(__DIR__);
$this->smarty->use_include_path = true;
$this->smarty->setTemplateDir(array('./templates', './templates_2', './include'));
$this->smarty->enableSecurity();
$ds = DS;
set_include_path($this->smarty->_realpath(__DIR__ . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Tpl{$ds}", true) . PATH_SEPARATOR . get_include_path());
}
/**
* Tears down the fixture
* This method is called after a test is executed.
*
*/
protected function tearDown()
{
restore_include_path();
$this->smarty->disableSecurity();
parent::tearDown();
}
public function testInit()
{
$this->cleanDirs();
}
public function testInclude1()
{
$this->assertContains('include_test1', $this->smarty->fetch('test1.tpl'));
}
public function testInclude2()
{
$this->assertContains('include_test2', $this->smarty->fetch('test2.tpl'));
}
public function testInclude3()
{
$this->assertContains('include_test3', $this->smarty->fetch('test3.tpl'));
}
public function testInclude31()
{
$this->smarty->use_include_path = false;
$this->smarty->security_policy->secure_dir = getcwd();
$this->assertContains('include_test3', $this->smarty->fetch('test3.tpl'));
}
public function testInclude4()
{
$this->assertContains('include_test4', $this->smarty->fetch('test4.tpl'));
}
public function testInclude5()
{
$this->assertContains('include_test4', $this->smarty->fetch('test5.tpl'));
}
}

View File

@@ -0,0 +1 @@
include_test3

View File

@@ -0,0 +1 @@
templates

View File

@@ -0,0 +1 @@
{include 'include_test1.tpl'}

View File

@@ -0,0 +1 @@
{include 'include_test2.tpl'}

View File

@@ -0,0 +1 @@
{include 'include_test3.tpl'}

View File

@@ -0,0 +1 @@
templates_2

View File

@@ -0,0 +1 @@
include_test1

View File

@@ -0,0 +1 @@
templates_3

View File

@@ -0,0 +1 @@
templates_4

View File

@@ -64,12 +64,37 @@ class FileResourceIndexedTest extends PHPUnit_Smarty
$tpl = $this->smarty->createTemplate('[10]dirname.tpl'); $tpl = $this->smarty->createTemplate('[10]dirname.tpl');
$this->assertEquals('templates_3', $this->smarty->fetch($tpl)); $this->assertEquals('templates_3', $this->smarty->fetch($tpl));
} }
public function testFetchNumeric2()
{
$tpl = $this->smarty->createTemplate('[10, 1]dirname10.tpl');
$this->assertEquals('templates_3', $this->smarty->fetch($tpl));
}
public function testFetchNumeric3()
{
$tpl = $this->smarty->createTemplate('[10, 1]dirname1.tpl');
$this->assertEquals('templates_2', $this->smarty->fetch($tpl));
}
public function testFetchName() public function testFetchName()
{ {
$tpl = $this->smarty->createTemplate('[foo]dirname.tpl'); $tpl = $this->smarty->createTemplate('[foo]dirname.tpl');
$this->assertEquals('templates_4', $this->smarty->fetch($tpl)); $this->assertEquals('templates_4', $this->smarty->fetch($tpl));
} }
public function testFetchName1()
{
$tpl = $this->smarty->createTemplate('[10,0,1,foo]dirname_foo.tpl');
$this->assertEquals('dirname_foo', $this->smarty->fetch($tpl));
}
public function testFetchName2()
{
$tpl = $this->smarty->createTemplate('[0,1,foo,10]dirname_x.tpl');
$this->assertEquals('templates_2', $this->smarty->fetch($tpl));
}
public function testFetchName3()
{
$tpl = $this->smarty->createTemplate('[0,10,foo,1]dirname_x.tpl');
$this->assertEquals('templates_4', $this->smarty->fetch($tpl));
}
public function testGetCompiledFilepath() public function testGetCompiledFilepath()
{ {

View File

@@ -0,0 +1 @@
templates_2

View File

@@ -0,0 +1 @@
templates_2

View File

@@ -0,0 +1 @@
templates_3

View File

@@ -0,0 +1 @@
dirname_foo

View File

@@ -0,0 +1 @@
templates_4