Replace Smarty:: with symfony/polyfill-mbstring

This commit is contained in:
Simon Wisselink
2022-12-01 21:56:12 +01:00
parent 9a0d46f1bc
commit d0319bdc87
37 changed files with 79 additions and 902 deletions

View File

@@ -30,12 +30,13 @@
"forum": "https://github.com/smarty-php/smarty/discussions"
},
"require": {
"php": "^7.1 || ^8.0"
"php": "^7.1 || ^8.0",
"symfony/polyfill-mbstring": "^1.27"
},
"autoload": {
"classmap": [
"libs/"
]
"psr-4" : {
"Smarty\\" : "src/"
}
},
"extra": {
"branch-alias": {

View File

@@ -6,9 +6,7 @@ Charset Encoding {#charset.encoding}
There are a variety of encodings for textual data, ISO-8859-1 (Latin1)
and UTF-8 being the most popular. Unless you change `\Smarty\Smarty::$_CHARSET`,
Smarty recognizes `UTF-8` as the internal charset if
[Multibyte String](https://www.php.net/mbstring) is available,
`ISO-8859-1` if not.
Smarty recognizes `UTF-8` as the internal charset.
> **Note**
>
@@ -26,10 +24,7 @@ Smarty recognizes `UTF-8` as the internal charset if
> **Note**
>
> Smarty\'s internals and core plugins are truly UTF-8 compatible since
> Smarty 3.1. To achieve unicode compatibility, the [Multibyte
> String](https://www.php.net/mbstring) PECL is required. Unless your PHP
> environment offers this package, Smarty will not be able to offer
> full-scale UTF-8 compatibility.
> Smarty 3.1.
// use japanese character encoding

View File

@@ -92,11 +92,7 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
$_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph;
}
// wordwrap sentences
if (\Smarty\Smarty::$_MBSTRING) {
$_paragraph = smarty_modifier_mb_wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
} else {
$_paragraph = wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
}
$_paragraph = smarty_modifier_mb_wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
// indent lines
if ($indent > 0) {
$_paragraph = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraph);

View File

@@ -24,57 +24,17 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
{
$string = (string) $string;
if (\Smarty\Smarty::$_MBSTRING) {
if ($lc_rest) {
// uppercase (including hyphenated words)
$upper_string = mb_convert_case($string, MB_CASE_TITLE, \Smarty\Smarty::$_CHARSET);
} else {
// uppercase word breaks
$upper_string = preg_replace_callback(
"!(^|[^\p{L}'])([\p{Ll}])!S" . \Smarty\Smarty::$_UTF8_MODIFIER,
'smarty_mod_cap_mbconvert_cb',
$string
);
}
// check uc_digits case
if (!$uc_digits) {
if (preg_match_all(
"!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . \Smarty\Smarty::$_UTF8_MODIFIER,
$string,
$matches,
PREG_OFFSET_CAPTURE
)
) {
foreach ($matches[ 1 ] as $match) {
$upper_string =
substr_replace(
$upper_string,
mb_strtolower($match[ 0 ], \Smarty\Smarty::$_CHARSET),
$match[ 1 ],
strlen($match[ 0 ])
);
}
}
}
$upper_string =
preg_replace_callback(
"!((^|\s)['\"])(\w)!" . \Smarty\Smarty::$_UTF8_MODIFIER,
'smarty_mod_cap_mbconvert2_cb',
$upper_string
);
return $upper_string;
}
// lowercase first
if ($lc_rest) {
$string = strtolower($string);
}
// uppercase (including hyphenated words)
$upper_string =
preg_replace_callback(
// uppercase (including hyphenated words)
$upper_string = mb_convert_case($string, MB_CASE_TITLE, \Smarty\Smarty::$_CHARSET);
} else {
// uppercase word breaks
$upper_string = preg_replace_callback(
"!(^|[^\p{L}'])([\p{Ll}])!S" . \Smarty\Smarty::$_UTF8_MODIFIER,
'smarty_mod_cap_ucfirst_cb',
'smarty_mod_cap_mbconvert_cb',
$string
);
}
// check uc_digits case
if (!$uc_digits) {
if (preg_match_all(
@@ -86,15 +46,21 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
) {
foreach ($matches[ 1 ] as $match) {
$upper_string =
substr_replace($upper_string, strtolower($match[ 0 ]), $match[ 1 ], strlen($match[ 0 ]));
substr_replace(
$upper_string,
mb_strtolower($match[ 0 ], \Smarty\Smarty::$_CHARSET),
$match[ 1 ],
strlen($match[ 0 ])
);
}
}
}
$upper_string = preg_replace_callback(
"!((^|\s)['\"])(\w)!" . \Smarty\Smarty::$_UTF8_MODIFIER,
'smarty_mod_cap_ucfirst2_cb',
$upper_string
);
$upper_string =
preg_replace_callback(
"!((^|\s)['\"])(\w)!" . \Smarty\Smarty::$_UTF8_MODIFIER,
'smarty_mod_cap_mbconvert2_cb',
$upper_string
);
return $upper_string;
}

View File

@@ -74,28 +74,16 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
break;
case 'string':
$results = strtr($var, $_replace);
if (\Smarty\Smarty::$_MBSTRING) {
if (mb_strlen($var, \Smarty\Smarty::$_CHARSET) > $length) {
$results = mb_substr($var, 0, $length - 3, \Smarty\Smarty::$_CHARSET) . '...';
}
} else {
if (isset($var[ $length ])) {
$results = substr($var, 0, $length - 3) . '...';
}
if (mb_strlen($var, \Smarty\Smarty::$_CHARSET) > $length) {
$results = mb_substr($var, 0, $length - 3, \Smarty\Smarty::$_CHARSET) . '...';
}
$results = htmlspecialchars('"' . $results . '"', ENT_QUOTES, \Smarty\Smarty::$_CHARSET);
break;
case 'unknown type':
default:
$results = strtr((string)$var, $_replace);
if (\Smarty\Smarty::$_MBSTRING) {
if (mb_strlen($results, \Smarty\Smarty::$_CHARSET) > $length) {
$results = mb_substr($results, 0, $length - 3, \Smarty\Smarty::$_CHARSET) . '...';
}
} else {
if (strlen($results) > $length) {
$results = substr($results, 0, $length - 3) . '...';
}
if (mb_strlen($results, \Smarty\Smarty::$_CHARSET) > $length) {
$results = mb_substr($results, 0, $length - 3, \Smarty\Smarty::$_CHARSET) . '...';
}
$results = htmlspecialchars($results, ENT_QUOTES, \Smarty\Smarty::$_CHARSET);
}

View File

@@ -34,12 +34,8 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
// no break
case 'htmlall':
if (\Smarty\Smarty::$_MBSTRING) {
$string = mb_convert_encoding($string, 'UTF-8', $char_set);
return htmlentities($string, ENT_QUOTES, 'UTF-8', $double_encode);
}
// no MBString fallback
return htmlentities($string, ENT_QUOTES, $char_set, $double_encode);
$string = mb_convert_encoding($string, 'UTF-8', $char_set);
return htmlentities($string, ENT_QUOTES, 'UTF-8', $double_encode);
// no break
case 'url':
return rawurlencode($string);
@@ -59,32 +55,14 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
return $return;
case 'hexentity':
$return = '';
if (\Smarty\Smarty::$_MBSTRING) {
$return = '';
foreach (smarty_mb_to_unicode($string, \Smarty\Smarty::$_CHARSET) as $unicode) {
$return .= '&#x' . strtoupper(dechex($unicode)) . ';';
}
return $return;
}
// no MBString fallback
$_length = strlen($string);
for ($x = 0; $x < $_length; $x++) {
$return .= '&#x' . bin2hex($string[ $x ]) . ';';
foreach (smarty_mb_to_unicode($string, \Smarty\Smarty::$_CHARSET) as $unicode) {
$return .= '&#x' . strtoupper(dechex($unicode)) . ';';
}
return $return;
case 'decentity':
$return = '';
if (\Smarty\Smarty::$_MBSTRING) {
$return = '';
foreach (smarty_mb_to_unicode($string, \Smarty\Smarty::$_CHARSET) as $unicode) {
$return .= '&#' . $unicode . ';';
}
return $return;
}
// no MBString fallback
$_length = strlen($string);
for ($x = 0; $x < $_length; $x++) {
$return .= '&#' . ord($string[ $x ]) . ';';
foreach (smarty_mb_to_unicode($string, \Smarty\Smarty::$_CHARSET) as $unicode) {
$return .= '&#' . $unicode . ';';
}
return $return;
case 'javascript':
@@ -105,21 +83,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
)
);
case 'mail':
if (\Smarty\Smarty::$_MBSTRING) {
return smarty_mb_str_replace(
array(
'@',
'.'
),
array(
' [AT] ',
' [DOT] '
),
$string
);
}
// no MBString fallback
return str_replace(
return smarty_mb_str_replace(
array(
'@',
'.'
@@ -133,24 +97,11 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
case 'nonstd':
// escape non-standard chars, such as ms document quotes
$return = '';
if (\Smarty\Smarty::$_MBSTRING) {
foreach (smarty_mb_to_unicode($string, \Smarty\Smarty::$_CHARSET) as $unicode) {
if ($unicode >= 126) {
$return .= '&#' . $unicode . ';';
} else {
$return .= chr($unicode);
}
}
return $return;
}
$_length = strlen($string);
for ($_i = 0; $_i < $_length; $_i++) {
$_ord = ord(substr($string, $_i, 1));
// non-standard char, escape it
if ($_ord >= 126) {
$return .= '&#' . $_ord . ';';
foreach (smarty_mb_to_unicode($string, \Smarty\Smarty::$_CHARSET) as $unicode) {
if ($unicode >= 126) {
$return .= '&#' . $unicode . ';';
} else {
$return .= substr($string, $_i, 1);
$return .= chr($unicode);
}
}
return $return;

View File

@@ -23,8 +23,5 @@
*/
function smarty_modifier_replace($string, $search, $replace)
{
if (\Smarty\Smarty::$_MBSTRING) {
return smarty_mb_str_replace($search, $replace, $string);
}
return str_replace($search, $replace, $string);
return smarty_mb_str_replace($search, $replace, $string);
}

View File

@@ -29,34 +29,20 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
if ($length === 0) {
return '';
}
if (\Smarty\Smarty::$_MBSTRING) {
if (mb_strlen($string, \Smarty\Smarty::$_CHARSET) > $length) {
$length -= min($length, mb_strlen($etc, \Smarty\Smarty::$_CHARSET));
if (!$break_words && !$middle) {
$string = preg_replace(
'/\s+?(\S+)?$/' . \Smarty\Smarty::$_UTF8_MODIFIER,
'',
mb_substr($string, 0, $length + 1, \Smarty\Smarty::$_CHARSET)
);
}
if (!$middle) {
return mb_substr($string, 0, $length, \Smarty\Smarty::$_CHARSET) . $etc;
}
return mb_substr($string, 0, intval($length / 2), \Smarty\Smarty::$_CHARSET) . $etc .
mb_substr($string, -intval($length / 2), $length, \Smarty\Smarty::$_CHARSET);
}
return $string;
}
// no MBString fallback
if (isset($string[ $length ])) {
$length -= min($length, strlen($etc));
if (mb_strlen($string, \Smarty\Smarty::$_CHARSET) > $length) {
$length -= min($length, mb_strlen($etc, \Smarty\Smarty::$_CHARSET));
if (!$break_words && !$middle) {
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1));
$string = preg_replace(
'/\s+?(\S+)?$/' . \Smarty\Smarty::$_UTF8_MODIFIER,
'',
mb_substr($string, 0, $length + 1, \Smarty\Smarty::$_CHARSET)
);
}
if (!$middle) {
return substr($string, 0, $length) . $etc;
return mb_substr($string, 0, $length, \Smarty\Smarty::$_CHARSET) . $etc;
}
return substr($string, 0, intval($length / 2)) . $etc . substr($string, -intval($length / 2));
return mb_substr($string, 0, intval($length / 2), \Smarty\Smarty::$_CHARSET) . $etc .
mb_substr($string, -intval($length / 2), $length, \Smarty\Smarty::$_CHARSET);
}
return $string;
}

View File

@@ -24,9 +24,5 @@ function smarty_modifiercompiler_count_characters($params)
if (!isset($params[ 1 ]) || $params[ 1 ] !== 'true') {
return 'preg_match_all(\'/[^\s]/' . \Smarty\Smarty::$_UTF8_MODIFIER . '\',' . $params[ 0 ] . ', $tmp)';
}
if (\Smarty\Smarty::$_MBSTRING) {
return 'mb_strlen(' . $params[ 0 ] . ', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')';
}
// no MBString fallback
return 'strlen(' . $params[ 0 ] . ')';
return 'mb_strlen(' . $params[ 0 ] . ', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')';
}

View File

@@ -20,11 +20,7 @@
*/
function smarty_modifiercompiler_count_words($params)
{
if (\Smarty\Smarty::$_MBSTRING) {
// expression taken from http://de.php.net/manual/en/function.str-word-count.php#85592
return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . \Smarty\Smarty::$_UTF8_MODIFIER . '\', ' .
$params[ 0 ] . ', $tmp)';
}
// no MBString fallback
return 'str_word_count(' . $params[ 0 ] . ')';
// expression taken from http://de.php.net/manual/en/function.str-word-count.php#85592
return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . \Smarty\Smarty::$_UTF8_MODIFIER . '\', ' .
$params[ 0 ] . ', $tmp)';
}

View File

@@ -35,13 +35,8 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
var_export($double_encode, true) . ')';
// no break
case 'htmlall':
if (\Smarty\Smarty::$_MBSTRING) {
return 'htmlentities(mb_convert_encoding((string)' . $params[ 0 ] . ', \'UTF-8\', ' .
var_export($char_set, true) . '), ENT_QUOTES, \'UTF-8\', ' .
var_export($double_encode, true) . ')';
}
// no MBString fallback
return 'htmlentities((string)' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
return 'htmlentities(mb_convert_encoding((string)' . $params[ 0 ] . ', \'UTF-8\', ' .
var_export($char_set, true) . '), ENT_QUOTES, \'UTF-8\', ' .
var_export($double_encode, true) . ')';
// no break
case 'url':

View File

@@ -19,10 +19,6 @@
*/
function smarty_modifiercompiler_from_charset($params)
{
if (!\Smarty\Smarty::$_MBSTRING) {
// FIXME: (rodneyrehm) shouldn't this throw an error?
return $params[ 0 ];
}
if (!isset($params[ 1 ])) {
$params[ 1 ] = '"ISO-8859-1"';
}

View File

@@ -21,9 +21,5 @@
*/
function smarty_modifiercompiler_lower($params)
{
if (\Smarty\Smarty::$_MBSTRING) {
return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')';
}
// no MBString fallback
return 'strtolower(' . $params[ 0 ] . ')';
return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')';
}

View File

@@ -19,10 +19,6 @@
*/
function smarty_modifiercompiler_to_charset($params)
{
if (!\Smarty\Smarty::$_MBSTRING) {
// FIXME: (rodneyrehm) shouldn't this throw an error?
return $params[ 0 ];
}
if (!isset($params[ 1 ])) {
$params[ 1 ] = '"ISO-8859-1"';
}

View File

@@ -29,10 +29,7 @@ function smarty_modifiercompiler_unescape($params, Smarty_Internal_TemplateCompi
switch ($esc_type) {
case 'entity':
case 'htmlall':
if (\Smarty\Smarty::$_MBSTRING) {
return 'html_entity_decode(mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'UTF-8\'), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' . $params[ 2 ] . ')';
}
return 'html_entity_decode(' . $params[ 0 ] . ', ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' . $params[ 2 ] . ')';
return 'html_entity_decode(mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'UTF-8\'), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' . $params[ 2 ] . ')';
case 'html':
return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)';
case 'url':

View File

@@ -20,9 +20,5 @@
*/
function smarty_modifiercompiler_upper($params)
{
if (\Smarty\Smarty::$_MBSTRING) {
return 'mb_strtoupper(' . $params[ 0 ] . ' ?? \'\', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')';
}
// no MBString fallback
return 'strtoupper(' . $params[ 0 ] . ' ?? \'\')';
return 'mb_strtoupper(' . $params[ 0 ] . ' ?? \'\', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')';
}

View File

@@ -31,9 +31,6 @@ function smarty_modifiercompiler_wordwrap($params, Smarty_Internal_TemplateCompi
if (!isset($params[ 3 ])) {
$params[ 3 ] = 'false';
}
$function = 'wordwrap';
if (\Smarty\Smarty::$_MBSTRING) {
$function = $compiler->getPlugin('mb_wordwrap', 'modifier');
}
$function = $compiler->getPlugin('mb_wordwrap', 'modifier');
return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')';
}

View File

@@ -20,15 +20,9 @@ namespace Smarty\Resource;
*/
class Extending extends Base
{
/**
* mbstring.overload flag
*
* @var int
*/
public $mbstring_overload = 0;
/**
* populate Source Object with meta data from Resource
* populate Source Object with metadata from Resource
*
* @param \Smarty_Template_Source $source source object
* @param \Smarty_Internal_Template $_template template object

View File

@@ -32,13 +32,6 @@ namespace Smarty;
* @package Smarty
*/
if (!defined('SMARTY_MBSTRING')) {
/**
*
*/
define('SMARTY_MBSTRING', function_exists('mb_get_info'));
}
/**
* This is the main Smarty class
*
@@ -105,14 +98,9 @@ class Smarty extends \Smarty_Internal_TemplateBase
public static $global_tpl_vars = array();
/**
* Flag denoting if Multibyte String functions are available
* The character set to adhere to (defaults to "UTF-8")
*/
public static $_MBSTRING = SMARTY_MBSTRING;
/**
* The character set to adhere to (e.g. "UTF-8")
*/
public static $_CHARSET = SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1';
public static $_CHARSET = 'UTF-8';
/**
* The date format to be used internally

View File

@@ -1,7 +1,9 @@
<?php
// compiler.test.php
class smarty_compiler_test extends Smarty_Internal_CompileBase
use Smarty\Compile\Base;
class smarty_compiler_test extends Base
{
public function compile($args, $compiler)
{
@@ -16,7 +18,7 @@ class smarty_compiler_test extends Smarty_Internal_CompileBase
}
// compiler.testclose.php
class smarty_compiler_testclose extends Smarty_Internal_CompileBase
class smarty_compiler_testclose extends Base
{
public function compile($args, $compiler)
{

View File

@@ -1,7 +1,9 @@
<?php
// compiler.testclose.php
class smarty_compiler_testclose extends Smarty_Internal_CompileBase
use Smarty\Compile\Base;
class smarty_compiler_testclose extends Base
{
public function execute($args, $compiler)
{

View File

@@ -29,15 +29,6 @@ class PluginBlockTextformatTest extends PHPUnit_Smarty
$this->assertEquals($result, $this->smarty->fetch($tpl));
}
public function testDefaultWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$result = "This is foo. This is foo. This is foo.\nThis is foo. This is foo. This is foo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo\nfoo. bar foo bar foo foo. bar foo bar\nfoo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo.\n\n";
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40}' . $this->string . '{/textformat}');
$this->assertEquals($result, $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testIndent()
{
$result = " This is foo. This is foo. This is\n foo. This is foo. This is foo. This\n is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo. bar foo bar foo foo.\n bar foo bar foo foo. bar foo bar foo\n foo.\n\n";
@@ -45,15 +36,6 @@ class PluginBlockTextformatTest extends PHPUnit_Smarty
$this->assertEquals($result, $this->smarty->fetch($tpl));
}
public function testIndentWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$result = " This is foo. This is foo. This is\n foo. This is foo. This is foo. This\n is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo. bar foo bar foo foo.\n bar foo bar foo foo. bar foo bar foo\n foo.\n\n";
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4}' . $this->string . '{/textformat}');
$this->assertEquals($result, $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testIndentFirst()
{
$result = " This is foo. This is foo. This\n is foo. This is foo. This is foo.\n This is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar\n foo foo. bar foo bar foo foo. bar\n foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo.\n\n";
@@ -61,15 +43,6 @@ class PluginBlockTextformatTest extends PHPUnit_Smarty
$this->assertEquals($result, $this->smarty->fetch($tpl));
}
public function testIndentFirstWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$result = " This is foo. This is foo. This\n is foo. This is foo. This is foo.\n This is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar\n foo foo. bar foo bar foo foo. bar\n foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo.\n\n";
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_first=4}' . $this->string . '{/textformat}');
$this->assertEquals($result, $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testIndentchar()
{
$result = "####This is foo. This is foo. This is\n####foo. This is foo. This is foo. This\n####is foo.\n\n####This is bar.\n\n####bar foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo. bar foo bar foo foo.\n####bar foo bar foo foo. bar foo bar foo\n####foo.\n\n";
@@ -77,15 +50,6 @@ class PluginBlockTextformatTest extends PHPUnit_Smarty
$this->assertEquals($result, $this->smarty->fetch($tpl));
}
public function testIndentcharWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$result = "####This is foo. This is foo. This is\n####foo. This is foo. This is foo. This\n####is foo.\n\n####This is bar.\n\n####bar foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo. bar foo bar foo foo.\n####bar foo bar foo foo. bar foo bar foo\n####foo.\n\n";
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_char="#"}' . $this->string . '{/textformat}');
$this->assertEquals($result, $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testIndentcharFirst()
{
$result = "########This is foo. This is foo. This\n####is foo. This is foo. This is foo.\n####This is foo.\n\n########This is bar.\n\n########bar foo bar foo foo. bar foo bar\n####foo foo. bar foo bar foo foo. bar\n####foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo.\n\n";
@@ -93,15 +57,6 @@ class PluginBlockTextformatTest extends PHPUnit_Smarty
$this->assertEquals($result, $this->smarty->fetch($tpl));
}
public function testIndentcharFirstWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$result = "########This is foo. This is foo. This\n####is foo. This is foo. This is foo.\n####This is foo.\n\n########This is bar.\n\n########bar foo bar foo foo. bar foo bar\n####foo foo. bar foo bar foo foo. bar\n####foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo.\n\n";
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_first=4 indent_char="#"}' . $this->string . '{/textformat}');
$this->assertEquals($result, $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testWrapchar()
{
$result = " This is foo. This is foo. This is#foo. This is foo. This is foo. This#is foo.## This is bar.## bar foo bar foo foo. bar foo bar foo#foo. bar foo bar foo foo. bar foo#bar foo foo. bar foo bar foo foo.#bar foo bar foo foo. bar foo bar foo#foo.##";
@@ -109,15 +64,6 @@ class PluginBlockTextformatTest extends PHPUnit_Smarty
$this->assertEquals($result, $this->smarty->fetch($tpl));
}
public function testWrapcharWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$result = " This is foo. This is foo. This is#foo. This is foo. This is foo. This#is foo.## This is bar.## bar foo bar foo foo. bar foo bar foo#foo. bar foo bar foo foo. bar foo#bar foo foo. bar foo bar foo foo.#bar foo bar foo foo. bar foo bar foo#foo.##";
$tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 wrap_char="#"}' . $this->string . '{/textformat}');
$this->assertEquals($result, $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testStyleEmail()
{
$result = "This is foo. This is foo. This is foo. This is foo. This is foo. This is\nfoo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo\nfoo.\n\n";
@@ -125,12 +71,4 @@ class PluginBlockTextformatTest extends PHPUnit_Smarty
$this->assertEquals($result, $this->smarty->fetch($tpl));
}
public function testStyleEmailWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$result = "This is foo. This is foo. This is foo. This is foo. This is foo. This is\nfoo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo\nfoo.\n\n";
$tpl = $this->smarty->createTemplate('string:{textformat style="email"}' . $this->string . '{/textformat}');
$this->assertEquals($result, $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
}

View File

@@ -27,15 +27,6 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testDefaultWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$result = '<a href="mailto:me@example.com" >me@example.com</a>';
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com"}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testText()
{
$result = '<a href="mailto:me@example.com" >send me some mail</a>';
@@ -43,15 +34,6 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testTextWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$result = '<a href="mailto:me@example.com" >send me some mail</a>';
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" text="send me some mail"}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testEncodeJavascript()
{
$result = '<script type="text/javascript">document.write(unescape(\'%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%22%20%3e%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%3c%2f%61%3e\'))</script>';
@@ -59,15 +41,6 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testEncodeJavascriptWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$result = '<script type="text/javascript">document.write(unescape(\'%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%22%20%3e%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%3c%2f%61%3e\'))</script>';
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript"}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testEncodeJavascriptCharcode()
{
$result = '<script type="text/javascript">document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,109,101,64,101,120,97,109,112,108,101,46,99,111,109,34,32,62,109,101,64,101,120,97,109,112,108,101,46,99,111,109,60,47,97,62))</script>';
@@ -75,15 +48,6 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testEncodeJavascriptCharcodeWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$result = '<script type="text/javascript">document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,109,101,64,101,120,97,109,112,108,101,46,99,111,109,34,32,62,109,101,64,101,120,97,109,112,108,101,46,99,111,109,60,47,97,62))</script>';
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript_charcode"}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testEncodeHex()
{
$result = '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6d%65@%65%78%61%6d%70%6c%65.%63%6f%6d" >&#x6d;&#x65;&#x40;&#x65;&#x78;&#x61;&#x6d;&#x70;&#x6c;&#x65;&#x2e;&#x63;&#x6f;&#x6d;</a>';
@@ -91,15 +55,6 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testEncodeHexWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$result = '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;%6d%65@%65%78%61%6d%70%6c%65.%63%6f%6d" >&#x6d;&#x65;&#x40;&#x65;&#x78;&#x61;&#x6d;&#x70;&#x6c;&#x65;&#x2e;&#x63;&#x6f;&#x6d;</a>';
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="hex"}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testSubject()
{
$result = '<a href="mailto:me@example.com?subject=Hello%20to%20you%21" >me@example.com</a>';
@@ -107,15 +62,6 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testSubjectWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$result = '<a href="mailto:me@example.com?subject=Hello%20to%20you%21" >me@example.com</a>';
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" subject="Hello to you!"}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testCc()
{
$result = '<a href="mailto:me@example.com?cc=you@example.com,they@example.com" >me@example.com</a>';
@@ -123,15 +69,6 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testCcWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$result = '<a href="mailto:me@example.com?cc=you@example.com,they@example.com" >me@example.com</a>';
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" cc="you@example.com,they@example.com"}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testExtra()
{
$result = '<a href="mailto:me@example.com" class="email">me@example.com</a>';
@@ -139,15 +76,6 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testExtraWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$result = '<a href="mailto:me@example.com" class="email">me@example.com</a>';
$tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" extra=\'class="email"\'}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testUmlauts()
{
$result = '<a href="mailto:me+smtpext@example.com?cc=you@example.com,they@example.com&amp;subject=h%C3%A4llo%20w%C3%B6rld" >me+smtpext@example.com</a>';
@@ -155,15 +83,6 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testUmlautsWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$result = '<a href="mailto:me+smtpext@example.com?cc=you@example.com,they@example.com&amp;subject=h%C3%A4llo%20w%C3%B6rld" >me+smtpext@example.com</a>';
$tpl = $this->smarty->createTemplate('eval:{mailto address="me+smtpext@example.com" cc="you@example.com,they@example.com" subject="hällo wörld"}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testJavascriptChars()
{
$result = '<script type="text/javascript">document.write(unescape(\'%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%26%71%75%6f%74%3b%26%67%74%3b%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%26%23%30%33%39%3b%29%3b%20%61%6c%65%72%74%28%26%71%75%6f%74%3b%69%6e%6a%65%63%74%69%6f%6e%26%71%75%6f%74%3b%29%3b%20%2f%2f%22%20%3e%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%26%71%75%6f%74%3b%26%67%74%3b%6d%65%40%65%78%61%6d%70%6c%65%2e%63%6f%6d%26%23%30%33%39%3b%29%3b%20%61%6c%65%72%74%28%26%71%75%6f%74%3b%69%6e%6a%65%63%74%69%6f%6e%26%71%75%6f%74%3b%29%3b%20%2f%2f%3c%2f%61%3e\'))</script>';

View File

@@ -40,33 +40,6 @@ class PluginModifierCapitalizeTest extends PHPUnit_Smarty
$this->assertEquals("Next X-Men Film, X3, Delayed. Ümlauts Äre Cööl.", $this->smarty->fetch($tpl));
}
public function testDefaultWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed."|capitalize}');
$this->assertEquals("Next X-Men FiLm, x3, Delayed.", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testDigitsWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed."|capitalize:true}');
$this->assertEquals("Next X-Men FiLm, X3, Delayed.", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testTrueCaptialsWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed."|capitalize:true:true}');
$this->assertEquals("Next X-Men Film, X3, Delayed.", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testQuotes()
{
$tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize}');
@@ -75,17 +48,6 @@ class PluginModifierCapitalizeTest extends PHPUnit_Smarty
$this->assertEquals("Next X-Men FiLm, x3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
}
public function testQuotesWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize}');
$this->assertEquals("Next X-Men FiLm, x3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
$tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize}');
$this->assertEquals("Next X-Men FiLm, x3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testQuotesDigits()
{
$tpl =
@@ -96,19 +58,6 @@ class PluginModifierCapitalizeTest extends PHPUnit_Smarty
$this->assertEquals("Next X-Men FiLm, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
}
public function testQuotesDigitsWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$tpl =
$this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true}');
$this->assertEquals("Next X-Men FiLm, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
$tpl =
$this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true}');
$this->assertEquals("Next X-Men FiLm, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testQuotesTrueCapitals()
{
$tpl =
@@ -119,19 +68,6 @@ class PluginModifierCapitalizeTest extends PHPUnit_Smarty
$this->assertEquals("Next X-Men Film, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
}
public function testQuotesTrueCapitalsWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$tpl =
$this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true:true}');
$this->assertEquals("Next X-Men Film, X3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
$tpl =
$this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true:true}');
$this->assertEquals("Next X-Men Film, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testQuotesBeginning()
{
$tpl = $this->smarty->createTemplate('string:{"\"delayed. umlauts\" foo."|capitalize}');
@@ -140,14 +76,4 @@ class PluginModifierCapitalizeTest extends PHPUnit_Smarty
$this->assertEquals("'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
}
public function testQuotesBeginningWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"\"delayed. umlauts\" foo."|capitalize}');
$this->assertEquals("\"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl));
$tpl = $this->smarty->createTemplate('string:{"\'delayed. umlauts\' foo."|capitalize}');
$this->assertEquals("'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
}

View File

@@ -28,17 +28,6 @@ class PluginModifierCharsetTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $tpl->fetch());
}
public function testToLatin1WithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$encoded = "hällö wörld 2";
$result = mb_convert_encoding($encoded, 'ISO-8859-1', 'UTF-8');
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|to_charset}');
$this->assertEquals($encoded, $tpl->fetch());
\Smarty\Smarty::$_MBSTRING = true;
}
public function testFromLatin1()
{
$result = "hällö wörld 3";
@@ -47,17 +36,6 @@ class PluginModifierCharsetTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $tpl->fetch());
}
public function testFromLatin1WithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$result = "hällö wörld 4";
$encoded = mb_convert_encoding($result, 'ISO-8859-1', 'UTF-8');
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|from_charset}');
$this->assertEquals($encoded, $tpl->fetch());
\Smarty\Smarty::$_MBSTRING = true;
}
public function testFromUtf32le()
{
$result = "hällö wörld 5";
@@ -66,17 +44,6 @@ class PluginModifierCharsetTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $tpl->fetch());
}
public function testFromUtf32leWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$result = "hällö wörld 6";
$encoded = mb_convert_encoding($result, "UTF-32LE", "UTF-8");
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|from_charset:"UTF-32LE"}');
$this->assertEquals($encoded, $tpl->fetch());
\Smarty\Smarty::$_MBSTRING = true;
}
public function testToUtf32le()
{
$encoded = "hällö wörld 7";
@@ -85,14 +52,4 @@ class PluginModifierCharsetTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $tpl->fetch());
}
public function testToUtf32leWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$encoded = "hällö wörld 8";
$result = mb_convert_encoding($encoded, "UTF-32LE", "UTF-8");
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|to_charset:"UTF-32LE"}');
$this->assertEquals($encoded, $tpl->fetch());
\Smarty\Smarty::$_MBSTRING = true;
}
}

View File

@@ -27,16 +27,6 @@ class PluginModifierCountCharactersTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testDefaultWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId ('mb');
$result = "29";
$tpl = $this->smarty->createTemplate('string:{"Cold Wave Linked to Temperatures."|count_characters}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testSpaces()
{
$result = "33";
@@ -44,16 +34,6 @@ class PluginModifierCountCharactersTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testSpacesWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId ('mb');
$result = "33";
$tpl = $this->smarty->createTemplate('string:{"Cold Wave Linked to Temperatures."|count_characters:true}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testUmlauts()
{
$result = "29";
@@ -61,16 +41,6 @@ class PluginModifierCountCharactersTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testUmlautsWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId ('mb');
$result = "29";
$tpl = $this->smarty->createTemplate('string:{"Cold Wäve Linked tö Temperatures."|count_characters}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testUmlautsSpaces()
{
$result = "33";
@@ -78,13 +48,4 @@ class PluginModifierCountCharactersTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testUmlautsSpacesWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId ('mb');
$result = "33";
$tpl = $this->smarty->createTemplate('string:{"Cold Wäve Linked tö Temperatures."|count_characters:true}');
$this->assertNotEquals($result, $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
}

View File

@@ -35,18 +35,6 @@ class PluginModifierCountSentencesTest extends PHPUnit_Smarty
$this->assertEquals("0", $this->smarty->fetch($tpl));
}
public function testDefaultWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"hello world."|count_sentences}');
$this->assertEquals("1", $this->smarty->fetch($tpl));
$tpl = $this->smarty->createTemplate('string:{"hello world. I\'m another? Sentence!"|count_sentences}');
$this->assertEquals("3", $this->smarty->fetch($tpl));
$tpl = $this->smarty->createTemplate('string:{"hello world.wrong"|count_sentences}');
$this->assertEquals("0", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testUmlauts()
{
$tpl = $this->smarty->createTemplate('string:{"hello worldä."|count_sentences}');

View File

@@ -27,15 +27,6 @@ class PluginModifierCountWordsTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testDefaultWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$result = "7";
$tpl = $this->smarty->createTemplate('string:{"Dealers Will Hear Car Talk at Noon."|count_words}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testDashes()
{
$result = "7";
@@ -43,15 +34,6 @@ class PluginModifierCountWordsTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testDashesWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$result = "7";
$tpl = $this->smarty->createTemplate('string:{"Smalltime-Dealers Will Hear Car Talk at Noon."|count_words}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testUmlauts()
{
$result = "7";
@@ -59,12 +41,4 @@ class PluginModifierCountWordsTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testUmlautsWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$result = "7";
$tpl = $this->smarty->createTemplate('string:{"Dealers Will Hear Cär Talk at Nöön."|count_words}');
$this->assertNotEquals($result, $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
}

View File

@@ -33,28 +33,12 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty
$this->assertEquals("I&#039;m some &lt;html&gt; to ä be &quot;escaped&quot; or &amp;copy;", $this->smarty->fetch($tpl));
}
public function testHtmlWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or &copy;"|escape:"html"}');
$this->assertEquals("I&#039;m some &lt;html&gt; to ä be &quot;escaped&quot; or &amp;copy;", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testHtmlDouble()
{
$tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or &copy;"|escape:"html":null:false}');
$this->assertEquals("I&#039;m some &lt;html&gt; to ä be &quot;escaped&quot; or &copy;", $this->smarty->fetch($tpl));
}
public function testHtmlDoubleWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or &copy;"|escape:"html":null:false}');
$this->assertEquals("I&#039;m some &lt;html&gt; to ä be &quot;escaped&quot; or &copy;", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testHtmlallCompiled()
{
$tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or &copy;"|escape:"htmlall"}');
@@ -68,37 +52,12 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty
$this->assertEquals("I&#039;m some &lt;html&gt; to &auml; be &quot;escaped&quot; or &amp;copy;", $this->smarty->fetch($tpl));
}
public function testHtmlallWithoutMbstringCompiled()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or &copy;"|escape:"htmlall"}');
$this->assertEquals("I&#039;m some &lt;html&gt; to &auml; be &quot;escaped&quot; or &amp;copy;", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testHtmlallWithoutMbstringModifier()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or &copy;"|escape:$mode}');
$this->smarty->assign('mode', 'htmlall');
$this->assertEquals("I&#039;m some &lt;html&gt; to &auml; be &quot;escaped&quot; or &amp;copy;", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testHtmlallDouble()
{
$tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or &copy;"|escape:"htmlall":null:false}');
$this->assertEquals("I&#039;m some &lt;html&gt; to &auml; be &quot;escaped&quot; or &copy;", $this->smarty->fetch($tpl));
}
public function testHtmlallDoubleWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"I\'m some <html> to ä be \"escaped\" or &copy;"|escape:"htmlall":null:false}');
$this->assertEquals("I&#039;m some &lt;html&gt; to &auml; be &quot;escaped&quot; or &copy;", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testUrlCompiled()
{
$tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"url"}');
@@ -112,42 +71,18 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty
$this->assertEquals("http%3A%2F%2Fsome.encoded.com%2Furl%3Fparts%23foo", $this->smarty->fetch($tpl));
}
public function testUrlWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"url"}');
$this->assertEquals("http%3A%2F%2Fsome.encoded.com%2Furl%3Fparts%23foo", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testUrlpathinfo()
{
$tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"urlpathinfo"}');
$this->assertEquals("http%3A//some.encoded.com/url%3Fparts%23foo", $this->smarty->fetch($tpl));
}
public function testUrlpathinfoWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"urlpathinfo"}');
$this->assertEquals("http%3A//some.encoded.com/url%3Fparts%23foo", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testHex()
{
$tpl = $this->smarty->createTemplate('string:{"a/cäa"|escape:"hex"}');
$this->assertEquals("%61%2f%63%c3%a4%61", $this->smarty->fetch($tpl));
}
public function testHexWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"a/cäa"|escape:"hex"}');
$this->assertEquals("%61%2f%63%c3%a4%61", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testHexentity()
{
$q = "a&#228;&#1047;&#1076;&#1088;&#1072;&#1074;&#1089;&#1089;&#1090;&#1074;&#1091;&#1081;&#1090;&#1077;";
@@ -159,19 +94,6 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty
$this->assertEquals("&#x61;&#x62;&#x63;", $this->smarty->fetch($tpl));
}
public function testHexentityWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$q = "a&#228;&#1047;&#1076;&#1088;&#1072;&#1074;&#1089;&#1089;&#1090;&#1074;&#1091;&#1081;&#1090;&#1077;";
$r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8');
$tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"hexentity"}');
$this->assertNotEquals("&#x61;&#xE4;&#x417;&#x434;&#x440;&#x430;&#x432;&#x441;&#x441;&#x442;&#x432;&#x443;&#x439;&#x442;&#x435;", $this->smarty->fetch($tpl));
$tpl = $this->smarty->createTemplate('string:{"abc"|escape:"hexentity"}');
$this->assertEquals("&#x61;&#x62;&#x63;", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testDecentity()
{
$q = "a&#228;&#1047;&#1076;&#1088;&#1072;&#1074;&#1089;&#1089;&#1090;&#1074;&#1091;&#1081;&#1090;&#1077;";
@@ -183,58 +105,22 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty
$this->assertEquals("&#97;&#98;&#99;", $this->smarty->fetch($tpl));
}
public function testDecentityWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$q = "a&#228;&#1047;&#1076;&#1088;&#1072;&#1074;&#1089;&#1089;&#1090;&#1074;&#1091;&#1081;&#1090;&#1077;";
$r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8');
$tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"decentity"}');
$this->assertNotEquals("&#97;&#228;&#1047;&#1076;&#1088;&#1072;&#1074;&#1089;&#1089;&#1090;&#1074;&#1091;&#1081;&#1090;&#1077;", $this->smarty->fetch($tpl));
$tpl = $this->smarty->createTemplate('string:{"abc"|escape:"decentity"}');
$this->assertEquals("&#97;&#98;&#99;", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testJavascript()
{
$tpl = $this->smarty->createTemplate('string:{"var x = { foo : \"bar\n\" };"|escape:"javascript"}');
$this->assertEquals("var x = { foo : \\\"bar\\n\\\" };", $this->smarty->fetch($tpl));
}
public function testJavascriptWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"var x = { foo : \"bar\n\" };"|escape:"javascript"}');
$this->assertEquals("var x = { foo : \\\"bar\\n\\\" };", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testMail()
{
$tpl = $this->smarty->createTemplate('string:{"smarty@example.com"|escape:"mail"}');
$this->assertEquals("smarty [AT] example [DOT] com", $this->smarty->fetch($tpl));
}
public function testMailWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"smarty@example.com"|escape:"mail"}');
$this->assertEquals("smarty [AT] example [DOT] com", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testNonstd()
{
$tpl = $this->smarty->createTemplate('string:{"sma\'rty|»example«.com"|escape:"nonstd"}');
$this->assertEquals("sma'rty|&#187;example&#171;.com", $this->smarty->fetch($tpl));
}
public function testNonstdWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"' . mb_convert_encoding('sma\'rty@»example«.com', 'ISO-8859-1', 'UTF-8') . '"|escape:"nonstd"}');
$this->assertEquals("sma'rty@&#187;example&#171;.com", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
}

View File

@@ -26,15 +26,6 @@ class PluginModifierLowerTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testDefaultWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$result = "two convicts evade noose, jury hung.";
$tpl = $this->smarty->createTemplate('string:{"Two Convicts Evade Noose, Jury Hung."|lower}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testUmlauts()
{
$result = "two convicts eväde nööse, jury hung.";
@@ -42,12 +33,4 @@ class PluginModifierLowerTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testUmlautsWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$result = "two convicts eväde nööse, jury hung.";
$tpl = $this->smarty->createTemplate('string:{"Two Convicts Eväde NöÖse, Jury Hung."|lower}');
$this->assertNotEquals($result, $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
}

View File

@@ -26,14 +26,6 @@ class PluginModifierRegexReplaceTest extends PHPUnit_Smarty
$this->assertEquals("Infertility unlikely to be passed on, experts say.", $this->smarty->fetch($tpl));
}
public function testDefaultWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"Infertility unlikely to\nbe passed on, experts say."|regex_replace:"/[\r\t\n]/":" "}');
$this->assertEquals("Infertility unlikely to be passed on, experts say.", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testUmlauts()
{
$tpl = $this->smarty->createTemplate('string:{"Infertility unlikely tö\näe passed on, experts say."|regex_replace:"/[\r\t\n]/u":" "}');

View File

@@ -27,15 +27,6 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testDefaultWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$result = 'Two Sisters Reunite after Eighteen Years at Checkout Counter.';
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testLength()
{
$result = 'Two Sisters Reunite after...';
@@ -43,15 +34,6 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testLengthWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$result = 'Two Sisters Reunite after...';
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testEtc()
{
$result = 'Two Sisters Reunite after';
@@ -59,15 +41,6 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testEtcWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$result = 'Two Sisters Reunite after';
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:""}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testEtc2()
{
$result = 'Two Sisters Reunite after---';
@@ -75,15 +48,6 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testEtc2WithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$result = 'Two Sisters Reunite after---';
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"---"}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testBreak()
{
$result = 'Two Sisters Reunite after Eigh';
@@ -91,15 +55,6 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testBreakWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$result = 'Two Sisters Reunite after Eigh';
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"":true}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testBreak2()
{
$result = 'Two Sisters Reunite after E...';
@@ -107,15 +62,6 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testBreak2WithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$result = 'Two Sisters Reunite after E...';
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"...":true}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testMiddle()
{
$result = 'Two Sisters Re..ckout Counter.';
@@ -123,12 +69,4 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testMiddleWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$result = 'Two Sisters Re..ckout Counter.';
$tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"..":true:true}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
}

View File

@@ -28,16 +28,6 @@ class PluginModifierUnescapeTest extends PHPUnit_Smarty
$this->assertEquals($result, $this->smarty->fetch($tpl));
}
public function testHtmlWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$encoded = "a&#228;&#1047;&#1076;&#1088;&#1072;&gt;&lt;&amp;amp;&auml;&#228;&#1074;&#1089;&#1089;&#1090;&#1074;&#1091;&#1081;&#1090;&#1077;";
$result = "a&#228;&#1047;&#1076;&#1088;&#1072;><&amp;&auml;&#228;&#1074;&#1089;&#1089;&#1090;&#1074;&#1091;&#1081;&#1090;&#1077;";
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"html"}');
$this->assertEquals($result, $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testHtmlall()
{
$encoded = "&#039;&quot;a&#228;&#1047;&#1076;&#1088;&#1072;&gt;&lt;&amp;amp;&auml;&#228;&#1074;&#1089;&#1089;&#1090;&#1074;&#1091;&#1081;&#1090;&#1077;";
@@ -46,16 +36,6 @@ class PluginModifierUnescapeTest extends PHPUnit_Smarty
$this->assertEquals($result, $this->smarty->fetch($tpl));
}
public function testHtmlallWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$encoded = "&#039;&quot;a&#228;&#1047;&#1076;&#1088;&#1072;&gt;&lt;&amp;amp;&auml;&#228;&#1074;&#1089;&#1089;&#1090;&#1074;&#1091;&#1081;&#1090;&#1077;";
$result = "'\"Здра><&amp;ääвсствуйте";
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"htmlall"}');
$this->assertEquals($result, $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testUrl()
{
$encoded = "a%C3%A4%D0%97%D0%B4%D1%80%D0%B0%3E%3C%26amp%3B%C3%A4%C3%A4%D0%B2%D1%81%D1%81%D1%82%D0%B2%3F%3D%2B%D1%83%D0%B9%D1%82%D0%B5";

View File

@@ -27,15 +27,6 @@ class PluginModifierUpperTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testDefaultWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$result = "IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE.";
$tpl = $this->smarty->createTemplate('string:{"If Strike isn\'t Settled Quickly it may Last a While."|upper}');
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testUmlauts()
{
$result = "IF STRIKE ISN'T SÄTTLED ÜQUICKLY IT MAY LAST A WHILE.";
@@ -43,12 +34,4 @@ class PluginModifierUpperTest extends PHPUnit_Smarty
$this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl));
}
public function testUmlautsWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
$result = "IF STRIKE ISN'T SÄTTLED ÜQUICKLY IT MAY LAST A WHILE.";
$tpl = $this->smarty->createTemplate('string:{"If Strike isn\'t Sättled ÜQuickly it may Last a While."|upper}');
$this->assertNotEquals($result, $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
}

View File

@@ -26,15 +26,6 @@ class PluginModifierWordwrapTest extends PHPUnit_Smarty
$this->assertEquals("Blind woman gets new kidney from dad she hasn't seen in years.", $this->smarty->fetch($tpl));
}
public function testDefaultWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap}');
$this->assertEquals("Blind woman gets new kidney from dad she hasn't seen in years.", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testDefaultUmlauts()
{
$tpl = $this->smarty->createTemplate('string:{"äöüßñ woman ñsä new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
@@ -47,45 +38,18 @@ class PluginModifierWordwrapTest extends PHPUnit_Smarty
$this->assertEquals("Blind woman gets new kidney\nfrom dad she hasn't seen in\nyears.", $this->smarty->fetch($tpl));
}
public function testLengthWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
$this->assertEquals("Blind woman gets new kidney\nfrom dad she hasn't seen in\nyears.", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testBreak()
{
$tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30:"<br />\n"}');
$this->assertEquals("Blind woman gets new kidney<br />\nfrom dad she hasn't seen in<br />\nyears.", $this->smarty->fetch($tpl));
}
public function testBreakWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30:"<br />\n"}');
$this->assertEquals("Blind woman gets new kidney<br />\nfrom dad she hasn't seen in<br />\nyears.", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testLong()
{
$tpl = $this->smarty->createTemplate('string:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n"}');
$this->assertEquals("Blind woman\nwithaverylongandunpronoucablenameorso\ngets new kidney from dad\nshe hasn't seen in years.", $this->smarty->fetch($tpl));
}
public function testLongWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n"}');
$this->assertEquals("Blind woman\nwithaverylongandunpronoucablenameorso\ngets new kidney from dad\nshe hasn't seen in years.", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testLongUmlauts()
{
$tpl = $this->smarty->createTemplate('string:{"äöüßñ woman ñsääöüßñameorsoäöüßñäöüßñäöüßñäöüßñßñ gets new kidney from dad she hasn\'t seen in years."|wordwrap:26}');
@@ -98,15 +62,6 @@ class PluginModifierWordwrapTest extends PHPUnit_Smarty
$this->assertEquals("Blind woman\nwithaverylongandunpronouca\nblenameorso gets new\nkidney from dad she hasn't\nseen in years.", $this->smarty->fetch($tpl));
}
public function testLongCutWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n":true}');
$this->assertEquals("Blind woman\nwithaverylongandunpronouca\nblenameorso gets new\nkidney from dad she hasn't\nseen in years.", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testLongCutUmlauts()
{
$tpl = $this->smarty->createTemplate('string:{"äöüßñ woman ñsääöüßñameorsoäöüßñäöüßñäöüßñäöüßñßñ gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n":true}');
@@ -119,15 +74,6 @@ class PluginModifierWordwrapTest extends PHPUnit_Smarty
$this->assertEquals("Blind woman\ngets new kidney from dad she\nhasn't seen in years.", $this->smarty->fetch($tpl));
}
public function testLinebreaksWithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"Blind woman\ngets new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
$this->assertEquals("Blind woman\ngets new kidney from dad she\nhasn't seen in years.", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
public function testLinebreaks2()
{
$tpl = $this->smarty->createTemplate('string:{"Blind woman
@@ -138,26 +84,4 @@ class PluginModifierWordwrapTest extends PHPUnit_Smarty
new kidney from\ndad she hasn't seen in years.", $this->smarty->fetch($tpl));
}
public function testLinebreaks2WithoutMbstring()
{
\Smarty\Smarty::$_MBSTRING = false;
$this->smarty->setCompileId('mb');
$tpl = $this->smarty->createTemplate('string:{"Blind woman
gets
new kidney from dad she hasn\'t seen in years."|wordwrap:30}');
$this->assertEquals("Blind woman
gets
new kidney from\ndad she hasn't seen in years.", $this->smarty->fetch($tpl));
\Smarty\Smarty::$_MBSTRING = true;
}
/*
public function testUnicodeSpaces()
{
// Some Unicode Spaces
$string = "&#8199;hello spaced&#8196; &#8239; &#8197;&#8199; words ";
$string = mb_convert_encoding($string, 'UTF-8', "HTML-ENTITIES");
$tpl = $this->smarty->createTemplate('string:{"' . $string . '"|strip}');
$this->assertEquals(" hello spaced words ", $this->smarty->fetch($tpl));
}
*/
}

View File

@@ -30,11 +30,6 @@ class MbSplitEncodingIssue549Test extends PHPUnit_Smarty
public function setUp(): void
{
if(!\Smarty::$_MBSTRING)
{
$this->markTestSkipped("mbstring extension is not in use by Smarty");
}
$this->charset = \Smarty::$_CHARSET;
$this->setUpSmarty(__DIR__);
}

View File

@@ -6,6 +6,8 @@
* @subpackage PHPunitPlugin
*/
use Smarty\Compile\Base;
/**
* Smarty {getparams}
*
@@ -14,13 +16,13 @@
*
* @return string
*/
class smarty_compiler_getparamsshort extends Smarty_Internal_CompileBase
class smarty_compiler_getparamsshort extends Base
{
/**
* Attribute definition: Overwrites base class.
*
* @var array
* @see Smarty_Internal_CompileBase
* @see Base
*/
public $required_attributes = array();
@@ -28,14 +30,14 @@ class smarty_compiler_getparamsshort extends Smarty_Internal_CompileBase
* Attribute definition: Overwrites base class.
*
* @var array
* @see Smarty_Internal_CompileBase
* @see Base
*/
public $optional_attributes = array('_any');
/**
* Attribute definition: Overwrites base class.
*
* @var array
* @see Smarty_Internal_CompileBase
* @see Base
*/
public $shorttag_order = array('s1', 's2', 's3');