2011-05-18 10:57:04 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
*
|
2014-05-27 20:18:06 +02:00
|
|
|
* This file is part of the phpBB Forum Software package.
|
|
|
|
*
|
|
|
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
|
|
|
*
|
|
|
|
* For full copyright and license information, please see
|
|
|
|
* the docs/CREDITS.txt file.
|
2011-05-18 10:57:04 -04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once dirname(__FILE__) . '/template_test_case.php';
|
|
|
|
|
|
|
|
class phpbb_template_includephp_test extends phpbb_template_template_test_case
|
|
|
|
{
|
|
|
|
public function test_includephp_relative()
|
|
|
|
{
|
2011-07-10 00:35:07 +02:00
|
|
|
$this->setup_engine(array('tpl_allow_php' => true));
|
2011-05-18 10:57:04 -04:00
|
|
|
|
2013-06-25 16:51:50 -05:00
|
|
|
$this->run_template('includephp_relative.html', array(), array(), array(), "Path is relative to board root.\ntesting included php");
|
2011-05-18 10:57:04 -04:00
|
|
|
|
|
|
|
$this->template->set_filenames(array('test' => 'includephp_relative.html'));
|
|
|
|
$this->assertEquals("Path is relative to board root.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
|
|
|
|
}
|
2011-05-19 12:18:16 -04:00
|
|
|
|
2012-07-07 22:43:52 +01:00
|
|
|
public function test_includephp_variables()
|
|
|
|
{
|
|
|
|
$this->setup_engine(array('tpl_allow_php' => true));
|
|
|
|
|
2013-06-25 16:51:50 -05:00
|
|
|
$this->run_template('includephp_variables.html', array('TEMPLATES' => 'templates'), array(), array(), "Path includes variables.\ntesting included php");
|
2012-07-07 22:43:52 +01:00
|
|
|
|
|
|
|
$this->template->set_filenames(array('test' => 'includephp_variables.html'));
|
|
|
|
$this->assertEquals("Path includes variables.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
|
|
|
|
}
|
|
|
|
|
2011-05-19 12:18:16 -04:00
|
|
|
public function test_includephp_absolute()
|
|
|
|
{
|
2013-07-02 12:59:23 -05:00
|
|
|
global $phpbb_root_path;
|
|
|
|
|
2015-03-12 00:25:00 +01:00
|
|
|
$filesystem = new \phpbb\filesystem\filesystem();
|
2013-06-25 16:51:50 -05:00
|
|
|
$path_to_php = str_replace('\\', '/', dirname(__FILE__)) . '/templates/_dummy_include.php.inc';
|
2015-03-12 00:25:00 +01:00
|
|
|
$this->assertTrue($filesystem->is_absolute_path($path_to_php));
|
2011-05-19 12:18:16 -04:00
|
|
|
$template_text = "Path is absolute.\n<!-- INCLUDEPHP $path_to_php -->";
|
|
|
|
|
2013-07-12 11:22:10 -05:00
|
|
|
$cache_dir = $phpbb_root_path . 'cache/';
|
2011-05-19 12:18:16 -04:00
|
|
|
$fp = fopen($cache_dir . 'includephp_absolute.html', 'w');
|
|
|
|
fputs($fp, $template_text);
|
|
|
|
fclose($fp);
|
|
|
|
|
2011-07-10 00:35:07 +02:00
|
|
|
$this->setup_engine(array('tpl_allow_php' => true));
|
2011-05-19 12:18:16 -04:00
|
|
|
|
2013-07-24 13:25:20 -05:00
|
|
|
$this->template->set_custom_style('tests', $cache_dir);
|
2011-05-19 12:18:16 -04:00
|
|
|
|
2013-06-25 16:51:50 -05:00
|
|
|
$this->run_template('includephp_absolute.html', array(), array(), array(), "Path is absolute.\ntesting included php");
|
2011-05-19 12:18:16 -04:00
|
|
|
|
|
|
|
$this->template->set_filenames(array('test' => 'includephp_absolute.html'));
|
|
|
|
$this->assertEquals("Path is absolute.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
|
|
|
|
}
|
2011-05-18 10:57:04 -04:00
|
|
|
}
|