-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/merge smarty-phpunit into tests subfolder (#580)
* Removed unneeded files and replace dummy.txt with .gitignore files * Synced unit tests with master codebase, noted TODO's, fixed phpunit scripts and travis config * fix php7.4 deprecation and remove php7.4 from travis allow_failures since php7.4 is current stable Co-authored-by: Uwe Tews <uwe.tews@googlemail.com> Co-authored-by: Uwe Tews <uwe.tews@gmail.com> Co-authored-by: AnrDaemon <anrdaemon@yandex.ru>
- Loading branch information
1 parent
61e7412
commit 17d4d43
Showing
875 changed files
with
26,924 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,3 @@ utilies/*.php | |
phpunit* | ||
vendor/* | ||
composer.lock | ||
templates_c/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Todo | ||
|
||
## Add unit test for strip issue in correct branch | ||
tests/UnitTests/TemplateSource/TagTests/Strip/CompileStripTest.php | ||
``` | ||
@@ -76,6 +76,7 @@ class CompileStripTest extends PHPUnit_Smarty | ||
array("{'Var'}\n <b></b> <c></c>", 'Var<b></b> <c></c>', '', $i ++), | ||
array("\n<b></b> <c></c>", '<b></b> <c></c>', '', $i ++), | ||
array("\n<b></b>\n <c></c>", '<b></b><c></c>', '', $i ++), | ||
+ array("\n<b>\n {* a comment *}\n <c>", '<b><c>', '', $i ++), | ||
); | ||
} | ||
``` | ||
|
||
## Add unit test for isset issue in correct branch | ||
tests/UnitTests/TemplateSource/ValueTests/PHPfunctions/PhpFunctionTest.php | ||
```php | ||
/** | ||
* test PHP isset() on (non-)variables | ||
* @dataProvider dataTestIsset3 | ||
* @param string $strTemplate template to test | ||
* @param string $result expected result | ||
*/ | ||
public function testIsset3($strTemplate, $result) | ||
{ | ||
$this->smarty->disableSecurity(); | ||
|
||
$this->smarty->assign('varobject', new TestIsset()); | ||
$this->smarty->assign('vararray', $vararray = [ | ||
'keythatexists' => false, | ||
'keywitharray' => [1 => 1], | ||
'keywithobject' => new TestIsset()] | ||
); | ||
|
||
$this->smarty->assign('key', 'A'); | ||
$this->smarty->assign('_varsimpleA', 1); | ||
$this->smarty->assign('varsimpleB', 0); | ||
$this->smarty->assign('varsimpleC', null); | ||
|
||
$this->assertEquals($result, $this->smarty->fetch('string:' . $strTemplate)); | ||
} | ||
|
||
/** | ||
* Data provider for testIsset3 | ||
*/ | ||
public function dataTestIsset3() | ||
{ | ||
return array( | ||
array('{if isset($varobject->arr)}true{else}false{/if}', 'true'), | ||
array('{if isset($vararray["keywitharray"])}true{else}false{/if}', 'true'), | ||
array('{if isset($vararray["keythatexists"])}true{else}false{/if}', 'true'), | ||
array('{if isset($vararray["nonexistingkey"])}true{else}false{/if}', 'false'), | ||
array('{if isset($_GET["sscr6hr6cz34j6"])}true{else}false{/if}', 'false'), | ||
array('{if isset(count([\'hi\']))}true{else}false{/if}', 'true'), | ||
array('{if isset($vararray[\'keywitharray\'][intval(\'1\')])}true{else}false{/if}', 'true'), | ||
array('{if isset($vararray[\'keywithobject\']->arr[\'isSet\'])}true{else}false{/if}', 'true'), | ||
array('{if isset($vararray[\'keywithobject\']->arr[\'isNull\'])}true{else}false{/if}', 'false'), | ||
array('{if isset($varobject->arr[\'isSet\'])}true{else}false{/if}', 'true'), | ||
array('{if isset($varobject->arr[\'isNull\'])}true{else}false{/if}', 'false'), | ||
array('{if isset($_varsimpleA)}true{else}false{/if}', 'true'), | ||
array('{if isset($varsimpleB)}true{else}false{/if}', 'true'), | ||
array('{if isset($varsimpleC)}true{else}false{/if}', 'false'), | ||
array('{if isset($_varsimpleA && varsimpleB)}true{else}false{/if}', 'true'), | ||
array('{if isset($_varsimpleA && varsimpleC)}true{else}false{/if}', 'true'), | ||
array('{if isset($_varsimple{$key})}true{else}false{/if}', 'true'), | ||
); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#! /bin/bash | ||
vendor/phpunit/phpunit/phpunit tests/UnitTests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd" | ||
bootstrap="tests/Bootstrap.php" | ||
colors="true" | ||
backupGlobals="false" | ||
backupStaticAttributes="true" | ||
forceCoversAnnotation="false" | ||
mapTestClassNameToCoveredClassName="false" | ||
processIsolation="false" | ||
stopOnError="false" | ||
stopOnFailure="false" | ||
stopOnIncomplete="false" | ||
stopOnSkipped="false" | ||
stopOnRisky="false" | ||
timeoutForSmallTests="1" | ||
timeoutForMediumTests="10" | ||
timeoutForLargeTests="60" | ||
verbose="false"> | ||
|
||
<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"> | ||
<directory suffix=".php">libs</directory> | ||
<directory suffix=".php">libs/plugins</directory> | ||
<directory suffix=".php">libs/sysplugins</directory> | ||
<directory suffix=".php">demo/plugins</directory> | ||
</whitelist> | ||
</filter> | ||
<logging> | ||
<log type="tap" target="tests/TestResults.tap"/> | ||
</logging> | ||
|
||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.idea | ||
|
||
# Unit test / coverage reports | ||
.coverage | ||
.tox | ||
|
||
#Smarty | ||
testdox.html | ||
TestResults.tap | ||
TestResults.txt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/* | ||
* This file is part of the Smarty PHPUnit tests. | ||
* | ||
*/ | ||
/* | ||
* Smarty PHPUnit Bootstrap | ||
*/ | ||
require_once dirname(__FILE__) . '/Config.php'; | ||
require_once dirname(__FILE__) . '/../vendor/autoload.php'; | ||
require_once dirname(__FILE__) . '/../libs/bootstrap.php'; | ||
|
||
if (!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) { | ||
class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase'); | ||
class_alias('\PHPUnit\Framework\Error\Notice', '\PHPUnit_Framework_Error_Notice'); | ||
class_alias('\PHPUnit\Framework\Error\Error', '\PHPUnit_Framework_Error_Error'); | ||
class_alias('\PHPUnit\Framework\Error\Warning', '\PHPUnit_Framework_Error_Warning'); | ||
class_alias('\PHPUnit\Framework\Error\Warning', '\PHPUnit_Framework_Error_Deprecated'); | ||
class_alias('\PHPUnit\Util\Configuration', '\PHPUnit_Util_Configuration'); | ||
} | ||
|
||
require_once 'PHPUnit_Smarty.php'; | ||
if (!ini_get('date.timezone')) { | ||
ini_set('date.timezone', 'Europe/Berlin'); | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/* | ||
* This file is part of the Smarty PHPUnit tests. | ||
* | ||
*/ | ||
/* | ||
* Smarty PHPUnit Config | ||
*/ | ||
define('individualFolders', true); | ||
define('MemCacheEnable', false); | ||
define('ApcCacheEnable', false); | ||
define('MysqlCacheEnable', false); | ||
define('PdoCacheEnable', false); | ||
define('PdoGzipCacheEnable', false); | ||
define('MysqlResourceEnable', false); | ||
define('DB_DSN', "mysql:dbname=test;host=localhost"); | ||
define('DB_USER', "travis"); | ||
define('DB_PASSWD', ""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
function smarty_function_plugin1($params, $template) | ||
{ | ||
return 'plugin1'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
function smarty_function_plugin2($params, $template) | ||
{ | ||
return 'plugin2'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include_test2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include_test4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{include 'include_test4.tpl'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include path root |
Oops, something went wrong.