From be1496d1a8618ef186047468009c7e3e0640183b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 11 Feb 2014 22:48:45 +0200 Subject: Utf8/iconv/mbstring-related changes --- tests/mocks/core/utf8.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/mocks') diff --git a/tests/mocks/core/utf8.php b/tests/mocks/core/utf8.php index a43138fbc..9dda43aec 100644 --- a/tests/mocks/core/utf8.php +++ b/tests/mocks/core/utf8.php @@ -16,11 +16,22 @@ class Mock_Core_Utf8 extends CI_Utf8 { { defined('MB_ENABLED') OR define('MB_ENABLED', TRUE); mb_internal_encoding('UTF-8'); + ini_set('mbstring.substitute_character', 'none'); } else { defined('MB_ENABLED') OR define('MB_ENABLED', FALSE); } + + if (extension_loaded('iconv')) + { + defined('ICONV_ENABLED') OR define('ICONV_ENABLED', TRUE); + iconv_set_encoding('internal_encoding', 'UTF-8'); + } + else + { + defined('ICONV_ENABLED') OR define('ICONV_ENABLED', FALSE); + } } public function is_ascii_test($str) -- cgit v1.2.3-24-g4f1b From 1480d8c1b58babf23f701796c8130f11d12c42c5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 12 Feb 2014 18:07:34 +0200 Subject: Remove pointless mocks for remove_invisible_characters(), is_php(), is_really_writable() --- tests/mocks/core/common.php | 51 --------------------------------------------- 1 file changed, 51 deletions(-) (limited to 'tests/mocks') diff --git a/tests/mocks/core/common.php b/tests/mocks/core/common.php index b073f230d..9eb6b0954 100644 --- a/tests/mocks/core/common.php +++ b/tests/mocks/core/common.php @@ -87,40 +87,6 @@ if ( ! function_exists('load_class')) } } -// This is sort of meh. Should probably be mocked up with -// controllable output, so that we can test some of our -// security code. The function itself will be tested in the -// bootstrap testsuite. -// -------------------------------------------------------------------- - -if ( ! function_exists('remove_invisible_characters')) -{ - function remove_invisible_characters($str, $url_encoded = TRUE) - { - $non_displayables = array(); - - // every control character except newline (dec 10) - // carriage return (dec 13), and horizontal tab (dec 09) - - if ($url_encoded) - { - $non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15 - $non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31 - } - - $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127 - - do - { - $str = preg_replace($non_displayables, '', $str, -1, $count); - } - while ($count); - - return $str; - } -} - - // Clean up error messages // -------------------------------------------------------------------- @@ -150,23 +116,6 @@ if ( ! function_exists('_exception_handler')) // We assume a few things about our environment ... // -------------------------------------------------------------------- - -if ( ! function_exists('is_php')) -{ - function is_php($version = '5.0.0') - { - return ! (version_compare(PHP_VERSION, $version) < 0); - } -} - -if ( ! function_exists('is_really_writable')) -{ - function is_really_writable($file) - { - return is_writable($file); - } -} - if ( ! function_exists('is_loaded')) { function &is_loaded() -- cgit v1.2.3-24-g4f1b From bfbdf1eb200c89783b98a6d6b23de3483fbc8975 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 12 Feb 2014 18:10:15 +0200 Subject: [ci skip] Indentation fix --- tests/mocks/autoloader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/mocks') diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php index 1bcde797d..33942768d 100644 --- a/tests/mocks/autoloader.php +++ b/tests/mocks/autoloader.php @@ -112,7 +112,7 @@ function autoload($class) if ( ! file_exists($file)) { - return FALSE; + return FALSE; } include_once($file); -- cgit v1.2.3-24-g4f1b From eb555ed7a1673dab9f51df0d1365d19c4429a900 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 12 Feb 2014 19:25:01 +0200 Subject: Move mbstring/iconv configuration and MB_ENABLED, ICONV_ENABLED out of CI_Utf8::__construct() Also, use mb_substitute_character() instead of ini_set() --- tests/mocks/core/utf8.php | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) (limited to 'tests/mocks') diff --git a/tests/mocks/core/utf8.php b/tests/mocks/core/utf8.php index 9dda43aec..30b78adfe 100644 --- a/tests/mocks/core/utf8.php +++ b/tests/mocks/core/utf8.php @@ -3,35 +3,14 @@ class Mock_Core_Utf8 extends CI_Utf8 { /** - * We need to define several constants as - * the same process within CI_Utf8 class constructor. + * We need to define UTF8_ENABLED the same way that + * CI_Utf8 constructor does. * * @covers CI_Utf8::__construct() */ public function __construct() { defined('UTF8_ENABLED') OR define('UTF8_ENABLED', TRUE); - - if (extension_loaded('mbstring')) - { - defined('MB_ENABLED') OR define('MB_ENABLED', TRUE); - mb_internal_encoding('UTF-8'); - ini_set('mbstring.substitute_character', 'none'); - } - else - { - defined('MB_ENABLED') OR define('MB_ENABLED', FALSE); - } - - if (extension_loaded('iconv')) - { - defined('ICONV_ENABLED') OR define('ICONV_ENABLED', TRUE); - iconv_set_encoding('internal_encoding', 'UTF-8'); - } - else - { - defined('ICONV_ENABLED') OR define('ICONV_ENABLED', FALSE); - } } public function is_ascii_test($str) -- cgit v1.2.3-24-g4f1b From cd74d36ae1ac34c25271b5ff81cc2fd8df099724 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 15 Feb 2014 21:44:02 +0200 Subject: Rename CI_Utf8::_is_ascii() to is_ascii() and make it public No reason for it to be protected. --- tests/mocks/core/utf8.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'tests/mocks') diff --git a/tests/mocks/core/utf8.php b/tests/mocks/core/utf8.php index 30b78adfe..c8214a62a 100644 --- a/tests/mocks/core/utf8.php +++ b/tests/mocks/core/utf8.php @@ -13,9 +13,4 @@ class Mock_Core_Utf8 extends CI_Utf8 { defined('UTF8_ENABLED') OR define('UTF8_ENABLED', TRUE); } - public function is_ascii_test($str) - { - return $this->_is_ascii($str); - } - } \ No newline at end of file -- cgit v1.2.3-24-g4f1b