2020-04-13 15:30:52 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Smarty PHPunit tests for File resources
|
|
|
|
|
*
|
|
|
|
|
* @package PHPunit
|
|
|
|
|
* @author Rodney Rehm
|
|
|
|
|
* @runTestsInSeparateProcess
|
|
|
|
|
* @preserveGlobalState disabled
|
|
|
|
|
* @backupStaticAttributes enabled
|
|
|
|
|
*/
|
|
|
|
|
class FileIncludePathTest extends PHPUnit_Smarty
|
|
|
|
|
{
|
2021-10-13 12:15:17 +02:00
|
|
|
public function setUp(): void
|
2020-04-13 15:30:52 +02:00
|
|
|
{
|
|
|
|
|
$this->setUpSmarty(dirname(__FILE__));
|
|
|
|
|
$this->smarty->use_include_path = true;
|
|
|
|
|
$this->smarty->setTemplateDir(array('./templates', './templates_2', './include'));
|
|
|
|
|
$this->smarty->enableSecurity();
|
|
|
|
|
$ds = DIRECTORY_SEPARATOR;
|
|
|
|
|
set_include_path($this->smarty->_realpath(dirname(__FILE__) . "{$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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2021-10-13 12:15:17 +02:00
|
|
|
protected function tearDown(): void
|
2020-04-13 15:30:52 +02:00
|
|
|
{
|
|
|
|
|
ini_restore('include_path');
|
|
|
|
|
$this->smarty->disableSecurity();
|
|
|
|
|
parent::tearDown();
|
|
|
|
|
}
|
|
|
|
|
public function testInit()
|
|
|
|
|
{
|
|
|
|
|
$this->cleanDirs();
|
|
|
|
|
}
|
|
|
|
|
public function testInclude1()
|
|
|
|
|
{
|
2021-10-13 12:15:17 +02:00
|
|
|
$this->assertStringContainsString('include_test1', $this->smarty->fetch('test1.tpl'));
|
2020-04-13 15:30:52 +02:00
|
|
|
}
|
|
|
|
|
public function testInclude2()
|
|
|
|
|
{
|
2021-10-13 12:15:17 +02:00
|
|
|
$this->assertStringContainsString('include_test2', $this->smarty->fetch('test2.tpl'));
|
2020-04-13 15:30:52 +02:00
|
|
|
}
|
|
|
|
|
public function testInclude3()
|
|
|
|
|
{
|
2021-10-13 12:15:17 +02:00
|
|
|
$this->assertStringContainsString('include_test3', $this->smarty->fetch('test3.tpl'));
|
2020-04-13 15:30:52 +02:00
|
|
|
}
|
|
|
|
|
public function testInclude31()
|
|
|
|
|
{
|
|
|
|
|
$this->smarty->use_include_path = false;
|
|
|
|
|
$this->smarty->security_policy->secure_dir = getcwd();
|
2021-10-13 12:15:17 +02:00
|
|
|
$this->assertStringContainsString('include_test3', $this->smarty->fetch('test3.tpl'));
|
2020-04-13 15:30:52 +02:00
|
|
|
}
|
|
|
|
|
public function testInclude4()
|
|
|
|
|
{
|
2021-10-13 12:15:17 +02:00
|
|
|
$this->assertStringContainsString('include_test4', $this->smarty->fetch('test4.tpl'));
|
2020-04-13 15:30:52 +02:00
|
|
|
}
|
|
|
|
|
public function testInclude5()
|
|
|
|
|
{
|
|
|
|
|
$this->smarty->setTemplateDir(array('./'));
|
2021-10-13 12:15:17 +02:00
|
|
|
$this->assertStringContainsString('include path root', $this->smarty->fetch('test5.tpl'));
|
2020-04-13 15:30:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|