diff --git a/composer.json b/composer.json
index 165bfd2a..e6cfafa9 100644
--- a/composer.json
+++ b/composer.json
@@ -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": {
diff --git a/docs/programmers/charset.md b/docs/programmers/charset.md
index 3ebbe339..3d6580ab 100644
--- a/docs/programmers/charset.md
+++ b/docs/programmers/charset.md
@@ -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
diff --git a/plugins/block.textformat.php b/plugins/block.textformat.php
index 21a0a1d4..290e5795 100644
--- a/plugins/block.textformat.php
+++ b/plugins/block.textformat.php
@@ -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);
diff --git a/plugins/modifier.capitalize.php b/plugins/modifier.capitalize.php
index bc3e4615..4f603263 100644
--- a/plugins/modifier.capitalize.php
+++ b/plugins/modifier.capitalize.php
@@ -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;
}
diff --git a/plugins/modifier.debug_print_var.php b/plugins/modifier.debug_print_var.php
index 982b5b12..b782acdc 100644
--- a/plugins/modifier.debug_print_var.php
+++ b/plugins/modifier.debug_print_var.php
@@ -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);
}
diff --git a/plugins/modifier.escape.php b/plugins/modifier.escape.php
index 9d446014..5a082ae5 100644
--- a/plugins/modifier.escape.php
+++ b/plugins/modifier.escape.php
@@ -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 .= '' . strtoupper(dechex($unicode)) . ';';
- }
- return $return;
- }
- // no MBString fallback
- $_length = strlen($string);
- for ($x = 0; $x < $_length; $x++) {
- $return .= '' . bin2hex($string[ $x ]) . ';';
+ foreach (smarty_mb_to_unicode($string, \Smarty\Smarty::$_CHARSET) as $unicode) {
+ $return .= '' . 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;
diff --git a/plugins/modifier.replace.php b/plugins/modifier.replace.php
index 75be0599..9b19b81d 100644
--- a/plugins/modifier.replace.php
+++ b/plugins/modifier.replace.php
@@ -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);
}
diff --git a/plugins/modifier.truncate.php b/plugins/modifier.truncate.php
index 13644c56..452e1e7c 100644
--- a/plugins/modifier.truncate.php
+++ b/plugins/modifier.truncate.php
@@ -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;
}
diff --git a/plugins/modifiercompiler.count_characters.php b/plugins/modifiercompiler.count_characters.php
index 1aa6fdd6..78a0f50f 100644
--- a/plugins/modifiercompiler.count_characters.php
+++ b/plugins/modifiercompiler.count_characters.php
@@ -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) . '\')';
}
diff --git a/plugins/modifiercompiler.count_words.php b/plugins/modifiercompiler.count_words.php
index 18a968a5..afccf02d 100644
--- a/plugins/modifiercompiler.count_words.php
+++ b/plugins/modifiercompiler.count_words.php
@@ -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)';
}
diff --git a/plugins/modifiercompiler.escape.php b/plugins/modifiercompiler.escape.php
index ea4ff3e1..7653ceb6 100644
--- a/plugins/modifiercompiler.escape.php
+++ b/plugins/modifiercompiler.escape.php
@@ -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':
diff --git a/plugins/modifiercompiler.from_charset.php b/plugins/modifiercompiler.from_charset.php
index 75c2d80c..40299b98 100644
--- a/plugins/modifiercompiler.from_charset.php
+++ b/plugins/modifiercompiler.from_charset.php
@@ -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"';
}
diff --git a/plugins/modifiercompiler.lower.php b/plugins/modifiercompiler.lower.php
index 1d11cfd1..4f900873 100644
--- a/plugins/modifiercompiler.lower.php
+++ b/plugins/modifiercompiler.lower.php
@@ -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) . '\')';
}
diff --git a/plugins/modifiercompiler.to_charset.php b/plugins/modifiercompiler.to_charset.php
index ed6ebd3b..17543a04 100644
--- a/plugins/modifiercompiler.to_charset.php
+++ b/plugins/modifiercompiler.to_charset.php
@@ -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"';
}
diff --git a/plugins/modifiercompiler.unescape.php b/plugins/modifiercompiler.unescape.php
index c7e76eed..e97709f2 100644
--- a/plugins/modifiercompiler.unescape.php
+++ b/plugins/modifiercompiler.unescape.php
@@ -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':
diff --git a/plugins/modifiercompiler.upper.php b/plugins/modifiercompiler.upper.php
index 734e6c17..c8237409 100644
--- a/plugins/modifiercompiler.upper.php
+++ b/plugins/modifiercompiler.upper.php
@@ -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) . '\')';
}
diff --git a/plugins/modifiercompiler.wordwrap.php b/plugins/modifiercompiler.wordwrap.php
index dfa95dcd..a95333ec 100644
--- a/plugins/modifiercompiler.wordwrap.php
+++ b/plugins/modifiercompiler.wordwrap.php
@@ -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 ] . ')';
}
diff --git a/src/Resource/Extending.php b/src/Resource/Extending.php
index 68b6b62a..ba7f38c4 100644
--- a/src/Resource/Extending.php
+++ b/src/Resource/Extending.php
@@ -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
diff --git a/src/Smarty.php b/src/Smarty.php
index 98bb43a7..7a33c61c 100644
--- a/src/Smarty.php
+++ b/src/Smarty.php
@@ -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
diff --git a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.test.php b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.test.php
index 615e0413..b52a2eae 100644
--- a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.test.php
+++ b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.test.php
@@ -1,7 +1,9 @@
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;
- }
}
diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php
index 547945b3..27c3933a 100644
--- a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php
+++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php
@@ -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 = 'me@example.com';
- $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 = 'send me some mail';
@@ -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 = 'send me some mail';
- $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 = '';
@@ -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 = '';
- $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 = '';
@@ -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 = '';
- $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 = 'me@example.com';
@@ -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 = 'me@example.com';
- $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 = 'me@example.com';
@@ -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 = 'me@example.com';
- $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 = 'me@example.com';
@@ -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 = 'me@example.com';
- $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 = 'me@example.com';
@@ -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 = 'me@example.com';
- $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 = 'me+smtpext@example.com';
@@ -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 = 'me+smtpext@example.com';
- $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 = '';
diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php
index 0bc14272..00ce02d3 100644
--- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php
+++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php
@@ -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;
- }
}
diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php
index e5b6038b..90e52b2d 100644
--- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php
+++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php
@@ -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;
- }
}
diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php
index 2d894858..c965fe7f 100644
--- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php
+++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php
@@ -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;
- }
}
diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php
index bde85da2..0b7881bc 100644
--- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php
+++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php
@@ -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}');
diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php
index 11b71d61..dc8373d0 100644
--- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php
+++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php
@@ -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;
- }
}
diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php
index c39229ff..4e6b9858 100644
--- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php
+++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php
@@ -33,28 +33,12 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty
$this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl));
}
- public function testHtmlWithoutMbstring()
- {
- \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
- $tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"html"}');
- $this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl));
- \Smarty\Smarty::$_MBSTRING = true;
- }
-
public function testHtmlDouble()
{
$tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"html":null:false}');
$this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl));
}
- public function testHtmlDoubleWithoutMbstring()
- {
- \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
- $tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"html":null:false}');
- $this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl));
- \Smarty\Smarty::$_MBSTRING = true;
- }
-
public function testHtmlallCompiled()
{
$tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"htmlall"}');
@@ -68,37 +52,12 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty
$this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl));
}
- public function testHtmlallWithoutMbstringCompiled()
- {
- \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
- $tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"htmlall"}');
- $this->assertEquals("I'm some <html> to ä be "escaped" or ©", $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 to ä be \"escaped\" or ©"|escape:$mode}');
- $this->smarty->assign('mode', 'htmlall');
- $this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl));
- \Smarty\Smarty::$_MBSTRING = true;
- }
-
public function testHtmlallDouble()
{
$tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"htmlall":null:false}');
$this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl));
}
- public function testHtmlallDoubleWithoutMbstring()
- {
- \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
- $tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"htmlall":null:false}');
- $this->assertEquals("I'm some <html> to ä be "escaped" or ©", $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äЗдравсствуйте";
@@ -159,19 +94,6 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty
$this->assertEquals("abc", $this->smarty->fetch($tpl));
}
- public function testHexentityWithoutMbstring()
- {
- \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
- $q = "aäЗдравсствуйте";
- $r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8');
- $tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"hexentity"}');
- $this->assertNotEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl));
-
- $tpl = $this->smarty->createTemplate('string:{"abc"|escape:"hexentity"}');
- $this->assertEquals("abc", $this->smarty->fetch($tpl));
- \Smarty\Smarty::$_MBSTRING = true;
- }
-
public function testDecentity()
{
$q = "aäЗдравсствуйте";
@@ -183,58 +105,22 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty
$this->assertEquals("abc", $this->smarty->fetch($tpl));
}
- public function testDecentityWithoutMbstring()
- {
- \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb');
- $q = "aäЗдравсствуйте";
- $r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8');
- $tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"decentity"}');
- $this->assertNotEquals("aäЗдравсствуйте", $this->smarty->fetch($tpl));
-
- $tpl = $this->smarty->createTemplate('string:{"abc"|escape:"decentity"}');
- $this->assertEquals("abc", $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|»example«.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@»example«.com", $this->smarty->fetch($tpl));
- \Smarty\Smarty::$_MBSTRING = true;
- }
}
diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php
index edf36c31..c5d2c3e3 100644
--- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php
+++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php
@@ -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;
- }
}
diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php
index d2e379ea..0836e821 100644
--- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php
+++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php
@@ -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":" "}');
diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php
index e7c4a987..f1cd35fb 100644
--- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php
+++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php
@@ -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;
- }
}
diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php
index def8f99d..985bf478 100644
--- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php
+++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php
@@ -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äЗдра><&ääвсствуйте";
- $result = "aäЗдра><&ääвсствуйте";
- $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"html"}');
- $this->assertEquals($result, $this->smarty->fetch($tpl));
- \Smarty\Smarty::$_MBSTRING = true;
- }
-
public function testHtmlall()
{
$encoded = "'"aäЗдра><&ääвсствуйте";
@@ -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 = "'"aäЗдра><&ääвсствуйте";
- $result = "'\"aäЗдра><&ääвсствуйте";
- $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";
diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php
index eeec696f..4b62e82b 100644
--- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php
+++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php
@@ -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;
- }
}
diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php
index 7a1396fa..fb767a50 100644
--- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php
+++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php
@@ -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:"
\n"}');
$this->assertEquals("Blind woman gets new kidney
\nfrom dad she hasn't seen in
\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:"
\n"}');
- $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 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 = " hello spaced 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));
- }
- */
}
diff --git a/tests/UnitTests/TemplateSource/_Issues/549/MbSplitEncodingIssue549Test.php b/tests/UnitTests/TemplateSource/_Issues/549/MbSplitEncodingIssue549Test.php
index 7490c56b..02d09810 100644
--- a/tests/UnitTests/TemplateSource/_Issues/549/MbSplitEncodingIssue549Test.php
+++ b/tests/UnitTests/TemplateSource/_Issues/549/MbSplitEncodingIssue549Test.php
@@ -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__);
}
diff --git a/tests/UnitTests/__shared/PHPunitplugins/compiler.getparamsshort.php b/tests/UnitTests/__shared/PHPunitplugins/compiler.getparamsshort.php
index e5907eb1..68804cf9 100644
--- a/tests/UnitTests/__shared/PHPunitplugins/compiler.getparamsshort.php
+++ b/tests/UnitTests/__shared/PHPunitplugins/compiler.getparamsshort.php
@@ -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');