mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 02:14:26 +02:00
Unit test improvements:
- do not try to test on PHP8.1 in Github CI workflow - Updated unit test to avoid risky and skipped tests - Changelog update - Removed .phpunit.result.cache from CVS and ignore it
This commit is contained in:
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
@@ -31,7 +31,6 @@ jobs:
|
|||||||
- "7.3"
|
- "7.3"
|
||||||
- "7.4"
|
- "7.4"
|
||||||
- "8.0"
|
- "8.0"
|
||||||
- "8.1"
|
|
||||||
|
|
||||||
compiler:
|
compiler:
|
||||||
- default
|
- default
|
||||||
@@ -41,10 +40,6 @@ jobs:
|
|||||||
php-version: "8.0"
|
php-version: "8.0"
|
||||||
compiler: jit
|
compiler: jit
|
||||||
|
|
||||||
- os: ubuntu-latest
|
|
||||||
php-version: "8.1"
|
|
||||||
compiler: jit
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,5 +9,6 @@ utilies/*.php
|
|||||||
|
|
||||||
# Dev
|
# Dev
|
||||||
phpunit*
|
phpunit*
|
||||||
|
.phpunit.result.cache
|
||||||
vendor/*
|
vendor/*
|
||||||
composer.lock
|
composer.lock
|
||||||
|
File diff suppressed because one or more lines are too long
10
CHANGELOG.md
10
CHANGELOG.md
@@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Updated unit tests to avoid skipped and risky test warnings
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- Dropped support for PHP7.0 and below, so Smarty now requires PHP >=7.1
|
||||||
|
- Dropped support for php asp tags in templates (removed from php since php7.0)
|
||||||
|
|
||||||
|
## [3.1.37] - 2021-01-07
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Dropped support for PHP versions lower than PHP7.1 (and disabled unit tests for 7.1)
|
- Dropped support for PHP versions lower than PHP7.1 (and disabled unit tests for 7.1)
|
||||||
- Changed error handlers and handling of undefined constants for php8-compatibility (set $errcontext argument optional) https://github.com/smarty-php/smarty/issues/605
|
- Changed error handlers and handling of undefined constants for php8-compatibility (set $errcontext argument optional) https://github.com/smarty-php/smarty/issues/605
|
||||||
@@ -13,7 +22,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Travis unit tests now run for all php versions >= 5.3, including php8
|
- Travis unit tests now run for all php versions >= 5.3, including php8
|
||||||
- Travis runs on Xenial where possible
|
- Travis runs on Xenial where possible
|
||||||
|
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- PHP5.3 compatibility fixes
|
- PHP5.3 compatibility fixes
|
||||||
|
|
||||||
|
@@ -144,9 +144,6 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
|||||||
return;
|
return;
|
||||||
} elseif (strpos($lex->value, '<?') === 0) {
|
} elseif (strpos($lex->value, '<?') === 0) {
|
||||||
$lex->phpType = 'php';
|
$lex->phpType = 'php';
|
||||||
} elseif (strpos($lex->value, '<%') === 0) {
|
|
||||||
$lex->phpType = 'asp';
|
|
||||||
$closeTag = '%>';
|
|
||||||
} elseif (strpos($lex->value, '%>') === 0) {
|
} elseif (strpos($lex->value, '%>') === 0) {
|
||||||
$lex->phpType = 'unmatched';
|
$lex->phpType = 'unmatched';
|
||||||
} elseif (strpos($lex->value, '?>') === 0) {
|
} elseif (strpos($lex->value, '?>') === 0) {
|
||||||
@@ -173,7 +170,7 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
|||||||
if ($lex->phpType === 'unmatched') {
|
if ($lex->phpType === 'unmatched') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (($lex->phpType === 'php' || $lex->phpType === 'asp')
|
if (($lex->phpType === 'php')
|
||||||
&&
|
&&
|
||||||
($lex->compiler->php_handling === Smarty::PHP_PASSTHRU ||
|
($lex->compiler->php_handling === Smarty::PHP_PASSTHRU ||
|
||||||
$lex->compiler->php_handling === Smarty::PHP_QUOTE)
|
$lex->compiler->php_handling === Smarty::PHP_QUOTE)
|
||||||
|
11
phpunit.xml
11
phpunit.xml
@@ -16,6 +16,14 @@
|
|||||||
timeoutForMediumTests="10"
|
timeoutForMediumTests="10"
|
||||||
timeoutForLargeTests="60"
|
timeoutForLargeTests="60"
|
||||||
verbose="false">
|
verbose="false">
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="foo">
|
||||||
|
<directory>./tests/UnitTests/</directory>
|
||||||
|
<exclude>./tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php</exclude>
|
||||||
|
<exclude>./tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php</exclude>
|
||||||
|
<exclude>./tests/UnitTests/CacheModify/ModifiedSince/HttpModifiedSinceTest.php</exclude>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
<filter>
|
<filter>
|
||||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||||
<directory suffix=".php">libs</directory>
|
<directory suffix=".php">libs</directory>
|
||||||
@@ -24,7 +32,4 @@
|
|||||||
<directory suffix=".php">demo/plugins</directory>
|
<directory suffix=".php">demo/plugins</directory>
|
||||||
</whitelist>
|
</whitelist>
|
||||||
</filter>
|
</filter>
|
||||||
<logging>
|
|
||||||
<log type="tap" target="tests/TestResults.tap"/>
|
|
||||||
</logging>
|
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
@@ -7,8 +7,6 @@
|
|||||||
* Smarty PHPUnit Config
|
* Smarty PHPUnit Config
|
||||||
*/
|
*/
|
||||||
define('individualFolders', true);
|
define('individualFolders', true);
|
||||||
define('MemCacheEnable', false);
|
|
||||||
define('ApcCacheEnable', false);
|
|
||||||
define('MysqlCacheEnable', false);
|
define('MysqlCacheEnable', false);
|
||||||
define('PdoCacheEnable', false);
|
define('PdoCacheEnable', false);
|
||||||
define('PdoGzipCacheEnable', false);
|
define('PdoGzipCacheEnable', false);
|
||||||
|
@@ -187,18 +187,12 @@ class FilterTest extends PHPUnit_Smarty
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* test registered pre filter closure
|
* test registered pre filter closure
|
||||||
* @requires PHP 5.3
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function testRegisteredPreFilterClosure()
|
public function testRegisteredPreFilterClosure()
|
||||||
{
|
{
|
||||||
if (version_compare(PHP_VERSION,'5.3','<'))
|
|
||||||
{
|
|
||||||
$this->markTestSkipped('does not run for PHP 5.2');
|
|
||||||
} else {
|
|
||||||
include 'FilterClosure.php';
|
include 'FilterClosure.php';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test registered pre filter class
|
* test registered pre filter class
|
||||||
|
@@ -18,7 +18,6 @@ class HttpModifiedSinceTest extends PHPUnit_Smarty
|
|||||||
|
|
||||||
public function setUp(): void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$this->markTestSkipped('modified since tests are disabled');
|
|
||||||
$this->setUpSmarty(dirname(__FILE__));
|
$this->setUpSmarty(dirname(__FILE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
* @package PHPunit
|
* @package PHPunit
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
if (ApcCacheEnable == true) {
|
|
||||||
include_once dirname(__FILE__) . '/../Memcache/CacheResourceCustomMemcacheTest.php';
|
include_once dirname(__FILE__) . '/../Memcache/CacheResourceCustomMemcacheTest.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,20 +16,15 @@ if (ApcCacheEnable == true) {
|
|||||||
*/
|
*/
|
||||||
class CacheResourceCustomApcTest extends CacheResourceCustomMemcacheTest
|
class CacheResourceCustomApcTest extends CacheResourceCustomMemcacheTest
|
||||||
{
|
{
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
if (ApcCacheEnable != true) {
|
|
||||||
$this->markTestSkipped('Apc tests are disabled');
|
|
||||||
} else {
|
|
||||||
if (!function_exists('apc_cache_info') || ini_get('apc.enable_cli')) {
|
if (!function_exists('apc_cache_info') || ini_get('apc.enable_cli')) {
|
||||||
$this->markTestSkipped('APC cache not available');
|
$this->markTestSkipped('APC cache not available');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$this->setUpSmarty(dirname(__FILE__));
|
$this->setUpSmarty(dirname(__FILE__));
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->smarty->setCachingType('apc');
|
$this->smarty->setCachingType('apc');
|
||||||
$this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/');
|
$this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
@@ -24,13 +24,9 @@ class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon
|
|||||||
*/
|
*/
|
||||||
public function setUp(): void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
if (MemCacheEnable != true) {
|
|
||||||
$this->markTestSkipped('Memcache tests are disabled');
|
|
||||||
} else {
|
|
||||||
if (!class_exists('Memcache')) {
|
if (!class_exists('Memcache')) {
|
||||||
$this->markTestSkipped('Memcache not available');
|
$this->markTestSkipped('Memcache not available');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$this->setUpSmarty(dirname(__FILE__));
|
$this->setUpSmarty(dirname(__FILE__));
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->smarty->setCachingType('memcachetest');
|
$this->smarty->setCachingType('memcachetest');
|
||||||
|
@@ -108,6 +108,9 @@ class FileResourceTest extends PHPUnit_Smarty
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @doesNotPerformAssertions
|
||||||
|
*/
|
||||||
public function testGetCompiledTimestampPrepare()
|
public function testGetCompiledTimestampPrepare()
|
||||||
{
|
{
|
||||||
$tpl = $this->smarty->createTemplate('helloworld.tpl');
|
$tpl = $this->smarty->createTemplate('helloworld.tpl');
|
||||||
@@ -140,6 +143,9 @@ class FileResourceTest extends PHPUnit_Smarty
|
|||||||
$this->assertTrue($tpl->mustCompile());
|
$this->assertTrue($tpl->mustCompile());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @doesNotPerformAssertions
|
||||||
|
*/
|
||||||
public function testMustCompileTouchedSourcePrepare()
|
public function testMustCompileTouchedSourcePrepare()
|
||||||
{
|
{
|
||||||
// touch to prepare next test
|
// touch to prepare next test
|
||||||
|
@@ -161,7 +161,7 @@ class PhpResourceTest extends PHPUnit_Smarty
|
|||||||
*
|
*
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
*
|
* @doesNotPerformAssertions
|
||||||
*/
|
*/
|
||||||
public function testIsCachedTouchedSourcePrepare()
|
public function testIsCachedTouchedSourcePrepare()
|
||||||
{
|
{
|
||||||
@@ -212,6 +212,7 @@ class PhpResourceTest extends PHPUnit_Smarty
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* test $smarty->is_cached
|
* test $smarty->is_cached
|
||||||
|
* @doesNotPerformAssertions
|
||||||
*/
|
*/
|
||||||
public function testSmartyIsCachedPrepare()
|
public function testSmartyIsCachedPrepare()
|
||||||
{
|
{
|
||||||
|
@@ -199,16 +199,6 @@ class SecurityTest extends PHPUnit_Smarty
|
|||||||
$this->assertEquals('<?php echo "hello world"; ?>', $this->smarty->fetch('string:<?php echo "hello world"; ?>'));
|
$this->assertEquals('<?php echo "hello world"; ?>', $this->smarty->fetch('string:<?php echo "hello world"; ?>'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSmartyPhpQuoteAsp()
|
|
||||||
{
|
|
||||||
// NOTE: asp_tags cannot be changed by ini_set()
|
|
||||||
if (!ini_get('asp_tags')) {
|
|
||||||
$this->markTestSkipped('asp tags disabled in php.ini');
|
|
||||||
}
|
|
||||||
$this->smarty->security_policy->php_handling = Smarty::PHP_QUOTE;
|
|
||||||
$this->assertEquals('<% echo "hello world"; %>', $this->smarty->fetch('string:<% echo "hello world"; %>'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test Smarty::PHP_REMOVE
|
* test Smarty::PHP_REMOVE
|
||||||
*/
|
*/
|
||||||
@@ -218,16 +208,6 @@ class SecurityTest extends PHPUnit_Smarty
|
|||||||
$this->assertEquals('', $this->smarty->fetch('string:<?php echo "hello world"; ?>'));
|
$this->assertEquals('', $this->smarty->fetch('string:<?php echo "hello world"; ?>'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSmartyPhpRemoveAsp()
|
|
||||||
{
|
|
||||||
// NOTE: asp_tags cannot be changed by ini_set()
|
|
||||||
if (!ini_get('asp_tags')) {
|
|
||||||
$this->markTestSkipped('asp tags disabled in php.ini');
|
|
||||||
}
|
|
||||||
$this->smarty->security_policy->php_handling = Smarty::PHP_REMOVE;
|
|
||||||
$this->assertEquals('', $this->smarty->fetch('string:<% echo "hello world"; %>'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test Smarty::PHP_ALLOW
|
* test Smarty::PHP_ALLOW
|
||||||
*/
|
*/
|
||||||
@@ -237,16 +217,6 @@ class SecurityTest extends PHPUnit_Smarty
|
|||||||
$this->assertEquals('hello world', $this->smartyBC->fetch('string:<?php echo "hello world"; ?>'));
|
$this->assertEquals('hello world', $this->smartyBC->fetch('string:<?php echo "hello world"; ?>'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSmartyPhpAllowAsp()
|
|
||||||
{
|
|
||||||
// NOTE: asp_tags cannot be changed by ini_set()
|
|
||||||
if (!ini_get('asp_tags')) {
|
|
||||||
$this->markTestSkipped('asp tags disabled in php.ini');
|
|
||||||
}
|
|
||||||
$this->smartyBC->security_policy->php_handling = Smarty::PHP_ALLOW;
|
|
||||||
$this->assertEquals('hello world', $this->smartyBC->fetch('string:<% echo "hello world"; %>'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test standard directory
|
* test standard directory
|
||||||
*/
|
*/
|
||||||
|
@@ -131,7 +131,6 @@ class CompilePhpTest extends PHPUnit_Smarty
|
|||||||
public function data()
|
public function data()
|
||||||
{
|
{
|
||||||
$shortTag = ini_get('short_open_tag') == 1;
|
$shortTag = ini_get('short_open_tag') == 1;
|
||||||
$aspTag = ini_get('asp_tags') == 1;
|
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
/*
|
/*
|
||||||
@@ -159,13 +158,6 @@ class CompilePhpTest extends PHPUnit_Smarty
|
|||||||
echo \'<? \';
|
echo \'<? \';
|
||||||
echo \'?> \';
|
echo \'?> \';
|
||||||
?><--', 'PHP_ALLOW, \'php2.tpl\''),
|
?><--', 'PHP_ALLOW, \'php2.tpl\''),
|
||||||
array(Smarty::PHP_REMOVE, 'asp.tpl', '--><--', 'PHP_REMOVE, \'asp.tpl\''),
|
|
||||||
array(Smarty::PHP_PASSTHRU, 'asp.tpl', '', 'PHP_PASSTHRU, \'asp.tpl\''),
|
|
||||||
array(Smarty::PHP_QUOTE, 'asp.tpl', '', 'PHP_QUOTE, \'asp.tpl\''),
|
|
||||||
array(Smarty::PHP_ALLOW, 'asp.tpl', $aspTag ? '-->hello world <% %> <--' : '--><% echo \'hello world \';
|
|
||||||
echo \'<% \';
|
|
||||||
echo \'%> \';
|
|
||||||
%><--', 'PHP_ALLOW, \'asp.tpl\''),
|
|
||||||
array(Smarty::PHP_REMOVE, 'script.tpl', '<br><br>', 'PHP_REMOVE, \'script.tpl\''),
|
array(Smarty::PHP_REMOVE, 'script.tpl', '<br><br>', 'PHP_REMOVE, \'script.tpl\''),
|
||||||
array(Smarty::PHP_PASSTHRU, 'script.tpl', '', 'PHP_PASSTHRU, \'script.tpl\''),
|
array(Smarty::PHP_PASSTHRU, 'script.tpl', '', 'PHP_PASSTHRU, \'script.tpl\''),
|
||||||
array(Smarty::PHP_QUOTE, 'script.tpl', '', 'PHP_QUOTE, \'script.tpl\''),
|
array(Smarty::PHP_QUOTE, 'script.tpl', '', 'PHP_QUOTE, \'script.tpl\''),
|
||||||
|
@@ -1,4 +0,0 @@
|
|||||||
--><% echo 'hello world ';
|
|
||||||
echo '<% ';
|
|
||||||
echo '%> ';
|
|
||||||
%><--
|
|
@@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty PHPunit tests of modifier
|
|
||||||
*
|
|
||||||
* @package PHPunit
|
|
||||||
* @author Rodney Rehm
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* class for modifier tests
|
|
||||||
*
|
|
||||||
* @runTestsInSeparateProcess
|
|
||||||
* @preserveGlobalState disabled
|
|
||||||
* @backupStaticAttributes enabled
|
|
||||||
*/
|
|
||||||
class PluginFunctionHtmlImageTest extends PHPUnit_Smarty
|
|
||||||
{
|
|
||||||
public function setUp(): void
|
|
||||||
{
|
|
||||||
$this->setUpSmarty(dirname(__FILE__));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFoo()
|
|
||||||
{
|
|
||||||
// TODO: UnitTests for {html_image}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -56,10 +56,6 @@ class PhpFunctionTest extends PHPUnit_Smarty
|
|||||||
*/
|
*/
|
||||||
public function testEmpty2()
|
public function testEmpty2()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.5', '<')) {
|
|
||||||
$this->markTestSkipped('runs only on PHP >= 5.5');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->smarty->disableSecurity();
|
$this->smarty->disableSecurity();
|
||||||
$this->smarty->assign('var', array(null,
|
$this->smarty->assign('var', array(null,
|
||||||
false,
|
false,
|
||||||
@@ -81,9 +77,6 @@ class PhpFunctionTest extends PHPUnit_Smarty
|
|||||||
*/
|
*/
|
||||||
public function testEmpty3()
|
public function testEmpty3()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.5', '<')) {
|
|
||||||
$this->markTestSkipped('runs only on PHP >= 5.5');
|
|
||||||
}
|
|
||||||
$this->smarty->disableSecurity();
|
$this->smarty->disableSecurity();
|
||||||
$this->smarty->assign('var', array(true,
|
$this->smarty->assign('var', array(true,
|
||||||
(int) 1,
|
(int) 1,
|
||||||
@@ -103,10 +96,6 @@ class PhpFunctionTest extends PHPUnit_Smarty
|
|||||||
*/
|
*/
|
||||||
public function testEmpty4()
|
public function testEmpty4()
|
||||||
{
|
{
|
||||||
if (version_compare(phpversion(), '5.5', '<')) {
|
|
||||||
$this->markTestSkipped('runs only on PHP >= 5.5');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->smarty->disableSecurity();
|
$this->smarty->disableSecurity();
|
||||||
$this->smarty->assign('var', new TestIsset());
|
$this->smarty->assign('var', new TestIsset());
|
||||||
$expected = ' true , false , false , true , true , true , false ';
|
$expected = ' true , false , false , true , true , true , false ';
|
||||||
|
@@ -291,6 +291,9 @@ class ScopeTest extends PHPUnit_Smarty
|
|||||||
'no smarty', $i ++,),);
|
'no smarty', $i ++,),);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @doesNotPerformAssertions
|
||||||
|
*/
|
||||||
public function testFunctionScope()
|
public function testFunctionScope()
|
||||||
{
|
{
|
||||||
$this->smarty->assign('scope', 'none');
|
$this->smarty->assign('scope', 'none');
|
||||||
|
Reference in New Issue
Block a user