Dropped suppport for php<7.2 to enable unit testing for php8, using phpunit8. Updated unit tests for compatability with phpunit8.

This commit is contained in:
Simon Wisselink
2021-01-07 00:19:13 +01:00
parent 277a11a212
commit e71481a2ce
152 changed files with 447 additions and 506 deletions

View File

@@ -7,15 +7,6 @@ install:
jobs: jobs:
include: include:
- php: 5.3 # Composer and PHPUnit require PHP 5.3.2+ to run, so we cannot test below 5.3
dist: precise # PHP 5.3 is supported only on Precise.
- php: 5.4
dist: trusty # PHP 5.4 is supported only on Trusty.
- php: 5.5
dist: trusty # PHP 5.5 is supported only on Trusty.
- php: 5.6
- php: 7.0
- php: 7.1
- php: 7.2 - php: 7.2
- php: 7.3 - php: 7.3
- php: 7.4 - php: 7.4

View File

@@ -7,11 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Changed ### 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 - Changed error handlers and handling of undefined constants for php8-compatibility (set $errcontext argument optional) https://github.com/smarty-php/smarty/issues/605
- Changed expected error levels in unit tests for php8-compatibility - Changed expected error levels in unit tests for php8-compatibility
- 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

View File

@@ -27,7 +27,7 @@
"forum": "http://www.smarty.net/forums/" "forum": "http://www.smarty.net/forums/"
}, },
"require": { "require": {
"php": ">=5.2" "php": ">=7.1"
}, },
"autoload": { "autoload": {
"classmap": [ "classmap": [
@@ -40,7 +40,7 @@
} }
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^9.5 || ^8.5 || ^7.5 || ^6.5 || ^5.7 || ^4.8", "phpunit/phpunit": "^8.5",
"smarty/smarty-lexer": "^3.1" "smarty/smarty-lexer": "^3.1"
} }
} }

View File

@@ -6,7 +6,6 @@
backupGlobals="false" backupGlobals="false"
backupStaticAttributes="true" backupStaticAttributes="true"
forceCoversAnnotation="false" forceCoversAnnotation="false"
mapTestClassNameToCoveredClassName="false"
processIsolation="false" processIsolation="false"
stopOnError="false" stopOnError="false"
stopOnFailure="false" stopOnFailure="false"
@@ -17,18 +16,7 @@
timeoutForMediumTests="10" timeoutForMediumTests="10"
timeoutForLargeTests="60" timeoutForLargeTests="60"
verbose="false"> verbose="false">
<filter>
<filter>
<testsuites>
<testsuite name="Smarty Test Suite">
<directory>tests/UnitTests</directory>
</testsuite>
</testsuites>
<blacklist>
<directory suffix=".php">tests</directory>
<directory suffix=".php">tests/cache</directory>
<directory suffix=".php">tests/templates_c</directory>
</blacklist>
<whitelist processUncoveredFilesFromWhitelist="true"> <whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">libs</directory> <directory suffix=".php">libs</directory>
<directory suffix=".php">libs/plugins</directory> <directory suffix=".php">libs/plugins</directory>
@@ -39,5 +27,4 @@
<logging> <logging>
<log type="tap" target="tests/TestResults.tap"/> <log type="tap" target="tests/TestResults.tap"/>
</logging> </logging>
</phpunit> </phpunit>

View File

@@ -86,7 +86,7 @@ class PHPUnit_Smarty extends PHPUnit_Framework_TestCase
* This method is called before the first test of this test class is run. * This method is called before the first test of this test class is run.
* *
*/ */
public static function setUpBeforeClass() public static function setUpBeforeClass(): void
{ {
error_reporting(E_ALL & ~E_STRICT); error_reporting(E_ALL & ~E_STRICT);
self::$init = true; self::$init = true;
@@ -97,7 +97,7 @@ class PHPUnit_Smarty extends PHPUnit_Framework_TestCase
* This method is called after the last test of this test class is run. * This method is called after the last test of this test class is run.
* *
*/ */
public static function tearDownAfterClass() public static function tearDownAfterClass(): void
{ {
//self::$pdo = null; //self::$pdo = null;
self::$testNumber = 0; self::$testNumber = 0;
@@ -676,7 +676,7 @@ KEY `name` (`name`)
* This method is called after a test is executed. * This method is called after a test is executed.
* *
*/ */
protected function tearDown() protected function tearDown(): void
{ {
if (class_exists('Smarty_Internal_TemplateCompilerBase') && if (class_exists('Smarty_Internal_TemplateCompilerBase') &&
isset(Smarty_Internal_TemplateCompilerBase::$_tag_objects) isset(Smarty_Internal_TemplateCompilerBase::$_tag_objects)

View File

@@ -15,7 +15,7 @@ class PathNormalizationTest extends PHPUnit_Smarty
/* /*
* Setup test fixture * Setup test fixture
*/ */
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@ class PluginNormalizationTest extends PHPUnit_Smarty
/* /*
* Setup test fixture * Setup test fixture
*/ */
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@ class TemplateNormalizationTest extends PHPUnit_Smarty
/* /*
* Setup test fixture * Setup test fixture
*/ */
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
/* /*
* Setup test fixture * Setup test fixture
*/ */
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -13,7 +13,7 @@ class UndefinedTemplateVarTest extends PHPUnit_Smarty
/* /*
* Setup test fixture * Setup test fixture
*/ */
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL | E_STRICT);

View File

@@ -15,7 +15,7 @@ class AutoEscapeTest extends PHPUnit_Smarty
/* /*
* Setup test fixture * Setup test fixture
*/ */
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->setEscapeHtml(true); $this->smarty->setEscapeHtml(true);

View File

@@ -17,7 +17,7 @@ class FilterTest extends PHPUnit_Smarty
{ {
public $loadSmartyBC = true; public $loadSmartyBC = true;
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class LoadFilterTest extends PHPUnit_Smarty class LoadFilterTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class RegisterFilterTest extends PHPUnit_Smarty class RegisterFilterTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class GetterSetterTest extends PHPUnit_Smarty class GetterSetterTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class DefaultPluginHandlerTest extends PHPUnit_Smarty class DefaultPluginHandlerTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->setForceCompile(true); $this->smarty->setForceCompile(true);

View File

@@ -11,7 +11,7 @@
*/ */
class IncludePathTest extends PHPUnit_Smarty class IncludePathTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->use_include_path = true; $this->smarty->use_include_path = true;
@@ -26,7 +26,7 @@ class IncludePathTest extends PHPUnit_Smarty
* This method is called after a test is executed. * This method is called after a test is executed.
* *
*/ */
protected function tearDown() protected function tearDown(): void
{ {
ini_restore('include_path'); ini_restore('include_path');
$this->smarty->disableSecurity(); $this->smarty->disableSecurity();
@@ -38,14 +38,14 @@ class IncludePathTest extends PHPUnit_Smarty
} }
public function testInclude1() public function testInclude1()
{ {
$this->assertContains('plugin1', $this->smarty->fetch('test_include_path1.tpl')); $this->assertStringContainsString('plugin1', $this->smarty->fetch('test_include_path1.tpl'));
} }
public function testInclude2() public function testInclude2()
{ {
$this->assertContains('plugin2', $this->smarty->fetch('test_include_path2.tpl')); $this->assertStringContainsString('plugin2', $this->smarty->fetch('test_include_path2.tpl'));
} }
public function testInclude3() public function testInclude3()
{ {
$this->assertContains('plugin3', $this->smarty->fetch('test_include_path3.tpl')); $this->assertStringContainsString('plugin3', $this->smarty->fetch('test_include_path3.tpl'));
} }
} }

View File

@@ -15,7 +15,7 @@
*/ */
class LoadPluginTest extends PHPUnit_Smarty class LoadPluginTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -17,7 +17,7 @@ class MuteExpectedErrorsTest extends PHPUnit_Smarty
{ {
protected $_errors = array(); protected $_errors = array();
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class PluginChainedLoadTest extends PHPUnit_Smarty class PluginChainedLoadTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }
@@ -28,6 +28,6 @@ class PluginChainedLoadTest extends PHPUnit_Smarty
public function testPluginChainedLoad() public function testPluginChainedLoad()
{ {
$this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/");
$this->assertContains('from chain3', $this->smarty->fetch('test_plugin_chained_load.tpl')); $this->assertStringContainsString('from chain3', $this->smarty->fetch('test_plugin_chained_load.tpl'));
} }
} }

View File

@@ -11,7 +11,7 @@
*/ */
class SharedFunctionsTest extends PHPUnit_Smarty class SharedFunctionsTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -17,7 +17,7 @@ class SmartyBcTest extends PHPUnit_Smarty
{ {
public $loadSmartyBC = true; public $loadSmartyBC = true;
public $loadSmarty = false; public $loadSmarty = false;
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -16,7 +16,7 @@
class HttpModifiedSinceTest extends PHPUnit_Smarty class HttpModifiedSinceTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->markTestSkipped('modified since tests are disabled'); $this->markTestSkipped('modified since tests are disabled');
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));

View File

@@ -18,7 +18,7 @@ include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php';
class CacheResourceFileTest extends CacheResourceTestCommon class CacheResourceFileTest extends CacheResourceTestCommon
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
parent::setUp(); parent::setUp();

View File

@@ -22,7 +22,7 @@ class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon
* This method is called before a test is executed. * This method is called before a test is executed.
* *
*/ */
public function setUp() public function setUp(): void
{ {
if (MemCacheEnable != true) { if (MemCacheEnable != true) {
$this->markTestSkipped('Memcache tests are disabled'); $this->markTestSkipped('Memcache tests are disabled');

View File

@@ -15,7 +15,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
{ {
public static $touchResource = null; public static $touchResource = null;
public function setUp() public function setUp(): void
{ {
$this->smarty->setTemplateDir(dirname(__FILE__) . '/templates'); $this->smarty->setTemplateDir(dirname(__FILE__) . '/templates');
$this->smarty->addPluginsDir(dirname(__FILE__) . '/PHPunitplugins'); $this->smarty->addPluginsDir(dirname(__FILE__) . '/PHPunitplugins');
@@ -551,7 +551,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
} }
$tpl = $this->smarty->createTemplate('templatedir.tpl', $this->smarty); $tpl = $this->smarty->createTemplate('templatedir.tpl', $this->smarty);
$this->assertEquals($iscached, $tpl->isCached()); $this->assertEquals($iscached, $tpl->isCached());
$this->assertContains($result, $tpl->fetch()); $this->assertStringContainsString($result, $tpl->fetch());
} }
public function dataDir(){ public function dataDir(){

View File

@@ -15,7 +15,7 @@
*/ */
class CompileCompilerPluginTest extends PHPUnit_Smarty class CompileCompilerPluginTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -14,7 +14,7 @@
*/ */
class AutoliteralTest extends PHPUnit_Smarty class AutoliteralTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->addPluginsDir("../../__shared/PHPunitplugins/"); $this->smarty->addPluginsDir("../../__shared/PHPunitplugins/");

View File

@@ -15,7 +15,7 @@
*/ */
class DelimiterTest extends PHPUnit_Smarty class DelimiterTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class UserliteralTest extends PHPUnit_Smarty class UserliteralTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
if (!property_exists('Smarty', 'literals')) { if (!property_exists('Smarty', 'literals')) {
$this->markTestSkipped('user literal support'); $this->markTestSkipped('user literal support');

View File

@@ -21,33 +21,30 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty
* This method is called before a test is executed. * This method is called before a test is executed.
* *
*/ */
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->setForceCompile(true); $this->smarty->setForceCompile(true);
} }
/** /**
* @expectedException SmartyException
* @expectedExceptionMessage Unable to load config 'file:foo.conf'
*
* test unknown config file * test unknown config file
*/ */
public function testUnknownConfigFile() public function testUnknownConfigFile()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('Unable to load config \'file:foo.conf\'');
$this->smarty->configLoad('foo.conf'); $this->smarty->configLoad('foo.conf');
} }
/** /**
* @expectedException SmartyException
* @expectedExceptionMessage Default config handler
* @expectedExceptionMessage not callable
*
* test register unknown default config handler * test register unknown default config handler
*
*/ */
public function testRegisterUnknownDefaultConfigHandler() public function testRegisterUnknownDefaultConfigHandler()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('Default config handler');
$this->expectExceptionMessage('not callable');
$this->smarty->registerDefaultConfigHandler('foo'); $this->smarty->registerDefaultConfigHandler('foo');
} }
@@ -77,42 +74,32 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty
$this->assertEquals("123.4", $this->smarty->fetch('number.tpl')); $this->assertEquals("123.4", $this->smarty->fetch('number.tpl'));
} }
/**
* @expectedException SmartyException
* @expectedExceptionMessage Unable to load config default file 'no.conf' for 'file:fo.conf'
*
*
*/
public function testDefaultConfigHandlerReplacementByConfigFileFail() public function testDefaultConfigHandlerReplacementByConfigFileFail()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage("Unable to load config default file 'no.conf' for 'file:fo.conf'");
$this->smarty->registerDefaultConfigHandler('configHandlerFile'); $this->smarty->registerDefaultConfigHandler('configHandlerFile');
$this->smarty->configLoad('fo.conf'); $this->smarty->configLoad('fo.conf');
$this->assertEquals("123.4", $this->smarty->fetch('number.tpl')); $this->assertEquals("123.4", $this->smarty->fetch('number.tpl'));
} }
/** /**
* @expectedException SmartyException
* @expectedExceptionMessage Unable to load config 'file:foo.conf'
*
*
* test default config handler replacement (return false) * test default config handler replacement (return false)
*
*/ */
public function testDefaultConfigHandlerReplacementReturningFalse() public function testDefaultConfigHandlerReplacementReturningFalse()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('Unable to load config \'file:foo.conf\'');
$this->smarty->configLoad('foo.conf'); $this->smarty->configLoad('foo.conf');
} }
/** /**
* @expectedException SmartyException
* @expectedExceptionMessage No config default content for 'file:bla.conf'
*
*
* test default config handler replacement (return false) * test default config handler replacement (return false)
*
*/ */
public function testDefaultConfigHandlerReplacementReturningFalse1() public function testDefaultConfigHandlerReplacementReturningFalse1()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('No config default content for \'file:bla.conf\'');
$this->smarty->registerDefaultConfigHandler('configHandlerData'); $this->smarty->registerDefaultConfigHandler('configHandlerData');
$this->smarty->configLoad('bla.conf'); $this->smarty->configLoad('bla.conf');
} }

View File

@@ -20,7 +20,7 @@ class ConfigVarTest extends PHPUnit_Smarty
* This method is called before a test is executed. * This method is called before a test is executed.
* *
*/ */
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -17,7 +17,7 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty
{ {
public $_resource = null; public $_resource = null;
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
require_once dirname(__FILE__) . '/PHPunitplugins/resource.ambiguous.php'; require_once dirname(__FILE__) . '/PHPunitplugins/resource.ambiguous.php';

View File

@@ -15,7 +15,7 @@
*/ */
class ResourceExtendsAllPluginTest extends PHPUnit_Smarty class ResourceExtendsAllPluginTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -138,13 +138,13 @@ if (MysqlResourceEnable == true) {
/** /**
* test unknown template * test unknown template
* *
* @expectedException SmartyException
* @expectedExceptionMessage Unable to load template 'mysqlstest:foo.tpl'
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
* *
*/ */
public function testUnknownTemplate() { public function testUnknownTemplate() {
$this->expectException('SmartyException');
$this->expectExceptionMessage('Unable to load template \'mysqlstest:foo.tpl\'');
$this->assertEquals('foo', $this->smarty->fetch('mysqlstest:foo.tpl')); $this->assertEquals('foo', $this->smarty->fetch('mysqlstest:foo.tpl'));
} }
} }

View File

@@ -15,7 +15,7 @@
*/ */
class DefaultTemplateHandlerTest extends PHPUnit_Smarty class DefaultTemplateHandlerTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->setForceCompile(true); $this->smarty->setForceCompile(true);
@@ -36,7 +36,7 @@ class DefaultTemplateHandlerTest extends PHPUnit_Smarty
$this->smarty->fetch('foo.tpl'); $this->smarty->fetch('foo.tpl');
} }
catch (Exception $e) { catch (Exception $e) {
$this->assertContains('Unable to load template', $e->getMessage()); $this->assertStringContainsString('Unable to load template', $e->getMessage());
return; return;
} }
@@ -52,8 +52,8 @@ class DefaultTemplateHandlerTest extends PHPUnit_Smarty
$this->smarty->registerDefaultTemplateHandler('foo'); $this->smarty->registerDefaultTemplateHandler('foo');
} }
catch (Exception $e) { catch (Exception $e) {
$this->assertContains("Default template handler", $e->getMessage()); $this->assertStringContainsString("Default template handler", $e->getMessage());
$this->assertContains("not callable", $e->getMessage()); $this->assertStringContainsString("not callable", $e->getMessage());
return; return;
} }
@@ -85,7 +85,7 @@ class DefaultTemplateHandlerTest extends PHPUnit_Smarty
$this->smarty->fetch('foo.tpl'); $this->smarty->fetch('foo.tpl');
} }
catch (Exception $e) { catch (Exception $e) {
$this->assertContains('Default handler: No template default content for \'file:foo.tpl\'', $e->getMessage()); $this->assertStringContainsString('Default handler: No template default content for \'file:foo.tpl\'', $e->getMessage());
return; return;
} }

View File

@@ -15,7 +15,7 @@
*/ */
class EvalResourceTest extends PHPUnit_Smarty class EvalResourceTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class ExtendsResourceTest extends PHPUnit_Smarty class ExtendsResourceTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->enableSecurity(); $this->smarty->enableSecurity();
@@ -48,8 +48,8 @@ class ExtendsResourceTest extends PHPUnit_Smarty
$this->smarty->compile_id = 1; $this->smarty->compile_id = 1;
} }
$result = $this->smarty->fetch('extends:003_parent.tpl|003_child_prepend.tpl'); $result = $this->smarty->fetch('extends:003_parent.tpl|003_child_prepend.tpl');
$this->assertContains("prepend - Default Title", $result, $testName . ' - content'); $this->assertStringContainsString("prepend - Default Title", $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $testName . ' - fetch() failure'); $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $testName . ' - fetch() failure');
} }
/** /**
* test child/parent template chain with apppend * test child/parent template chain with apppend
@@ -67,8 +67,8 @@ class ExtendsResourceTest extends PHPUnit_Smarty
$this->smarty->compile_id = 1; $this->smarty->compile_id = 1;
} }
$result = $this->smarty->fetch('extends:004_parent.tpl|004_child_append.tpl'); $result = $this->smarty->fetch('extends:004_parent.tpl|004_child_append.tpl');
$this->assertContains("Default Title - append", $result, $testName . ' - content'); $this->assertStringContainsString("Default Title - append", $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $testName . ' - fetch() failure'); $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $testName . ' - fetch() failure');
} }
/** /**
@@ -87,8 +87,8 @@ class ExtendsResourceTest extends PHPUnit_Smarty
$this->smarty->compile_id = 1; $this->smarty->compile_id = 1;
} }
$result = $this->smarty->fetch('extends:040_parent.tpl|040_child.tpl'); $result = $this->smarty->fetch('extends:040_parent.tpl|040_child.tpl');
$this->assertContains("var-bar-var", $result, $testName . ' - content'); $this->assertStringContainsString("var-bar-var", $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $testName . ' - fetch() failure'); $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $testName . ' - fetch() failure');
} }
/** /**
@@ -103,7 +103,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
$tpl = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); $tpl = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl');
$this->assertFalse($tpl->isCached()); $this->assertFalse($tpl->isCached());
$result = $this->smarty->fetch($tpl); $result = $this->smarty->fetch($tpl);
$this->assertContains('Grandchild Page Title', $result); $this->assertStringContainsString('Grandchild Page Title', $result);
} }
/** /**
@@ -118,7 +118,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
$tpl2 = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); $tpl2 = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl');
$this->assertTrue($tpl2->isCached()); $this->assertTrue($tpl2->isCached());
$result = $this->smarty->fetch($tpl2); $result = $this->smarty->fetch($tpl2);
$this->assertContains('Grandchild Page Title', $result); $this->assertStringContainsString('Grandchild Page Title', $result);
} }
/** /**
@@ -137,7 +137,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
$tpl = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); $tpl = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl');
$this->assertFalse($tpl->isCached()); $this->assertFalse($tpl->isCached());
$result = $this->smarty->fetch($tpl); $result = $this->smarty->fetch($tpl);
$this->assertContains('Grandchild Page Title', $result); $this->assertStringContainsString('Grandchild Page Title', $result);
} }
/** /**
* test grandchild/child/parent dependency test2 * test grandchild/child/parent dependency test2
@@ -152,7 +152,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
$tpl2 = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); $tpl2 = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl');
$this->assertTrue($tpl2->isCached()); $this->assertTrue($tpl2->isCached());
$result = $this->smarty->fetch($tpl2); $result = $this->smarty->fetch($tpl2);
$this->assertContains('Grandchild Page Title', $result); $this->assertStringContainsString('Grandchild Page Title', $result);
} }
/** /**
@@ -171,7 +171,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
$tpl = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); $tpl = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl');
$this->assertFalse($tpl->isCached()); $this->assertFalse($tpl->isCached());
$result = $this->smarty->fetch($tpl); $result = $this->smarty->fetch($tpl);
$this->assertContains('Grandchild Page Title', $result); $this->assertStringContainsString('Grandchild Page Title', $result);
} }
/** /**
* test grandchild/child/parent dependency test3 * test grandchild/child/parent dependency test3
@@ -186,7 +186,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
$tpl2 = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); $tpl2 = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl');
$this->assertTrue($tpl2->isCached()); $this->assertTrue($tpl2->isCached());
$result = $this->smarty->fetch($tpl2); $result = $this->smarty->fetch($tpl2);
$this->assertContains('Grandchild Page Title', $result); $this->assertStringContainsString('Grandchild Page Title', $result);
} }
/** /**
@@ -205,7 +205,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
$tpl = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); $tpl = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl');
$this->assertFalse($tpl->isCached()); $this->assertFalse($tpl->isCached());
$result = $this->smarty->fetch($tpl); $result = $this->smarty->fetch($tpl);
$this->assertContains('Grandchild Page Title', $result); $this->assertStringContainsString('Grandchild Page Title', $result);
} }
/** /**
* test grandchild/child/parent dependency test4 * test grandchild/child/parent dependency test4
@@ -220,7 +220,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
$tpl = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl'); $tpl = $this->smarty->createTemplate('extends:021_parent.tpl|021_child.tpl|021_grandchild.tpl');
$this->assertTrue($tpl->isCached()); $this->assertTrue($tpl->isCached());
$result = $this->smarty->fetch($tpl); $result = $this->smarty->fetch($tpl);
$this->assertContains('Grandchild Page Title', $result); $this->assertStringContainsString('Grandchild Page Title', $result);
} }
/** /**
@@ -241,10 +241,10 @@ class ExtendsResourceTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('extends:./child/parent/033_parent.tpl|./child/033_child.tpl|033_grandchild.tpl'); $result = $this->smarty->fetch('extends:./child/parent/033_parent.tpl|./child/033_child.tpl|033_grandchild.tpl');
$this->assertContains('include grand:content include grand', $result, $testName . ' - grand'); $this->assertStringContainsString('include grand:content include grand', $result, $testName . ' - grand');
$this->assertContains('include child:content include child', $result, $testName . ' - grand'); $this->assertStringContainsString('include child:content include child', $result, $testName . ' - grand');
$this->assertContains('include parent:content include parent', $result, $testName . ' - grand'); $this->assertStringContainsString('include parent:content include parent', $result, $testName . ' - grand');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
public function data(){ public function data(){
@@ -293,11 +293,11 @@ class ExtendsResourceTest extends PHPUnit_Smarty
} }
$this->smarty->setCompileId($cid); $this->smarty->setCompileId($cid);
$result = $this->smarty->fetch('extends:034_parent.tpl|034_grandchild.tpl'); $result = $this->smarty->fetch('extends:034_parent.tpl|034_grandchild.tpl');
$this->assertContains('grandchild - grandchild', $result, $testName . ' - grand'); $this->assertStringContainsString('grandchild - grandchild', $result, $testName . ' - grand');
$this->assertContains('parent - parent', $result, $testName . ' - grand'); $this->assertStringContainsString('parent - parent', $result, $testName . ' - grand');
$this->assertContains($extends_recursion ? 'child - child' : 'child - parent', $result, $this->assertStringContainsString($extends_recursion ? 'child - child' : 'child - parent', $result,
$testName . ' - grand'); $testName . ' - grand');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}",
$result, $testName . ' - fetch() failure'); $result, $testName . ' - fetch() failure');
} }
} }

View File

@@ -15,7 +15,7 @@
*/ */
class FileResourceTest extends PHPUnit_Smarty class FileResourceTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->enableSecurity(); $this->smarty->enableSecurity();
@@ -65,16 +65,14 @@ class FileResourceTest extends PHPUnit_Smarty
} }
/** /**
* @expectedException SmartyException
* @expectedExceptionMessage Unable to
* @expectedExceptionMessage notthere.tpl
*
* test not existing file * test not existing file
*/ */
public function testTemplateFileNotExists3() public function testTemplateFileNotExists3()
{ {
$this->expectException('SmartyException');
$result = $this->smarty->fetch('notthere.tpl'); $this->expectExceptionMessage('Unable to');
$this->expectExceptionMessage('notthere.tpl');
$this->smarty->fetch('notthere.tpl');
} }
public function testGetTemplateTimestamp() public function testGetTemplateTimestamp()
@@ -196,7 +194,7 @@ class FileResourceTest extends PHPUnit_Smarty
public function testRelativeInclude() public function testRelativeInclude()
{ {
$result = $this->smarty->fetch('relative.tpl'); $result = $this->smarty->fetch('relative.tpl');
$this->assertContains('hello world', $result); $this->assertStringContainsString('hello world', $result);
} }
/** /**
@@ -208,12 +206,9 @@ class FileResourceTest extends PHPUnit_Smarty
public function testRelativeIncludeSub() public function testRelativeIncludeSub()
{ {
$result = $this->smarty->fetch('sub/relative.tpl'); $result = $this->smarty->fetch('sub/relative.tpl');
$this->assertContains('hello world', $result); $this->assertStringContainsString('hello world', $result);
} }
/** /**
* @expectedException SmartyException
* @expectedExceptionMessage Unable to
* @expectedExceptionMessage notthereh.tpl
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
* *
@@ -221,11 +216,11 @@ class FileResourceTest extends PHPUnit_Smarty
*/ */
public function testRelativeIncludeFail() public function testRelativeIncludeFail()
{ {
$result = $this->smarty->fetch('relative_sub.tpl'); $this->expectException('SmartyException');
$this->expectExceptionMessage('Unable to');
$this->smarty->fetch('relative_sub.tpl');
} }
/** /**
* @expectedException SmartyException
* @expectedExceptionMessage ./hello.tpl
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
* *
@@ -233,8 +228,10 @@ class FileResourceTest extends PHPUnit_Smarty
*/ */
public function testRelativeIncludeFailOtherDir() public function testRelativeIncludeFailOtherDir()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('./hello.tpl');
$this->smarty->addTemplateDir('./templates_2'); $this->smarty->addTemplateDir('./templates_2');
$result = $this->smarty->fetch('relative_notexist.tpl'); $this->smarty->fetch('relative_notexist.tpl');
} }
/** /**

View File

@@ -11,7 +11,7 @@
*/ */
class FileIncludePathTest extends PHPUnit_Smarty class FileIncludePathTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->use_include_path = true; $this->smarty->use_include_path = true;
@@ -26,7 +26,7 @@ class FileIncludePathTest extends PHPUnit_Smarty
* This method is called after a test is executed. * This method is called after a test is executed.
* *
*/ */
protected function tearDown() protected function tearDown(): void
{ {
ini_restore('include_path'); ini_restore('include_path');
$this->smarty->disableSecurity(); $this->smarty->disableSecurity();
@@ -38,30 +38,30 @@ class FileIncludePathTest extends PHPUnit_Smarty
} }
public function testInclude1() public function testInclude1()
{ {
$this->assertContains('include_test1', $this->smarty->fetch('test1.tpl')); $this->assertStringContainsString('include_test1', $this->smarty->fetch('test1.tpl'));
} }
public function testInclude2() public function testInclude2()
{ {
$this->assertContains('include_test2', $this->smarty->fetch('test2.tpl')); $this->assertStringContainsString('include_test2', $this->smarty->fetch('test2.tpl'));
} }
public function testInclude3() public function testInclude3()
{ {
$this->assertContains('include_test3', $this->smarty->fetch('test3.tpl')); $this->assertStringContainsString('include_test3', $this->smarty->fetch('test3.tpl'));
} }
public function testInclude31() public function testInclude31()
{ {
$this->smarty->use_include_path = false; $this->smarty->use_include_path = false;
$this->smarty->security_policy->secure_dir = getcwd(); $this->smarty->security_policy->secure_dir = getcwd();
$this->assertContains('include_test3', $this->smarty->fetch('test3.tpl')); $this->assertStringContainsString('include_test3', $this->smarty->fetch('test3.tpl'));
} }
public function testInclude4() public function testInclude4()
{ {
$this->assertContains('include_test4', $this->smarty->fetch('test4.tpl')); $this->assertStringContainsString('include_test4', $this->smarty->fetch('test4.tpl'));
} }
public function testInclude5() public function testInclude5()
{ {
$this->smarty->setTemplateDir(array('./')); $this->smarty->setTemplateDir(array('./'));
$this->assertContains('include path root', $this->smarty->fetch('test5.tpl')); $this->assertStringContainsString('include path root', $this->smarty->fetch('test5.tpl'));
} }
} }

View File

@@ -11,7 +11,7 @@
*/ */
class FileResourceIndexedTest extends PHPUnit_Smarty class FileResourceIndexedTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->addTemplateDir(dirname(__FILE__) . '/templates_2'); $this->smarty->addTemplateDir(dirname(__FILE__) . '/templates_2');

View File

@@ -15,7 +15,7 @@
*/ */
class PhpResourceTest extends PHPUnit_Smarty class PhpResourceTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }
@@ -57,7 +57,7 @@ class PhpResourceTest extends PHPUnit_Smarty
* public function testGetTemplateSource() * public function testGetTemplateSource()
* { * {
* $tpl = $this->smarty->createTemplate('php:phphelloworld.php'); * $tpl = $this->smarty->createTemplate('php:phphelloworld.php');
* $this->assertContains('php hello world', $tpl->source->getContent()); * $this->assertStringContainsString('php hello world', $tpl->source->getContent());
* } * }
* /** * /**
* test usesCompiler * test usesCompiler
@@ -110,7 +110,7 @@ class PhpResourceTest extends PHPUnit_Smarty
$this->smarty->caching = true; $this->smarty->caching = true;
$this->smarty->cache_lifetime = 1000; $this->smarty->cache_lifetime = 1000;
$tpl = $this->smarty->createTemplate('php:phphelloworld.php'); $tpl = $this->smarty->createTemplate('php:phphelloworld.php');
$this->assertContains('php hello world', $this->smarty->fetch($tpl)); $this->assertStringContainsString('php hello world', $this->smarty->fetch($tpl));
} }
/** /**
@@ -207,7 +207,7 @@ class PhpResourceTest extends PHPUnit_Smarty
{ {
$this->smarty->setAllowPhpTemplates(true); $this->smarty->setAllowPhpTemplates(true);
$tpl = $this->smarty->createTemplate('php:phphelloworld.php'); $tpl = $this->smarty->createTemplate('php:phphelloworld.php');
$this->assertContains('php hello world', $tpl->fetch()); $this->assertStringContainsString('php hello world', $tpl->fetch());
} }
/** /**
@@ -275,7 +275,7 @@ class PhpResourceTest extends PHPUnit_Smarty
public function testIncludePhpTemplate() public function testIncludePhpTemplate()
{ {
$this->smarty->setAllowPhpTemplates(true); $this->smarty->setAllowPhpTemplates(true);
$this->assertContains('php hello world', $this->smarty->fetch('includephp.tpl')); $this->assertStringContainsString('php hello world', $this->smarty->fetch('includephp.tpl'));
} }
/** /**
@@ -285,7 +285,7 @@ class PhpResourceTest extends PHPUnit_Smarty
{ {
$this->smarty->caching = true; $this->smarty->caching = true;
$this->smarty->setAllowPhpTemplates(true); $this->smarty->setAllowPhpTemplates(true);
$this->assertContains('php hello world', $this->smarty->fetch('includephp.tpl')); $this->assertStringContainsString('php hello world', $this->smarty->fetch('includephp.tpl'));
} }
/** /**

View File

@@ -16,7 +16,7 @@
class RegisteredResourceTest extends PHPUnit_Smarty class RegisteredResourceTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));

View File

@@ -15,7 +15,7 @@
*/ */
class ResourcePluginTest extends PHPUnit_Smarty class ResourcePluginTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class StreamResourceTest extends PHPUnit_Smarty class StreamResourceTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
@@ -32,7 +32,7 @@ class StreamResourceTest extends PHPUnit_Smarty
{ {
$this->cleanDirs(); $this->cleanDirs();
} }
public function tearDown() public function tearDown(): void
{ {
parent::tearDown(); parent::tearDown();
stream_wrapper_unregister("global"); stream_wrapper_unregister("global");
@@ -138,8 +138,6 @@ class StreamResourceTest extends PHPUnit_Smarty
$this->assertFalse($this->smarty->templateExists('global:notthere')); $this->assertFalse($this->smarty->templateExists('global:notthere'));
} }
/** /**
* @expectedException SmartyException
* @expectedExceptionMessage 'global:notthere'
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
* *
@@ -148,7 +146,9 @@ class StreamResourceTest extends PHPUnit_Smarty
public function testTemplateStramNotExists3() public function testTemplateStramNotExists3()
{ {
$result = $this->smarty->fetch('global:notthere'); $this->expectException('SmartyException');
$this->expectExceptionMessage('\'global:notthere\'');
$this->smarty->fetch('global:notthere');
} }
/** /**

View File

@@ -15,7 +15,7 @@
*/ */
class StringResourceTest extends PHPUnit_Smarty class StringResourceTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class FunctionTest extends PHPUnit_Smarty class FunctionTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }
@@ -35,7 +35,7 @@ class FunctionTest extends PHPUnit_Smarty
$this->smarty->fetch('eval:{unknown()}'); $this->smarty->fetch('eval:{unknown()}');
} }
catch (Exception $e) { catch (Exception $e) {
$this->assertContains("PHP function 'unknown' not allowed by security setting", $e->getMessage()); $this->assertStringContainsString("PHP function 'unknown' not allowed by security setting", $e->getMessage());
return; return;
} }

View File

@@ -16,7 +16,7 @@
class SecurityTest extends PHPUnit_Smarty class SecurityTest extends PHPUnit_Smarty
{ {
public $loadSmartyBC = true; public $loadSmartyBC = true;
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
@@ -60,15 +60,15 @@ class SecurityTest extends PHPUnit_Smarty
/** /**
* test not trusted PHP function * test not trusted PHP function
* @expectedException SmartyException
* @expectedExceptionMessage PHP function 'count' not allowed by security setting
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
*/ */
public function testNotTrustedPHPFunction() public function testNotTrustedPHPFunction()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('PHP function \'count\' not allowed by security setting');
$this->smarty->security_policy->php_functions = array('null'); $this->smarty->security_policy->php_functions = array('null');
$this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{count($foo)}'); $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{count($foo)}');
} }
/** /**
@@ -91,13 +91,13 @@ class SecurityTest extends PHPUnit_Smarty
/** /**
* test not trusted modifier * test not trusted modifier
* @expectedException SmartyException
* @expectedExceptionMessage modifier 'count' not allowed by security setting
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
*/ */
public function testNotTrustedModifier() public function testNotTrustedModifier()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('modifier \'count\' not allowed by security setting');
$this->smarty->security_policy->php_modifiers = array('null'); $this->smarty->security_policy->php_modifiers = array('null');
$this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{$foo|@count}'); $this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{$foo|@count}');
} }
@@ -123,26 +123,26 @@ class SecurityTest extends PHPUnit_Smarty
/** /**
* test not allowed tag * test not allowed tag
* @expectedException SmartyException
* @expectedExceptionMessage tag 'cycle' not allowed by security setting
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
*/ */
public function testNotAllowedTags2() public function testNotAllowedTags2()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('tag \'cycle\' not allowed by security setting');
$this->smarty->security_policy->allowed_tags = array('counter'); $this->smarty->security_policy->allowed_tags = array('counter');
$this->smarty->fetch('string:{counter}{cycle values="1,2"}'); $this->smarty->fetch('string:{counter}{cycle values="1,2"}');
} }
/** /**
* test disabled tag * test disabled tag
* @expectedException SmartyException
* @expectedExceptionMessage tag 'cycle' disabled by security setting
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
*/ */
public function testDisabledTags() public function testDisabledTags()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('tag \'cycle\' disabled by security setting');
$this->smarty->security_policy->disabled_tags = array('cycle'); $this->smarty->security_policy->disabled_tags = array('cycle');
$this->smarty->fetch('string:{counter}{cycle values="1,2"}'); $this->smarty->fetch('string:{counter}{cycle values="1,2"}');
} }
@@ -166,28 +166,28 @@ class SecurityTest extends PHPUnit_Smarty
/** /**
* test not allowed modifier * test not allowed modifier
* @expectedException SmartyException
* @expectedExceptionMessage modifier 'lower' not allowed by security setting
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
*/ */
public function testNotAllowedModifier() public function testNotAllowedModifier()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('modifier \'lower\' not allowed by security setting');
$this->smarty->security_policy->allowed_modifiers = array('upper'); $this->smarty->security_policy->allowed_modifiers = array('upper');
$this->smarty->fetch('string:{"hello"|upper}{"world"|lower}'); $this->smarty->fetch('string:{"hello"|upper}{"world"|lower}');
} }
/** /**
* test disabled modifier * test disabled modifier
* @expectedException SmartyException
* @expectedExceptionMessage modifier 'lower' disabled by security setting
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
*/ */
public function testDisabledModifier() public function testDisabledModifier()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('modifier \'lower\' disabled by security setting');
$this->smarty->security_policy->disabled_modifiers = array('lower'); $this->smarty->security_policy->disabled_modifiers = array('lower');
$this->smarty->fetch('string:{"hello"|upper}{"world"|lower}'); $this->smarty->fetch('string:{"hello"|upper}{"world"|lower}');
} }
/** /**
@@ -268,15 +268,15 @@ class SecurityTest extends PHPUnit_Smarty
/** /**
* test not trusted directory * test not trusted directory
* *
* @expectedException SmartyException
* @expectedExceptionMessage not trusted file path
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
*/ */
public function testNotTrustedDirectory() public function testNotTrustedDirectory()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('not trusted file path');
$this->smarty->security_policy->secure_dir = array(str_replace('\\', '/', dirname(__FILE__) . '/templates_3/')); $this->smarty->security_policy->secure_dir = array(str_replace('\\', '/', dirname(__FILE__) . '/templates_3/'));
$this->smarty->fetch('string:{include file="templates_2/hello.tpl"}'); $this->smarty->fetch('string:{include file="templates_2/hello.tpl"}');
} }
/** /**
@@ -300,15 +300,15 @@ class SecurityTest extends PHPUnit_Smarty
/** /**
* test not trusted PHP function * test not trusted PHP function
* @expectedException SmartyException
* @expectedExceptionMessage access to static class 'mysecuritystaticclass' not allowed by security setting
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
*/ */
public function testNotTrustedStaticClass() public function testNotTrustedStaticClass()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('access to static class \'mysecuritystaticclass\' not allowed by security setting');
$this->smarty->security_policy->static_classes = array('null'); $this->smarty->security_policy->static_classes = array('null');
$this->smarty->fetch('string:{mysecuritystaticclass::square(5)}'); $this->smarty->fetch('string:{mysecuritystaticclass::square(5)}');
} }
public function testChangedTrustedDirectory() public function testChangedTrustedDirectory()
@@ -342,14 +342,14 @@ class SecurityTest extends PHPUnit_Smarty
$this->assertTrue($tpl->source->exists); $this->assertTrue($tpl->source->exists);
} }
/** /**
* @expectedException SmartyException
* @expectedExceptionMessage stream 'global' not allowed by security setting
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
* test template file exits * test template file exits
*/ */
public function testTemplateNotTrustedStream() public function testTemplateNotTrustedStream()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('stream \'global\' not allowed by security setting');
stream_wrapper_register("global", "ResourceStreamSecurity") stream_wrapper_register("global", "ResourceStreamSecurity")
or die("Failed to register protocol"); or die("Failed to register protocol");
$fp = fopen("global://mytest", "r+"); $fp = fopen("global://mytest", "r+");
@@ -368,19 +368,19 @@ class SecurityTest extends PHPUnit_Smarty
$this->smarty->security_policy->trusted_uri = array( $this->smarty->security_policy->trusted_uri = array(
'#https://www.smarty.net$#i' '#https://www.smarty.net$#i'
); );
$this->assertContains('<title>Preface | Smarty</title>', $this->smarty->fetch('string:{fetch file="https://www.smarty.net/docs/en/preface.tpl"}')); $this->assertStringContainsString('<title>Preface | Smarty</title>', $this->smarty->fetch('string:{fetch file="https://www.smarty.net/docs/en/preface.tpl"}'));
} }
/** /**
* @expectedException SmartyException
* @expectedExceptionMessage URI 'https://www.smarty.net/docs/en/preface.tpl' not allowed by security setting
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
*/ */
public function testNotTrustedUri() public function testNotTrustedUri()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('URI \'https://www.smarty.net/docs/en/preface.tpl\' not allowed by security setting');
$this->smarty->security_policy->trusted_uri = array(); $this->smarty->security_policy->trusted_uri = array();
$this->assertContains('<title>Preface | Smarty</title>', $this->smarty->fetch('string:{fetch file="https://www.smarty.net/docs/en/preface.tpl"}')); $this->assertStringContainsString('<title>Preface | Smarty</title>', $this->smarty->fetch('string:{fetch file="https://www.smarty.net/docs/en/preface.tpl"}'));
} }
} }

View File

@@ -15,7 +15,7 @@
*/ */
class AppendTest extends PHPUnit_Smarty class AppendTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -17,7 +17,7 @@ class AppendByRefBCTest extends PHPUnit_Smarty
{ {
public $loadSmartyBC = true; public $loadSmartyBC = true;
public $loadSmarty = false; public $loadSmarty = false;
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class AppendByRefTest extends PHPUnit_Smarty class AppendByRefTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class AssignTest extends PHPUnit_Smarty class AssignTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -17,7 +17,7 @@ class AssignByRefBCTest extends PHPUnit_Smarty
{ {
public $loadSmartyBC = true; public $loadSmartyBC = true;
public $loadSmarty = false; public $loadSmarty = false;
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class AssignByRefTest extends PHPUnit_Smarty class AssignByRefTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class AssignGlobalTest extends PHPUnit_Smarty class AssignGlobalTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -20,7 +20,7 @@ class ClearAllAssignBCTest extends PHPUnit_Smarty
protected $_dataBC = null; protected $_dataBC = null;
protected $_tplBC = null; protected $_tplBC = null;
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));

View File

@@ -18,7 +18,7 @@ class ClearAllAssignTest extends PHPUnit_Smarty
protected $_data = null; protected $_data = null;
protected $_tpl = null; protected $_tpl = null;
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));

View File

@@ -17,7 +17,7 @@ class ClearAssignBCTest extends PHPUnit_Smarty
{ {
public $loadSmartyBC = true; public $loadSmartyBC = true;
public $loadSmarty = false; public $loadSmarty = false;
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));

View File

@@ -15,7 +15,7 @@
*/ */
class ClearAssignTest extends PHPUnit_Smarty class ClearAssignTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->assign('foo', 'foo'); $this->smarty->assign('foo', 'foo');

View File

@@ -20,7 +20,7 @@ class ClearCompiledBCTest extends ClearCompiledTest
public $loadSmartyBC = true; public $loadSmartyBC = true;
public $loadSmarty = false; public $loadSmarty = false;
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smartyBC->addTemplateDir('./templates_2/'); $this->smartyBC->addTemplateDir('./templates_2/');

View File

@@ -17,7 +17,7 @@
class ClearCompiledTest extends PHPUnit_Smarty class ClearCompiledTest extends PHPUnit_Smarty
{ {
public $methodName = null; public $methodName = null;
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->addTemplateDir('./templates_2/'); $this->smarty->addTemplateDir('./templates_2/');

View File

@@ -18,7 +18,7 @@ class get_template_varsBCTest extends PHPUnit_Smarty
public $loadSmartyBC = true; public $loadSmartyBC = true;
public $loadSmarty = false; public $loadSmarty = false;
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class GetTemplateVarsTest extends PHPUnit_Smarty class GetTemplateVarsTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -16,7 +16,7 @@
class RegisterBlockTest extends PHPUnit_Smarty class RegisterBlockTest extends PHPUnit_Smarty
{ {
public $loadSmartyBC = true; public $loadSmartyBC = true;
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->disableSecurity(); $this->smarty->disableSecurity();

View File

@@ -18,7 +18,7 @@ class RegisterCompilerFunctionBCTest extends PHPUnit_Smarty
public $loadSmartyBC = true; public $loadSmartyBC = true;
public $loadSmarty = false; public $loadSmarty = false;
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class RegisterCompilerFunctionTest extends PHPUnit_Smarty class RegisterCompilerFunctionTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -20,7 +20,7 @@ class RegisterFunctionBCTest extends PHPUnit_Smarty
public $loadSmarty = false; public $loadSmarty = false;
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -16,7 +16,7 @@
*/ */
class RegisterFunctionTest extends PHPUnit_Smarty class RegisterFunctionTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class RegisterModifierTest extends PHPUnit_Smarty class RegisterModifierTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class CompileRegisteredObjectFunctionTest extends PHPUnit_Smarty class CompileRegisteredObjectFunctionTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));

View File

@@ -15,7 +15,7 @@
*/ */
class TemplateExistsTest extends PHPUnit_Smarty class TemplateExistsTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class CommentsTest extends PHPUnit_Smarty class CommentsTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class SpacingTest extends PHPUnit_Smarty class SpacingTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class StaticClassAccessTest extends PHPUnit_Smarty class StaticClassAccessTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->disableSecurity(); $this->smarty->disableSecurity();

View File

@@ -15,7 +15,7 @@
*/ */
class CompileAppendTest extends PHPUnit_Smarty class CompileAppendTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/");

View File

@@ -15,7 +15,7 @@
*/ */
class CompileAssignTest extends PHPUnit_Smarty class CompileAssignTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/");

View File

@@ -15,7 +15,7 @@
*/ */
class CompileBlockPluginTest extends PHPUnit_Smarty class CompileBlockPluginTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->addPluginsDir("./PHPunitplugins/"); $this->smarty->addPluginsDir("./PHPunitplugins/");
@@ -47,13 +47,11 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
/** /**
* test unknown block plugin tag * test unknown block plugin tag
*
* @expectedException SmartyCompilerException
* @expectedExceptionMessage unknown tag 'bar'
*
*/ */
public function testBlockPluginUnknown() public function testBlockPluginUnknown()
{ {
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('unknown tag \'bar\'');
$this->assertEquals("hello world", $this->smarty->fetch('unknown.tpl')); $this->assertEquals("hello world", $this->smarty->fetch('unknown.tpl'));
} }
@@ -75,12 +73,11 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
* *
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
* @expectedException SmartyException
* @expectedExceptionMessage block tag 'blockplugintest' not callable
*
*/ */
public function testBlockPluginRegisteredFunction2() public function testBlockPluginRegisteredFunction2()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('block tag \'blockplugintest\' not callable');
$this->assertEquals('block test', $this->smarty->fetch('registered.tpl')); $this->assertEquals('block test', $this->smarty->fetch('registered.tpl'));
} }
@@ -102,12 +99,12 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
* *
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
* @expectedException SmartyException
* @expectedExceptionMessage block tag 'blockpluginstatic' not callable
* *
*/ */
public function testBlockPluginRegisteredStatic2() public function testBlockPluginRegisteredStatic2()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('block tag \'blockpluginstatic\' not callable');
$this->assertEquals('static block test', $this->smarty->fetch('registered_static.tpl')); $this->assertEquals('static block test', $this->smarty->fetch('registered_static.tpl'));
} }
@@ -130,12 +127,11 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
* *
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
* @expectedException SmartyException
* @expectedExceptionMessage block tag 'blockpluginmethod' not callable
*
*/ */
public function testBlockPluginRegisteredMethod2() public function testBlockPluginRegisteredMethod2()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('block tag \'blockpluginmethod\' not callable');
$this->assertEquals('method block test', $this->smarty->fetch('registered_method.tpl')); $this->assertEquals('method block test', $this->smarty->fetch('registered_method.tpl'));
} }
@@ -158,12 +154,11 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
* *
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
* @expectedException SmartyException
* @expectedExceptionMessage block tag 'myobject' not callable
*
*/ */
public function testBlockPluginRegisteredObject2() public function testBlockPluginRegisteredObject2()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('block tag \'myobject\' not callable');
$this->assertEquals('object block test', $this->smarty->fetch('registered_object.tpl')); $this->assertEquals('object block test', $this->smarty->fetch('registered_object.tpl'));
} }
@@ -297,10 +292,10 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
$this->assertEquals($isCached, $tpl->isCached(), $testName . ' - isCached()'); $this->assertEquals($isCached, $tpl->isCached(), $testName . ' - isCached()');
} }
$result = $this->smarty->fetch($tpl); $result = $this->smarty->fetch($tpl);
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}",
$result, $result,
$testName . ' - fetch() failure test number'); $testName . ' - fetch() failure test number');
$this->assertContains("block test{$resultNumber}", $result, $testName . ' - fetch() failure result'); $this->assertStringContainsString("block test{$resultNumber}", $result, $testName . ' - fetch() failure result');
} }
public function data() public function data()

View File

@@ -15,7 +15,7 @@
*/ */
class CompileBlockExtendsTest extends PHPUnit_Smarty class CompileBlockExtendsTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
//$this->smarty->setMergeCompiledIncludes(true); //$this->smarty->setMergeCompiledIncludes(true);
@@ -54,7 +54,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
{ {
$this->smarty->assign('parent', 'parent'); $this->smarty->assign('parent', 'parent');
$result = $this->smarty->fetch('001_parent.tpl'); $result = $this->smarty->fetch('001_parent.tpl');
$this->assertContains('(parent|b)content parent b(parent|/b)', $result); $this->assertStringContainsString('(parent|b)content parent b(parent|/b)', $result);
} }
/** /**
@@ -77,8 +77,8 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('002_child.tpl'); $result = $this->smarty->fetch('002_child.tpl');
$this->assertContains('(child|b)content child b(child|/b)', $result, $testName . ' - content'); $this->assertStringContainsString('(child|b)content child b(child|/b)', $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -102,9 +102,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('003_child.tpl'); $result = $this->smarty->fetch('003_child.tpl');
$this->assertContains('(child|b)content child b(child|/b)(parent|b)content parent b(parent|/b)', $result, $this->assertStringContainsString('(child|b)content child b(child|/b)(parent|b)content parent b(parent|/b)', $result,
$testName . ' - content'); $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -129,9 +129,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('003_grand.tpl'); $result = $this->smarty->fetch('003_grand.tpl');
$this->assertContains('(grand|b)content grand b(grand|/b)(child|b)content child b(child|/b)(parent|b)content parent b(parent|/b)', $this->assertStringContainsString('(grand|b)content grand b(grand|/b)(child|b)content child b(child|/b)(parent|b)content parent b(parent|/b)',
$result, $testName . ' - content'); $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -156,9 +156,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('004_child.tpl'); $result = $this->smarty->fetch('004_child.tpl');
$this->assertContains('(parent|b)content parent b(parent|/b)(child|b)content child b(child|/b)', $result, $this->assertStringContainsString('(parent|b)content parent b(parent|/b)(child|b)content child b(child|/b)', $result,
$testName . ' - content'); $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -183,9 +183,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('004_grand.tpl'); $result = $this->smarty->fetch('004_grand.tpl');
$this->assertContains('(parent|b)content parent b(parent|/b)(child|b)content child b(child|/b)(grand|b)content grand b(grand|/b)', $this->assertStringContainsString('(parent|b)content parent b(parent|/b)(child|b)content child b(child|/b)(grand|b)content grand b(grand|/b)',
$result, $testName . ' - content'); $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -210,9 +210,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('004_grand2.tpl'); $result = $this->smarty->fetch('004_grand2.tpl');
$this->assertContains('(parent|b)content parent b(parent|/b)(grand|b)content grand b(grand|/b)(child|b)content child b(child|/b)(grand|b)content grand b(grand|/b)', $this->assertStringContainsString('(parent|b)content parent b(parent|/b)(grand|b)content grand b(grand|/b)(child|b)content child b(child|/b)(grand|b)content grand b(grand|/b)',
$result, $testName . ' - content'); $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -236,9 +236,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('005_child.tpl'); $result = $this->smarty->fetch('005_child.tpl');
$this->assertContains('(parent|b)content parent b(parent|/b)(child|b)content child b(child|/b)', $result, $this->assertStringContainsString('(parent|b)content parent b(parent|/b)(child|b)content child b(child|/b)', $result,
$testName . ' - content'); $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -262,9 +262,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('006_child.tpl'); $result = $this->smarty->fetch('006_child.tpl');
$this->assertContains('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result, $this->assertStringContainsString('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result,
$testName . ' - content'); $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -289,9 +289,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('007_child.tpl'); $result = $this->smarty->fetch('007_child.tpl');
$this->assertContains('(child|b)content (parent|b)content parent b(parent|/b) b(child|/b)', $result, $this->assertStringContainsString('(child|b)content (parent|b)content parent b(parent|/b) b(child|/b)', $result,
$testName . ' - content'); $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -316,9 +316,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('007_grand.tpl'); $result = $this->smarty->fetch('007_grand.tpl');
$this->assertContains('(grand|b)content (child|b)content (parent|b)content parent b(parent|/b) b(child|/b) b(grand|/b)', $this->assertStringContainsString('(grand|b)content (child|b)content (parent|b)content parent b(parent|/b) b(child|/b) b(grand|/b)',
$result, $testName . ' - content'); $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -343,9 +343,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('008_child.tpl'); $result = $this->smarty->fetch('008_child.tpl');
$this->assertContains('(child|b)content escaped &lt;text&gt; child 1 b(child|/b', $result, $this->assertStringContainsString('(child|b)content escaped &lt;text&gt; child 1 b(child|/b', $result,
$testName . ' - content'); $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -368,9 +368,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('009_parent.tpl'); $result = $this->smarty->fetch('009_parent.tpl');
$this->assertContains('(parent|b)content (parent|c)content parent c(parent|/c) b(parent|/b)', $result, $this->assertStringContainsString('(parent|b)content (parent|c)content parent c(parent|/c) b(parent|/b)', $result,
$testName . ' - content'); $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -394,9 +394,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('010_child.tpl'); $result = $this->smarty->fetch('010_child.tpl');
$this->assertContains('(parent|b)content (parent|c)content child c(parent|/c) b(parent|/b)', $result, $this->assertStringContainsString('(parent|b)content (parent|c)content child c(parent|/c) b(parent|/b)', $result,
$testName . ' - content'); $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -421,9 +421,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('011_grand.tpl'); $result = $this->smarty->fetch('011_grand.tpl');
$this->assertContains('(child|b)content(child|c)content(child|n)content(include)content child i(/include)n(child|/n)c(child|/c)(grand|c)content grand c(grand|\c)b(child|/b)', $this->assertStringContainsString('(child|b)content(child|c)content(child|n)content(include)content child i(/include)n(child|/n)c(child|/c)(grand|c)content grand c(grand|\c)b(child|/b)',
$result, $testName . ' - content'); $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -448,9 +448,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('012_grandgrand.tpl'); $result = $this->smarty->fetch('012_grandgrand.tpl');
$this->assertContains('(grand|b)content (grandgrand|c)content c(grandgrand|\c)(grand|c)content c(grand|\c) b(grand|/b)', $this->assertStringContainsString('(grand|b)content (grandgrand|c)content c(grandgrand|\c)(grand|c)content c(grand|\c) b(grand|/b)',
$result, $testName . ' - content'); $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -472,9 +472,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('018_child.tpl'); $result = $this->smarty->fetch('018_child.tpl');
$this->assertContains('(child|b)content(child|c)content child c(child|/c)b(child|/b)', $result, $this->assertStringContainsString('(child|b)content(child|c)content child c(child|/c)b(child|/b)', $result,
$testName . ' - content'); $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -496,9 +496,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('018_grand.tpl'); $result = $this->smarty->fetch('018_grand.tpl');
$this->assertContains('(child|b)content(child|c)content child c(child|/c)(child|d)content (grand|d)content grand d(grand|/d) d(child|/d)b(child|/b)', $this->assertStringContainsString('(child|b)content(child|c)content child c(child|/c)(child|d)content (grand|d)content grand d(grand|/d) d(child|/d)b(child|/b)',
$result, $testName . ' - content'); $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -520,9 +520,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('018_grandgrand.tpl'); $result = $this->smarty->fetch('018_grandgrand.tpl');
$this->assertContains('(child|b)content(grand|c)content (grandgrand|c)content grandgrand c(grandgrand|/c) c(grand|/c)(child|d)content (grandgrand|d)content grandgrand d(grandgrand|/d) d(child|/d)b(child|/b)', $this->assertStringContainsString('(child|b)content(grand|c)content (grandgrand|c)content grandgrand c(grandgrand|/c) c(grand|/c)(child|d)content (grandgrand|d)content grandgrand d(grandgrand|/d) d(child|/d)b(child|/b)',
$result, $testName . ' - content'); $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -544,13 +544,13 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('020_include_root.tpl'); $result = $this->smarty->fetch('020_include_root.tpl');
$this->assertContains('(include1)(include1|p)content 1 p(include1|\p)(include1|b)content 1 b(include1|\b)(\include1)', $this->assertStringContainsString('(include1)(include1|p)content 1 p(include1|\p)(include1|b)content 1 b(include1|\b)(\include1)',
$result, $testName . ' - include 1'); $result, $testName . ' - include 1');
$this->assertContains('(include2)(include2|p)content 2 p(include2|\p)(include2|b)content 2 b(include2|\b)(\include2)', $this->assertStringContainsString('(include2)(include2|p)content 2 p(include2|\p)(include2|b)content 2 b(include2|\b)(\include2)',
$result, $testName . ' - include 1'); $result, $testName . ' - include 1');
$this->assertContains('(include3)(include3|p)content 3 p(include3|\p)(include3|b)content 3 b(include3|\b)(\include3)', $this->assertStringContainsString('(include3)(include3|p)content 3 p(include3|\p)(include3|b)content 3 b(include3|\b)(\include3)',
$result, $testName . ' - include 1'); $result, $testName . ' - include 1');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -571,7 +571,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$tpl = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); $tpl = $this->smarty->createTemplate('021_grand.tpl', $this->smarty);
$this->assertFalse($tpl->isCached()); $this->assertFalse($tpl->isCached());
$result = $this->smarty->fetch($tpl); $result = $this->smarty->fetch($tpl);
$this->assertContains('(grand|b)content grand b(grand|/b)(child|b)content child b(child|/b)(parent|b)content parent b(parent|/b)', $this->assertStringContainsString('(grand|b)content grand b(grand|/b)(child|b)content child b(child|/b)(parent|b)content parent b(parent|/b)',
$result); $result);
$this->smarty->_clearTemplateCache(); $this->smarty->_clearTemplateCache();
$this->smarty->assign('parent', 'parent2'); $this->smarty->assign('parent', 'parent2');
@@ -580,7 +580,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); $tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty);
$this->assertTrue($tpl2->isCached()); $this->assertTrue($tpl2->isCached());
$result = $this->smarty->fetch($tpl2); $result = $this->smarty->fetch($tpl2);
$this->assertContains('(grand|b)content grand2 b(grand|/b)(child|b)content child2 b(child|/b)(parent|b)content parent b(parent|/b)', $this->assertStringContainsString('(grand|b)content grand2 b(grand|/b)(child|b)content child2 b(child|/b)(parent|b)content parent b(parent|/b)',
$result); $result);
} }
@@ -601,7 +601,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); $tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty);
$this->assertTrue($tpl2->isCached()); $this->assertTrue($tpl2->isCached());
$result = $this->smarty->fetch($tpl2); $result = $this->smarty->fetch($tpl2);
$this->assertContains('(grand|b)content grand3 b(grand|/b)(child|b)content child3 b(child|/b)(parent|b)content parent b(parent|/b)', $this->assertStringContainsString('(grand|b)content grand3 b(grand|/b)(child|b)content child3 b(child|/b)(parent|b)content parent b(parent|/b)',
$result); $result);
} }
@@ -626,7 +626,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$tpl = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); $tpl = $this->smarty->createTemplate('021_grand.tpl', $this->smarty);
$this->assertFalse($tpl->isCached()); $this->assertFalse($tpl->isCached());
$result = $this->smarty->fetch($tpl); $result = $this->smarty->fetch($tpl);
$this->assertContains('(grand|b)content grand4 b(grand|/b)(child|b)content child4 b(child|/b)(parent|b)content parent4 b(parent|/b)', $this->assertStringContainsString('(grand|b)content grand4 b(grand|/b)(child|b)content child4 b(child|/b)(parent|b)content parent4 b(parent|/b)',
$result); $result);
$this->smarty->_clearTemplateCache(); $this->smarty->_clearTemplateCache();
$this->smarty->assign('parent', 'parent5'); $this->smarty->assign('parent', 'parent5');
@@ -636,7 +636,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); $tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty);
$this->assertTrue($tpl2->isCached()); $this->assertTrue($tpl2->isCached());
$result = $this->smarty->fetch($tpl2); $result = $this->smarty->fetch($tpl2);
$this->assertContains('(grand|b)content grand5 b(grand|/b)(child|b)content child5 b(child|/b)(parent|b)content parent4 b(parent|/b)', $this->assertStringContainsString('(grand|b)content grand5 b(grand|/b)(child|b)content child5 b(child|/b)(parent|b)content parent4 b(parent|/b)',
$result); $result);
} }
@@ -661,7 +661,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$tpl = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); $tpl = $this->smarty->createTemplate('021_grand.tpl', $this->smarty);
$this->assertFalse($tpl->isCached()); $this->assertFalse($tpl->isCached());
$result = $this->smarty->fetch($tpl); $result = $this->smarty->fetch($tpl);
$this->assertContains('(grand|b)content grand6 b(grand|/b)(child|b)content child6 b(child|/b)(parent|b)content parent6 b(parent|/b)', $this->assertStringContainsString('(grand|b)content grand6 b(grand|/b)(child|b)content child6 b(child|/b)(parent|b)content parent6 b(parent|/b)',
$result); $result);
} }
@@ -683,7 +683,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); $tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty);
$this->assertTrue($tpl2->isCached()); $this->assertTrue($tpl2->isCached());
$result = $this->smarty->fetch($tpl2); $result = $this->smarty->fetch($tpl2);
$this->assertContains('(grand|b)content grand7 b(grand|/b)(child|b)content child7 b(child|/b)(parent|b)content parent6 b(parent|/b)', $this->assertStringContainsString('(grand|b)content grand7 b(grand|/b)(child|b)content child7 b(child|/b)(parent|b)content parent6 b(parent|/b)',
$result); $result);
} }
@@ -707,7 +707,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$tpl = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); $tpl = $this->smarty->createTemplate('021_grand.tpl', $this->smarty);
$this->assertFalse($tpl->isCached()); $this->assertFalse($tpl->isCached());
$result = $this->smarty->fetch($tpl); $result = $this->smarty->fetch($tpl);
$this->assertContains('(grand|b)content grand8 b(grand|/b)(child|b)content child8 b(child|/b)(parent|b)content parent8 b(parent|/b)', $this->assertStringContainsString('(grand|b)content grand8 b(grand|/b)(child|b)content child8 b(child|/b)(parent|b)content parent8 b(parent|/b)',
$result); $result);
} }
@@ -728,7 +728,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty); $tpl2 = $this->smarty->createTemplate('021_grand.tpl', $this->smarty);
$this->assertTrue($tpl2->isCached()); $this->assertTrue($tpl2->isCached());
$result = $this->smarty->fetch($tpl2); $result = $this->smarty->fetch($tpl2);
$this->assertContains('(grand|b)content grand9 b(grand|/b)(child|b)content child9 b(child|/b)(parent|b)content parent8 b(parent|/b)', $this->assertStringContainsString('(grand|b)content grand9 b(grand|/b)(child|b)content child9 b(child|/b)(parent|b)content parent8 b(parent|/b)',
$result); $result);
} }
@@ -747,37 +747,37 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
public function testNotExistingChildBlock_024() public function testNotExistingChildBlock_024()
{ {
$result = $this->smarty->fetch('024_parent.tpl'); $result = $this->smarty->fetch('024_parent.tpl');
$this->assertContains('no >< child', $result); $this->assertStringContainsString('no >< child', $result);
} }
/** /**
* @expectedException SmartyCompilerException
* @expectedExceptionMessage '{$smarty.block.child}' used outside {block} tags
* test {$this->smarty.block.child} outside {block] * test {$this->smarty.block.child} outside {block]
*/ */
public function testSmartyBlockChildOutsideBlock_025() public function testSmartyBlockChildOutsideBlock_025()
{ {
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('\'{$smarty.block.child}\' used outside {block} tags');
$this->smarty->fetch('025_parent.tpl'); $this->smarty->fetch('025_parent.tpl');
} }
/** /**
* @expectedException SmartyCompilerException
* @expectedExceptionMessage '{$smarty.block.parent}' used outside {block} tags
* test {$this->smarty.block.parent} outside {block] * test {$this->smarty.block.parent} outside {block]
*/ */
public function testSmartyBlockParentOutsideBlock_026() public function testSmartyBlockParentOutsideBlock_026()
{ {
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('\'{$smarty.block.parent}\' used outside {block} tags');
$this->smarty->fetch('026_child.tpl'); $this->smarty->fetch('026_child.tpl');
} }
/** /**
* @expectedException SmartyException
* @expectedExceptionMessage illegal '{$smarty.block.parent}'
* test {$this->smarty.block.parent} in parent template * test {$this->smarty.block.parent} in parent template
*/ */
public function testSmartyBlockParentInParent_027() public function testSmartyBlockParentInParent_027()
{ {
$result = $this->smarty->fetch('027_parent.tpl'); $this->expectException('SmartyException');
$this->expectExceptionMessage('illegal \'{$smarty.block.parent}\'');
$this->smarty->fetch('027_parent.tpl');
} }
/** /**
@@ -800,8 +800,8 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
} }
$this->smarty->assign('foo', '028_parent_include1.tpl'); $this->smarty->assign('foo', '028_parent_include1.tpl');
$result = $this->smarty->fetch('028_child.tpl'); $result = $this->smarty->fetch('028_child.tpl');
$this->assertContains('b1-include-1--b1', $result, $testName . ' - content'); $this->assertStringContainsString('b1-include-1--b1', $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -822,8 +822,8 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
} }
$this->smarty->assign('foo', '028_parent_include2.tpl'); $this->smarty->assign('foo', '028_parent_include2.tpl');
$result = $this->smarty->fetch('028_child.tpl'); $result = $this->smarty->fetch('028_child.tpl');
$this->assertContains('b1-child-i2-include-2--b1', $result, $testName . ' - content'); $this->assertStringContainsString('b1-child-i2-include-2--b1', $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -845,9 +845,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('030_grandchild_nested.tpl'); $result = $this->smarty->fetch('030_grandchild_nested.tpl');
$this->assertContains('child pre -grandchild content- child post', $result, $testName . ' - content'); $this->assertStringContainsString('child pre -grandchild content- child post', $result, $testName . ' - content');
$this->assertContains('include:' . $testNumber, $result, $testName . ' - content 2'); $this->assertStringContainsString('include:' . $testNumber, $result, $testName . ' - content 2');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
/** /**
@@ -868,9 +868,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('sub/030_grandchild_nested_rel.tpl'); $result = $this->smarty->fetch('sub/030_grandchild_nested_rel.tpl');
$this->assertContains('child pre -grandchild content- child post', $result, $testName . ' - content'); $this->assertStringContainsString('child pre -grandchild content- child post', $result, $testName . ' - content');
$this->assertContains('include:' . $testNumber, $result, $testName . ' - content 2'); $this->assertStringContainsString('include:' . $testNumber, $result, $testName . ' - content 2');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
/** /**
@@ -891,8 +891,8 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('034_1child.tpl'); $result = $this->smarty->fetch('034_1child.tpl');
$this->assertContains('parent b1', $result, $testName . ' - content'); $this->assertStringContainsString('parent b1', $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
/** /**
@@ -913,8 +913,8 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('034_2child.tpl'); $result = $this->smarty->fetch('034_2child.tpl');
$this->assertContains('parent b1', $result, $testName . ' - content'); $this->assertStringContainsString('parent b1', $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
/** /**
@@ -935,8 +935,8 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('034_3child.tpl'); $result = $this->smarty->fetch('034_3child.tpl');
$this->assertContains('parent b1', $result, $testName . ' - content'); $this->assertStringContainsString('parent b1', $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
/** /**
@@ -957,8 +957,8 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('034_4child.tpl'); $result = $this->smarty->fetch('034_4child.tpl');
$this->assertContains('parent b1', $result, $testName . ' - content'); $this->assertStringContainsString('parent b1', $result, $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
/** /**
@@ -982,9 +982,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('035_child.tpl'); $result = $this->smarty->fetch('035_child.tpl');
$this->assertContains('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result, $this->assertStringContainsString('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result,
$testName . ' - content'); $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -1009,9 +1009,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('035_child.tpl'); $result = $this->smarty->fetch('035_child.tpl');
$this->assertContains('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result, $this->assertStringContainsString('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result,
$testName . ' - content'); $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
/** /**
@@ -1035,9 +1035,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('035_child.tpl'); $result = $this->smarty->fetch('035_child.tpl');
$this->assertContains('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result, $this->assertStringContainsString('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result,
$testName . ' - content'); $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
/** /**
@@ -1061,9 +1061,9 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('035_child.tpl'); $result = $this->smarty->fetch('035_child.tpl');
$this->assertContains('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result, $this->assertStringContainsString('(parent|b)content (child|b)content child b(child|/b) b(parent|/b)', $result,
$testName . ' - content'); $testName . ' - content');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
@@ -1102,7 +1102,7 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->loadFilter('post', 'test031'); $this->smarty->loadFilter('post', 'test031');
$this->smarty->assign('foo', 'foo'); $this->smarty->assign('foo', 'foo');
$this->smarty->assign('bar', 'bar'); $this->smarty->assign('bar', 'bar');
$this->assertContains('bar', $this->smarty->fetch('031_post_filter.tpl')); $this->assertStringContainsString('bar', $this->smarty->fetch('031_post_filter.tpl'));
} }
/* /*
* Test new inheritance root in outermost include * Test new inheritance root in outermost include
@@ -1110,11 +1110,11 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
public function testInclude_032() public function testInclude_032()
{ {
$result = $this->smarty->fetch('032_child.tpl'); $result = $this->smarty->fetch('032_child.tpl');
$this->assertContains('foo in 032_child.tpl', $result); $this->assertStringContainsString('foo in 032_child.tpl', $result);
$this->assertContains('bar in 032_included_child.tpl', $result); $this->assertStringContainsString('bar in 032_included_child.tpl', $result);
$this->assertContains('foo in 032_included_parent.tpl', $result); $this->assertStringContainsString('foo in 032_included_parent.tpl', $result);
$this->assertNotContains('bar in 032_included_parent.tpl', $result); $this->assertStringNotContainsString('bar in 032_included_parent.tpl', $result);
$this->assertNotContains('foo in 032_parent.tpl', $result); $this->assertStringNotContainsString('foo in 032_parent.tpl', $result);
} }
/** /**
* test relative includes in {block} * test relative includes in {block}
@@ -1134,66 +1134,56 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
$this->smarty->setCompileId(1); $this->smarty->setCompileId(1);
} }
$result = $this->smarty->fetch('033_grandchild.tpl'); $result = $this->smarty->fetch('033_grandchild.tpl');
$this->assertContains('include grand:content include grand', $result, $testName . ' - grand'); $this->assertStringContainsString('include grand:content include grand', $result, $testName . ' - grand');
$this->assertContains('include child:content include child', $result, $testName . ' - grand'); $this->assertStringContainsString('include child:content include child', $result, $testName . ' - grand');
$this->assertContains('include parent:content include parent', $result, $testName . ' - grand'); $this->assertStringContainsString('include parent:content include parent', $result, $testName . ' - grand');
$this->assertContains("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result, $this->assertStringContainsString("test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $result,
$testName . ' - fetch() failure'); $testName . ' - fetch() failure');
} }
/** /**
*
* test smarty.block.foo * test smarty.block.foo
*
* @expectedException SmartyCompilerException
* @expectedExceptionMessage $smarty.block is not defined
*/ */
public function testSmartyBlockWrongBlockName_036() public function testSmartyBlockWrongBlockName_036()
{ {
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('$smarty.block is not defined');
$this->smarty->fetch('036_parent.tpl'); $this->smarty->fetch('036_parent.tpl');
} }
/** /**
*
* test '{$smarty.block.parent}' * test '{$smarty.block.parent}'
*
* @expectedException SmartyException
* @expectedExceptionMessage inheritance: illegal '{$smarty.block.parent}' used in child template
*/ */
public function testSmartyParentBlockCalledInParent_036_1() public function testSmartyParentBlockCalledInParent_036_1()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('inheritance: illegal \'{$smarty.block.parent}\' used in child template');
$this->smarty->fetch('036_1_parent.tpl'); $this->smarty->fetch('036_1_parent.tpl');
} }
/** /**
*
* test {block_parent} * test {block_parent}
*
* @expectedException SmartyException
* @expectedExceptionMessage inheritance: illegal '{block_parent}' used in child template
*/ */
public function testSmartyParentBlockCalledInParent_036_2() public function testSmartyParentBlockCalledInParent_036_2()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('inheritance: illegal \'{block_parent}\' used in child template');
$this->smarty->fetch('036_2_parent.tpl'); $this->smarty->fetch('036_2_parent.tpl');
} }
/** /**
*
* test {block_parent} * test {block_parent}
*
* @expectedException SmartyException
* @expectedExceptionMessage inheritance: illegal '{parent}' used in child template
*/ */
public function testSmartyParentBlockCalledInParent_036_3() public function testSmartyParentBlockCalledInParent_036_3()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('inheritance: illegal \'{parent}\' used in child template');
$this->smarty->fetch('036_3_parent.tpl'); $this->smarty->fetch('036_3_parent.tpl');
} }
/** /**
*
* test smarty.block * test smarty.block
*
* @expectedException SmartyCompilerException
* @expectedExceptionMessage $smarty.block is not defined
*/ */
public function testSmartyBlockMissigBlockName_037() public function testSmartyBlockMissigBlockName_037()
{ {
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('$smarty.block is not defined');
$this->smarty->fetch('037_parent.tpl'); $this->smarty->fetch('037_parent.tpl');
} }

View File

@@ -15,7 +15,7 @@
*/ */
class CompileCaptureTest extends PHPUnit_Smarty class CompileCaptureTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->addTemplateDir("./templates_tmp"); $this->smarty->addTemplateDir("./templates_tmp");
@@ -70,15 +70,15 @@ class CompileCaptureTest extends PHPUnit_Smarty
public function testCapture9() public function testCapture9()
{ {
$result = $this->smarty->fetch('009_capture.tpl'); $result = $this->smarty->fetch('009_capture.tpl');
$this->assertContains('-->hello world<--', $result); $this->assertStringContainsString('-->hello world<--', $result);
$this->assertContains('-->hello world2<--', $result); $this->assertStringContainsString('-->hello world2<--', $result);
} }
public function testCompileCaptureNocache1() public function testCompileCaptureNocache1()
{ {
$this->smarty->assign('foo', 1); $this->smarty->assign('foo', 1);
$this->smarty->caching = 1; $this->smarty->caching = 1;
$this->assertContains('foo 1', $this->smarty->fetch('test_capture_nocache.tpl')); $this->assertStringContainsString('foo 1', $this->smarty->fetch('test_capture_nocache.tpl'));
} }
/** /**
@@ -92,7 +92,7 @@ class CompileCaptureTest extends PHPUnit_Smarty
$this->smarty->assign('foo', 2); $this->smarty->assign('foo', 2);
$this->smarty->caching = 1; $this->smarty->caching = 1;
$this->assertTrue($this->smarty->isCached('test_capture_nocache.tpl')); $this->assertTrue($this->smarty->isCached('test_capture_nocache.tpl'));
$this->assertContains('foo 2', $this->smarty->fetch('test_capture_nocache.tpl')); $this->assertStringContainsString('foo 2', $this->smarty->fetch('test_capture_nocache.tpl'));
} }
/* /*
* Test capture buffer names with uppercase * Test capture buffer names with uppercase
@@ -100,8 +100,8 @@ class CompileCaptureTest extends PHPUnit_Smarty
public function testCapture10() public function testCapture10()
{ {
$result = $this->smarty->fetch('010_capture.tpl'); $result = $this->smarty->fetch('010_capture.tpl');
$this->assertContains('lowercase', $result); $this->assertStringContainsString('lowercase', $result);
$this->assertContains('uppercase', $result); $this->assertStringContainsString('uppercase', $result);
} }
/** /**

View File

@@ -15,7 +15,7 @@
*/ */
class CompilerPluginTest extends PHPUnit_Smarty class CompilerPluginTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -20,7 +20,7 @@ class CompileConfigLoadTest extends PHPUnit_Smarty
* This method is called before a test is executed. * This method is called before a test is executed.
* *
*/ */
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/");
@@ -161,12 +161,12 @@ class CompileConfigLoadTest extends PHPUnit_Smarty
} }
/** /**
* @expectedException SmartyCompilerException
* @expectedExceptionMessage Syntax error in config file
* test config file syntax error * test config file syntax error
*/ */
public function testConfigSyntaxError_009() public function testConfigSyntaxError_009()
{ {
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('Syntax error in config file');
$this->smarty->fetch('009_error.tpl'); $this->smarty->fetch('009_error.tpl');
} }
} }

View File

@@ -15,7 +15,7 @@
*/ */
class CompileDelimiterTest extends PHPUnit_Smarty class CompileDelimiterTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }
@@ -41,12 +41,10 @@ class CompileDelimiterTest extends PHPUnit_Smarty
$this->assertEquals('x}x', $this->smarty->fetch($tpl)); $this->assertEquals('x}x', $this->smarty->fetch($tpl));
} }
/**
* @expectedException SmartyCompilerException
* @expectedExceptionMessage nocache option not allowed
*/
public function testLeftDelimiterError() public function testLeftDelimiterError()
{ {
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('nocache option not allowed');
$tpl = $this->smarty->createTemplate('string:x{ldelim nocache}x'); $tpl = $this->smarty->createTemplate('string:x{ldelim nocache}x');
$this->assertEquals('x{x', $this->smarty->fetch($tpl)); $this->assertEquals('x{x', $this->smarty->fetch($tpl));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class CompileEvalTest extends PHPUnit_Smarty class CompileEvalTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class CompileForTest extends PHPUnit_Smarty class CompileForTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class CompileForeachTest extends PHPUnit_Smarty class CompileForeachTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/");

View File

@@ -15,7 +15,7 @@
*/ */
class CompileFunctionPluginTest extends PHPUnit_Smarty class CompileFunctionPluginTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/");

View File

@@ -15,7 +15,7 @@
*/ */
class CompileIfTest extends PHPUnit_Smarty class CompileIfTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/");

View File

@@ -15,7 +15,7 @@
*/ */
class CompileIncludeTest extends PHPUnit_Smarty class CompileIncludeTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/");
@@ -187,7 +187,7 @@ class CompileIncludeTest extends PHPUnit_Smarty
$this->smarty->assign('foo', 1); $this->smarty->assign('foo', 1);
$this->smarty->assign('bar', 'bar'); $this->smarty->assign('bar', 'bar');
$content = $this->smarty->fetch('test_recursive_includes.tpl'); $content = $this->smarty->fetch('test_recursive_includes.tpl');
$this->assertContains("before 1 bar<br>\nbefore 2 bar<br>\nbefore 3 bar<br>\nafter 3 bar<br>\nafter 2 bar<br>\nafter 1 bar<br>", $content, $text); $this->assertStringContainsString("before 1 bar<br>\nbefore 2 bar<br>\nbefore 3 bar<br>\nafter 3 bar<br>\nafter 2 bar<br>\nafter 1 bar<br>", $content, $text);
} }
/** /**
@@ -203,7 +203,7 @@ class CompileIncludeTest extends PHPUnit_Smarty
$this->smarty->assign('foo', 1); $this->smarty->assign('foo', 1);
$this->smarty->assign('bar', 'bar'); $this->smarty->assign('bar', 'bar');
$content = $this->smarty->fetch('test_recursive_includes2.tpl'); $content = $this->smarty->fetch('test_recursive_includes2.tpl');
$this->assertContains("before 1 bar<br>\nbefore 3 bar<br>\nbefore 5 bar<br>\nafter 5 bar<br>\nafter 3 bar<br>\nafter 1 bar<br>", $content, $text); $this->assertStringContainsString("before 1 bar<br>\nbefore 3 bar<br>\nbefore 5 bar<br>\nafter 5 bar<br>\nafter 3 bar<br>\nafter 1 bar<br>", $content, $text);
} }
/** /**

View File

@@ -17,7 +17,7 @@ class CompileIncludePhpTest extends PHPUnit_Smarty
{ {
public $loadSmartyBC = true; public $loadSmartyBC = true;
public $loadSmarty = false; public $loadSmarty = false;
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smartyBC->setForceCompile(true); $this->smartyBC->setForceCompile(true);
@@ -36,7 +36,7 @@ class CompileIncludePhpTest extends PHPUnit_Smarty
$this->smartyBC->disableSecurity(); $this->smartyBC->disableSecurity();
$tpl = $this->smartyBC->createTemplate('include_php.tpl'); $tpl = $this->smartyBC->createTemplate('include_php.tpl');
$result = $this->smartyBC->fetch($tpl); $result = $this->smartyBC->fetch($tpl);
$this->assertContains("test include php", $result); $this->assertStringContainsString("test include php", $result);
} }
/** /**
@@ -48,7 +48,7 @@ class CompileIncludePhpTest extends PHPUnit_Smarty
$this->smartyBC->security_policy->trusted_dir = '.\\scripts\\'; $this->smartyBC->security_policy->trusted_dir = '.\\scripts\\';
$tpl = $this->smartyBC->createTemplate('include_php_trusted.tpl'); $tpl = $this->smartyBC->createTemplate('include_php_trusted.tpl');
$result = $this->smartyBC->fetch($tpl); $result = $this->smartyBC->fetch($tpl);
$this->assertContains("test include php", $result); $this->assertStringContainsString("test include php", $result);
} }
/** /**
@@ -60,7 +60,7 @@ class CompileIncludePhpTest extends PHPUnit_Smarty
$tpl = $this->smartyBC->createTemplate('string:start {include_php file=$filename once=false} end'); $tpl = $this->smartyBC->createTemplate('string:start {include_php file=$filename once=false} end');
$tpl->assign('filename', 'scripts/test_include_php.php'); $tpl->assign('filename', 'scripts/test_include_php.php');
$result = $this->smartyBC->fetch($tpl); $result = $this->smartyBC->fetch($tpl);
$this->assertContains("test include php", $result); $this->assertStringContainsString("test include php", $result);
} }
public function testIncludePhpVariableFileNameShortag() public function testIncludePhpVariableFileNameShortag()
@@ -69,6 +69,6 @@ class CompileIncludePhpTest extends PHPUnit_Smarty
$tpl = $this->smartyBC->createTemplate('string:start {include_php $filename once=false} end'); $tpl = $this->smartyBC->createTemplate('string:start {include_php $filename once=false} end');
$tpl->assign('filename', 'scripts/test_include_php.php'); $tpl->assign('filename', 'scripts/test_include_php.php');
$result = $this->smartyBC->fetch($tpl); $result = $this->smartyBC->fetch($tpl);
$this->assertContains("test include php", $result); $this->assertStringContainsString("test include php", $result);
} }
} }

View File

@@ -15,7 +15,7 @@
*/ */
class CompileInsertTest extends PHPUnit_Smarty class CompileInsertTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/"); $this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/");
@@ -192,7 +192,7 @@ class CompileInsertTest extends PHPUnit_Smarty
$this->smarty->compile_id = 1; $this->smarty->compile_id = 1;
$tpl = $this->smarty->createTemplate('insertplugintest.tpl'); $tpl = $this->smarty->createTemplate('insertplugintest.tpl');
$tpl->assign('foo', 'buh'); $tpl->assign('foo', 'buh');
$this->assertContains('param foo bar globalvar global 2', $this->smarty->fetch($tpl)); $this->assertStringContainsString('param foo bar globalvar global 2', $this->smarty->fetch($tpl));
} }
/** /**
* test insert plugin caching 3 * test insert plugin caching 3
@@ -203,7 +203,7 @@ class CompileInsertTest extends PHPUnit_Smarty
{ {
$this->smarty->caching = true; $this->smarty->caching = true;
$this->smarty->assign('insert',$t=time()); $this->smarty->assign('insert',$t=time());
$this->assertContains($t.'Inner template', $this->smarty->fetch('insertplugintest2.tpl')); $this->assertStringContainsString($t.'Inner template', $this->smarty->fetch('insertplugintest2.tpl'));
} }
/** /**
@@ -216,7 +216,7 @@ class CompileInsertTest extends PHPUnit_Smarty
sleep(2); sleep(2);
$this->smarty->caching = true; $this->smarty->caching = true;
$this->smarty->assign('insert',$t=time()); $this->smarty->assign('insert',$t=time());
$this->assertContains($t.'Inner template', $this->smarty->fetch('insertplugintest2.tpl')); $this->assertStringContainsString($t.'Inner template', $this->smarty->fetch('insertplugintest2.tpl'));
} }
@@ -232,7 +232,7 @@ class CompileInsertTest extends PHPUnit_Smarty
$this->smarty->fetch($tpl); $this->smarty->fetch($tpl);
} }
catch (Exception $e) { catch (Exception $e) {
$this->assertContains("{insert} no function or plugin found for 'mustfail'", $e->getMessage()); $this->assertStringContainsString("{insert} no function or plugin found for 'mustfail'", $e->getMessage());
return; return;
} }
@@ -251,7 +251,7 @@ class CompileInsertTest extends PHPUnit_Smarty
$this->smarty->fetch($tpl); $this->smarty->fetch($tpl);
} }
catch (Exception $e) { catch (Exception $e) {
$this->assertContains('missing script file', $e->getMessage()); $this->assertStringContainsString('missing script file', $e->getMessage());
return; return;
} }

View File

@@ -15,7 +15,7 @@
*/ */
class LiteralTest extends PHPUnit_Smarty class LiteralTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class CompileMakeNocacheTest extends PHPUnit_Smarty class CompileMakeNocacheTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/");

View File

@@ -15,7 +15,7 @@
*/ */
class CompileNocacheTest extends PHPUnit_Smarty class CompileNocacheTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }
@@ -34,13 +34,13 @@ class CompileNocacheTest extends PHPUnit_Smarty
$this->smarty->assign('foo', 0); $this->smarty->assign('foo', 0);
$this->smarty->assign('bar', 'A'); $this->smarty->assign('bar', 'A');
$content = $this->smarty->fetch('test_nocache_tag.tpl'); $content = $this->smarty->fetch('test_nocache_tag.tpl');
$this->assertContains("root 2A", $content); $this->assertStringContainsString("root 2A", $content);
$this->assertContains("include 4A", $content); $this->assertStringContainsString("include 4A", $content);
$this->smarty->assign('foo', 2); $this->smarty->assign('foo', 2);
$this->smarty->assign('bar', 'B'); $this->smarty->assign('bar', 'B');
$content = $this->smarty->fetch('test_nocache_tag.tpl'); $content = $this->smarty->fetch('test_nocache_tag.tpl');
$this->assertContains("root 4B", $content); $this->assertStringContainsString("root 4B", $content);
$this->assertContains("include 6B", $content); $this->assertStringContainsString("include 6B", $content);
} }
/** /**
@@ -52,8 +52,8 @@ class CompileNocacheTest extends PHPUnit_Smarty
$this->smarty->assign('foo', 0); $this->smarty->assign('foo', 0);
$this->smarty->assign('bar', 'A'); $this->smarty->assign('bar', 'A');
$content = $this->smarty->fetch('test_nocache_tag.tpl'); $content = $this->smarty->fetch('test_nocache_tag.tpl');
$this->assertContains("root 2A", $content); $this->assertStringContainsString("root 2A", $content);
$this->assertContains("include 4A", $content); $this->assertStringContainsString("include 4A", $content);
} }
@@ -69,7 +69,7 @@ class CompileNocacheTest extends PHPUnit_Smarty
$this->smarty->assign('foo', 2); $this->smarty->assign('foo', 2);
$this->smarty->assign('bar', 'B'); $this->smarty->assign('bar', 'B');
$content = $this->smarty->fetch('test_nocache_tag.tpl'); $content = $this->smarty->fetch('test_nocache_tag.tpl');
$this->assertContains("root 4A", $content); $this->assertStringContainsString("root 4A", $content);
$this->assertContains("include 6A", $content); $this->assertStringContainsString("include 6A", $content);
} }
} }

View File

@@ -16,7 +16,7 @@
class CompilePhpTest extends PHPUnit_Smarty class CompilePhpTest extends PHPUnit_Smarty
{ {
public $loadSmartyBC = true; public $loadSmartyBC = true;
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
$this->smarty->setUseSubDirs(true); $this->smarty->setUseSubDirs(true);
@@ -79,13 +79,11 @@ class CompilePhpTest extends PHPUnit_Smarty
$content = $tpl->fetch(); $content = $tpl->fetch();
$this->assertEquals($result, $content, $testName); $this->assertEquals($result, $content, $testName);
} }
/**
* @expectedException SmartyCompilerException
* @expectedExceptionMessage $smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it
*/
public function testPHP_ALLOW_error() public function testPHP_ALLOW_error()
{ {
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it');
$this->smarty->setPhpHandling(Smarty::PHP_ALLOW); $this->smarty->setPhpHandling(Smarty::PHP_ALLOW);
$content = $this->smarty->fetch("string:aa <?php echo 'hallo'; ?> ae"); $content = $this->smarty->fetch("string:aa <?php echo 'hallo'; ?> ae");
} }
@@ -112,13 +110,12 @@ class CompilePhpTest extends PHPUnit_Smarty
} }
/** /**
* test {php no cache}illegal option * test {php no cache}illegal option
* @expectedException SmartyCompilerException
* @expectedExceptionMessage illegal value of option flag 'no cache'
*
*/ */
public function testPHP_Tag_IllegalOption() public function testPHP_Tag_IllegalOption()
{ {
$content = $this->smartyBC->fetch("string:aa {php no cache} echo 'hallo'; {/php} ae"); $this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('illegal value of option flag \'no cache\'');
$this->smartyBC->fetch("string:aa {php no cache} echo 'hallo'; {/php} ae");
} }
/** /**

View File

@@ -17,7 +17,7 @@ class PluginBlockTextformatTest extends PHPUnit_Smarty
{ {
protected $string = "\n\nThis is foo.\nThis is foo.\nThis is foo.\nThis is foo.\nThis is foo.\nThis is foo.\n\nThis is bar.\n\nbar foo bar foo foo.\nbar foo bar foo foo.\nbar foo bar foo foo.\nbar foo bar foo foo.\nbar foo bar foo foo.\nbar foo bar foo foo.\nbar foo bar foo foo.\n\n"; protected $string = "\n\nThis is foo.\nThis is foo.\nThis is foo.\nThis is foo.\nThis is foo.\nThis is foo.\n\nThis is bar.\n\nbar foo bar foo foo.\nbar foo bar foo foo.\nbar foo bar foo foo.\nbar foo bar foo foo.\nbar foo bar foo foo.\nbar foo bar foo foo.\nbar foo bar foo foo.\n\n";
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class PluginFunctionFetchTest extends PHPUnit_Smarty class PluginFunctionFetchTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }
@@ -34,52 +34,52 @@ class PluginFunctionFetchTest extends PHPUnit_Smarty
*/ */
public function testFetchUri() public function testFetchUri()
{ {
$this->assertContains('<title>Preface | Smarty</title>', $this->smarty->fetch('string:{fetch file="https://www.smarty.net/docs/en/preface.tpl"}')); $this->assertStringContainsString('<title>Preface | Smarty</title>', $this->smarty->fetch('string:{fetch file="https://www.smarty.net/docs/en/preface.tpl"}'));
} }
/** /**
* test {fetch} invalid uri * test {fetch} invalid uri
* *
* @expectedException SmartyException
* @expectedExceptionMessage {fetch} cannot read resource 'https://foo.smarty.net/foo.dat'
* @runInSeparateProcess * @runInSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
*/ */
public function testFetchInvalidUri() public function testFetchInvalidUri()
{ {
$result = $this->smarty->fetch('string:{fetch file="https://foo.smarty.net/foo.dat"}'); $this->expectException('SmartyException');
$this->expectExceptionMessage('{fetch} cannot read resource \'https://foo.smarty.net/foo.dat\'');
$this->smarty->fetch('string:{fetch file="https://foo.smarty.net/foo.dat"}');
} }
/** /**
* test {fetch file=...} access to file from path not aloo/wed by security settings * test {fetch file=...} access to file from path not aloo/wed by security settings
* *
* @expectedException SmartyException
* @expectedExceptionMessage not trusted file path
* @run InSeparateProcess * @run InSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
*/ */
public function testFetchSecurity() public function testFetchSecurity()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('not trusted file path');
$this->cleanDirs(); $this->cleanDirs();
$dir=$this->smarty->getTemplateDir(); $dir=$this->smarty->getTemplateDir();
$this->smarty->enableSecurity(); $this->smarty->enableSecurity();
$result = $this->smarty->fetch('string:{fetch file=\''. $dir[0]. '../../../../../etc/passwd\'}'); $this->smarty->fetch('string:{fetch file=\''. $dir[0]. '../../../../../etc/passwd\'}');
} }
/** /**
* test {fetch file=...} access to file from path not aloo/wed by security settings * test {fetch file=...} access to file from path not aloo/wed by security settings
* *
* @expectedException SmartyException
* @expectedExceptionMessage not trusted file path
* @run InSeparateProcess * @run InSeparateProcess
* @preserveGlobalState disabled * @preserveGlobalState disabled
*/ */
public function testFetchSecurity2() public function testFetchSecurity2()
{ {
$this->expectException('SmartyException');
$this->expectExceptionMessage('not trusted file path');
$this->cleanDirs(); $this->cleanDirs();
$dir=$this->smarty->getTemplateDir(); $this->smarty->getTemplateDir();
$this->smarty->enableSecurity(); $this->smarty->enableSecurity();
$this->smarty->setTemplateDir('/templates'); $this->smarty->setTemplateDir('/templates');
$result = $this->smarty->fetch('string:{fetch file="/templates/../etc/passwd"}'); $this->smarty->fetch('string:{fetch file="/templates/../etc/passwd"}');
} }
} }

View File

@@ -17,7 +17,7 @@ require_once(dirname(__FILE__) . '/helpers/_object_tostring.php');
*/ */
class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@
*/ */
class PluginFunctionHtmlImageTest extends PHPUnit_Smarty class PluginFunctionHtmlImageTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -17,7 +17,7 @@ require_once(dirname(__FILE__) . '/helpers/_object_tostring.php');
*/ */
class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty class PluginFunctionHtmlOptionsTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -16,7 +16,7 @@ require_once(dirname(__FILE__) . '/helpers/_object_tostring.php');
*/ */
class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty class PluginFunctionHtmlRadiosTest extends PHPUnit_Smarty
{ {
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

Some files were not shown because too many files have changed in this diff Show More