mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 18:04: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.4"
|
||||
- "8.0"
|
||||
- "8.1"
|
||||
|
||||
compiler:
|
||||
- default
|
||||
@@ -41,10 +40,6 @@ jobs:
|
||||
php-version: "8.0"
|
||||
compiler: jit
|
||||
|
||||
- os: ubuntu-latest
|
||||
php-version: "8.1"
|
||||
compiler: jit
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,5 +9,6 @@ utilies/*.php
|
||||
|
||||
# Dev
|
||||
phpunit*
|
||||
.phpunit.result.cache
|
||||
vendor/*
|
||||
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]
|
||||
|
||||
### 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
|
||||
- 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
|
||||
@@ -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 runs on Xenial where possible
|
||||
|
||||
|
||||
### Fixed
|
||||
- PHP5.3 compatibility fixes
|
||||
|
||||
|
@@ -144,9 +144,6 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||
return;
|
||||
} elseif (strpos($lex->value, '<?') === 0) {
|
||||
$lex->phpType = 'php';
|
||||
} elseif (strpos($lex->value, '<%') === 0) {
|
||||
$lex->phpType = 'asp';
|
||||
$closeTag = '%>';
|
||||
} elseif (strpos($lex->value, '%>') === 0) {
|
||||
$lex->phpType = 'unmatched';
|
||||
} elseif (strpos($lex->value, '?>') === 0) {
|
||||
@@ -173,7 +170,7 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||
if ($lex->phpType === 'unmatched') {
|
||||
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_QUOTE)
|
||||
|
11
phpunit.xml
11
phpunit.xml
@@ -16,6 +16,14 @@
|
||||
timeoutForMediumTests="10"
|
||||
timeoutForLargeTests="60"
|
||||
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>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">libs</directory>
|
||||
@@ -24,7 +32,4 @@
|
||||
<directory suffix=".php">demo/plugins</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<logging>
|
||||
<log type="tap" target="tests/TestResults.tap"/>
|
||||
</logging>
|
||||
</phpunit>
|
||||
|
@@ -7,8 +7,6 @@
|
||||
* Smarty PHPUnit Config
|
||||
*/
|
||||
define('individualFolders', true);
|
||||
define('MemCacheEnable', false);
|
||||
define('ApcCacheEnable', false);
|
||||
define('MysqlCacheEnable', false);
|
||||
define('PdoCacheEnable', false);
|
||||
define('PdoGzipCacheEnable', false);
|
||||
|
@@ -187,17 +187,11 @@ class FilterTest extends PHPUnit_Smarty
|
||||
|
||||
/**
|
||||
* test registered pre filter closure
|
||||
* @requires PHP 5.3
|
||||
*/
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -18,7 +18,6 @@ class HttpModifiedSinceTest extends PHPUnit_Smarty
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->markTestSkipped('modified since tests are disabled');
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
}
|
||||
|
||||
|
@@ -5,32 +5,26 @@
|
||||
* @package PHPunit
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
if (ApcCacheEnable == true) {
|
||||
include_once dirname(__FILE__) . '/../Memcache/CacheResourceCustomMemcacheTest.php';
|
||||
include_once dirname(__FILE__) . '/../Memcache/CacheResourceCustomMemcacheTest.php';
|
||||
|
||||
/**
|
||||
* class for cache resource file tests
|
||||
*
|
||||
* @runTestsInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @backupStaticAttributes enabled
|
||||
*/
|
||||
class CacheResourceCustomApcTest extends CacheResourceCustomMemcacheTest
|
||||
/**
|
||||
* class for cache resource file tests
|
||||
*
|
||||
* @runTestsInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @backupStaticAttributes enabled
|
||||
*/
|
||||
class CacheResourceCustomApcTest extends CacheResourceCustomMemcacheTest
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (ApcCacheEnable != true) {
|
||||
$this->markTestSkipped('Apc tests are disabled');
|
||||
} else {
|
||||
if (!function_exists('apc_cache_info') || ini_get('apc.enable_cli')) {
|
||||
$this->markTestSkipped('APC cache not available');
|
||||
}
|
||||
}
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
parent::setUp();
|
||||
$this->smarty->setCachingType('apc');
|
||||
$this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/');
|
||||
if (!function_exists('apc_cache_info') || ini_get('apc.enable_cli')) {
|
||||
$this->markTestSkipped('APC cache not available');
|
||||
}
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
parent::setUp();
|
||||
$this->smarty->setCachingType('apc');
|
||||
$this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/');
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -24,12 +24,8 @@ class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
if (MemCacheEnable != true) {
|
||||
$this->markTestSkipped('Memcache tests are disabled');
|
||||
} else {
|
||||
if (!class_exists('Memcache')) {
|
||||
$this->markTestSkipped('Memcache not available');
|
||||
}
|
||||
if (!class_exists('Memcache')) {
|
||||
$this->markTestSkipped('Memcache not available');
|
||||
}
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
parent::setUp();
|
||||
|
@@ -108,6 +108,9 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @doesNotPerformAssertions
|
||||
*/
|
||||
public function testGetCompiledTimestampPrepare()
|
||||
{
|
||||
$tpl = $this->smarty->createTemplate('helloworld.tpl');
|
||||
@@ -140,6 +143,9 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$this->assertTrue($tpl->mustCompile());
|
||||
}
|
||||
|
||||
/**
|
||||
* @doesNotPerformAssertions
|
||||
*/
|
||||
public function testMustCompileTouchedSourcePrepare()
|
||||
{
|
||||
// touch to prepare next test
|
||||
|
@@ -161,7 +161,7 @@ class PhpResourceTest extends PHPUnit_Smarty
|
||||
*
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*
|
||||
* @doesNotPerformAssertions
|
||||
*/
|
||||
public function testIsCachedTouchedSourcePrepare()
|
||||
{
|
||||
@@ -212,6 +212,7 @@ class PhpResourceTest extends PHPUnit_Smarty
|
||||
|
||||
/**
|
||||
* test $smarty->is_cached
|
||||
* @doesNotPerformAssertions
|
||||
*/
|
||||
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"; ?>'));
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
@@ -218,16 +208,6 @@ class SecurityTest extends PHPUnit_Smarty
|
||||
$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
|
||||
*/
|
||||
@@ -237,16 +217,6 @@ class SecurityTest extends PHPUnit_Smarty
|
||||
$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
|
||||
*/
|
||||
|
@@ -131,7 +131,6 @@ class CompilePhpTest extends PHPUnit_Smarty
|
||||
public function data()
|
||||
{
|
||||
$shortTag = ini_get('short_open_tag') == 1;
|
||||
$aspTag = ini_get('asp_tags') == 1;
|
||||
|
||||
$data = array(
|
||||
/*
|
||||
@@ -159,13 +158,6 @@ class CompilePhpTest extends PHPUnit_Smarty
|
||||
echo \'<? \';
|
||||
echo \'?> \';
|
||||
?><--', '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_PASSTHRU, 'script.tpl', '', 'PHP_PASSTHRU, \'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()
|
||||
{
|
||||
if (version_compare(phpversion(), '5.5', '<')) {
|
||||
$this->markTestSkipped('runs only on PHP >= 5.5');
|
||||
}
|
||||
|
||||
$this->smarty->disableSecurity();
|
||||
$this->smarty->assign('var', array(null,
|
||||
false,
|
||||
@@ -81,9 +77,6 @@ class PhpFunctionTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function testEmpty3()
|
||||
{
|
||||
if (version_compare(phpversion(), '5.5', '<')) {
|
||||
$this->markTestSkipped('runs only on PHP >= 5.5');
|
||||
}
|
||||
$this->smarty->disableSecurity();
|
||||
$this->smarty->assign('var', array(true,
|
||||
(int) 1,
|
||||
@@ -103,10 +96,6 @@ class PhpFunctionTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function testEmpty4()
|
||||
{
|
||||
if (version_compare(phpversion(), '5.5', '<')) {
|
||||
$this->markTestSkipped('runs only on PHP >= 5.5');
|
||||
}
|
||||
|
||||
$this->smarty->disableSecurity();
|
||||
$this->smarty->assign('var', new TestIsset());
|
||||
$expected = ' true , false , false , true , true , true , false ';
|
||||
|
@@ -291,6 +291,9 @@ class ScopeTest extends PHPUnit_Smarty
|
||||
'no smarty', $i ++,),);
|
||||
}
|
||||
|
||||
/**
|
||||
* @doesNotPerformAssertions
|
||||
*/
|
||||
public function testFunctionScope()
|
||||
{
|
||||
$this->smarty->assign('scope', 'none');
|
||||
|
Reference in New Issue
Block a user