mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
Update file resource tests
This commit is contained in:
1
tests/Include_Path/Tpl/include/include_test2.tpl
Normal file
1
tests/Include_Path/Tpl/include/include_test2.tpl
Normal file
@@ -0,0 +1 @@
|
||||
include_test2
|
1
tests/Include_Path/Tpl/include/include_test4.tpl
Normal file
1
tests/Include_Path/Tpl/include/include_test4.tpl
Normal file
@@ -0,0 +1 @@
|
||||
include_test4
|
1
tests/Include_Path/Tpl/templates_2/test4.tpl
Normal file
1
tests/Include_Path/Tpl/templates_2/test4.tpl
Normal file
@@ -0,0 +1 @@
|
||||
{include 'include_test4.tpl'}
|
@@ -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'));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1 @@
|
||||
include_test3
|
@@ -0,0 +1 @@
|
||||
templates
|
@@ -0,0 +1 @@
|
||||
{include 'include_test1.tpl'}
|
@@ -0,0 +1 @@
|
||||
{include 'include_test2.tpl'}
|
@@ -0,0 +1 @@
|
||||
{include 'include_test3.tpl'}
|
@@ -0,0 +1 @@
|
||||
templates_2
|
@@ -0,0 +1 @@
|
||||
include_test1
|
@@ -0,0 +1 @@
|
||||
templates_3
|
@@ -0,0 +1 @@
|
||||
templates_4
|
@@ -64,12 +64,37 @@ class FileResourceIndexedTest extends PHPUnit_Smarty
|
||||
$tpl = $this->smarty->createTemplate('[10]dirname.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()
|
||||
{
|
||||
$tpl = $this->smarty->createTemplate('[foo]dirname.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()
|
||||
{
|
||||
|
@@ -0,0 +1 @@
|
||||
templates_2
|
@@ -0,0 +1 @@
|
||||
templates_2
|
@@ -0,0 +1 @@
|
||||
templates_3
|
@@ -0,0 +1 @@
|
||||
dirname_foo
|
@@ -0,0 +1 @@
|
||||
templates_4
|
Reference in New Issue
Block a user