mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-01 17:04:26 +02:00
synced unit tests with master codebase, noted TODO's, fixed phpunit scripts and travis config
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,4 +11,3 @@ utilies/*.php
|
||||
phpunit*
|
||||
vendor/*
|
||||
composer.lock
|
||||
templates_c/*
|
||||
|
@@ -30,8 +30,6 @@ before_install:
|
||||
|
||||
install:
|
||||
- travis_retry composer install
|
||||
- git clone --depth=50 --branch=master git://github.com/smarty-php/smarty-phpunit.git
|
||||
|
||||
script:
|
||||
- cd smarty-phpunit
|
||||
- ../vendor/bin/phpunit ./
|
||||
- ./phpunit.sh
|
||||
|
69
TODO.md
Normal file
69
TODO.md
Normal file
@@ -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'),
|
||||
);
|
||||
}
|
||||
```
|
3
phpunit.sh
Normal file → Executable file
3
phpunit.sh
Normal file → Executable file
@@ -1,3 +1,2 @@
|
||||
#! /bin/bash
|
||||
|
||||
php ../../phpunit/phpunit/phpunit ./
|
||||
vendor/phpunit/phpunit/phpunit tests/UnitTests
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
|
||||
bootstrap="Bootstrap.php"
|
||||
bootstrap="tests/Bootstrap.php"
|
||||
colors="true"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="true"
|
||||
@@ -21,23 +21,23 @@
|
||||
<filter>
|
||||
<testsuites>
|
||||
<testsuite name="Smarty Test Suite">
|
||||
<directory>UnitTests</directory>
|
||||
<directory>tests/UnitTests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<blacklist>
|
||||
<directory suffix=".php">./</directory>
|
||||
<directory suffix=".php">cache</directory>
|
||||
<directory suffix=".php">templates_c</directory>
|
||||
<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">../smarty/libs</directory>
|
||||
<directory suffix=".php">../smarty/libs/plugins</directory>
|
||||
<directory suffix=".php">../smarty/libs/sysplugins</directory>
|
||||
<directory suffix=".php">../smarty/demo/plugins</directory>
|
||||
<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="TestResults.tap"/>
|
||||
<log type="tap" target="tests/TestResults.tap"/>
|
||||
</logging>
|
||||
|
||||
</phpunit>
|
@@ -6,30 +6,9 @@
|
||||
/*
|
||||
* Smarty PHPUnit Bootstrap
|
||||
*/
|
||||
include_once dirname(__FILE__) . '/Config.php';
|
||||
if (!class_exists('Smarty_Autoloader')) {
|
||||
if (is_file(dirname(__FILE__) . '/../smarty/libs/bootstrap.php')) {
|
||||
require_once dirname(__FILE__) . '/../smarty/libs/bootstrap.php';
|
||||
} elseif (is_file(dirname(__FILE__) . '/../libs/bootstrap.php')) {
|
||||
require_once dirname(__FILE__) . '/../libs/bootstrap.php';
|
||||
} else {
|
||||
throw new Exception('can not locate Smarty distribution');
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined('SMARTY_COMPOSER_INSTALL')) {
|
||||
foreach (array(dirname(__FILE__) . '/../../autoload.php', dirname(__FILE__) . '/../vendor/autoload.php',
|
||||
dirname(__FILE__) . '/vendor/autoload.php') as $file) {
|
||||
if (file_exists($file)) {
|
||||
define('SMARTY_COMPOSER_INSTALL', $file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($file);
|
||||
}
|
||||
if (!class_exists('PHPUnit_Framework_TestCase') && !class_exists('\PHPUnit\Framework\TestCase')){
|
||||
require_once SMARTY_COMPOSER_INSTALL;
|
||||
}
|
||||
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');
|
||||
|
@@ -1,2 +1,2 @@
|
||||
dummy# Ignore anything in here, but keep this directory
|
||||
*
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
|
@@ -156,57 +156,6 @@ class PhpFunctionTest extends PHPUnit_Smarty
|
||||
,{if isset($var->pass(1))} true {else} false {/IF}
|
||||
'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user