summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/core/compat/mbstring_test.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-02-13 02:01:31 +0100
committerAndrey Andreev <narf@devilix.net>2014-02-13 02:01:31 +0100
commit3fd1b384273b7b6d56950bbad3e1fac18f5f82e4 (patch)
treeb063e6c11901abb9384f829725cdc910d5f77a96 /tests/codeigniter/core/compat/mbstring_test.php
parent1b4e5e15404cc767d9472dbf6dc091b506b69136 (diff)
Introducing compatibility layers
- Limited support for mbstring (mb_strlen(), mb_strpos(), mb_substr() only) via iconv. Falls back to regular strlen(), strpos(), substr() if iconv is not available. - Password hashing, dependant on CRYPT_BLOWFISH (2y version, available since PHP 5.3.7) availability.
Diffstat (limited to 'tests/codeigniter/core/compat/mbstring_test.php')
-rw-r--r--tests/codeigniter/core/compat/mbstring_test.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/codeigniter/core/compat/mbstring_test.php b/tests/codeigniter/core/compat/mbstring_test.php
new file mode 100644
index 000000000..415222446
--- /dev/null
+++ b/tests/codeigniter/core/compat/mbstring_test.php
@@ -0,0 +1,54 @@
+<?php
+
+class mbstring_test extends CI_TestCase {
+
+ public function test_bootstrap()
+ {
+ if (MB_ENABLED)
+ {
+ return $this->markTestSkipped('ext/mbstring is loaded');
+ }
+
+ $this->assertTrue(function_exists('mb_strlen'));
+ $this->assertTrue(function_exists('mb_substr'));
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @depends test_bootstrap
+ */
+ public function test_mb_strlen()
+ {
+ $this->assertEquals(ICONV_ENABLED ? 4 : 8, mb_strlen('тест'));
+ $this->assertEquals(ICONV_ENABLED ? 4 : 8, mb_strlen('тест', 'UTF-8'));
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @depends test_boostrap
+ */
+ public function test_mb_strpos()
+ {
+ $this->assertEquals(ICONV_ENABLED ? 3 : 6, mb_strpos('тест', 'с'));
+ $this->assertFalse(mb_strpos('тест', 'с', 3));
+ $this->assertEquals(ICONV_ENABLED ? 3 : 6, mb_strpos('тест', 'с', 1, 'UTF-8'));
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @depends test_boostrap
+ */
+ public function test_mb_substr()
+ {
+ $this->assertEquals(ICONV_ENABLED ? 'стинг' : 'естинг', mb_substr('тестинг', 2));
+ $this->assertEquals(ICONV_ENABLED ? 'нг' : 'г', mb_substr('тестинг', -2));
+ $this->assertEquals(ICONV_ENABLED ? 'ст' : 'е', mb_substr('тестинг', 2, 2));
+ $this->assertEquals(ICONV_ENABLED ? 'стинг' : 'естинг', mb_substr('тестинг', 2, 'UTF-8'));
+ $this->assertEquals(ICONV_ENABLED ? 'нг' : 'г', mb_substr('тестинг', -2, 'UTF-8'));
+ $this->assertEquals(ICONV_ENABLED ? 'ст' : 'е', mb_substr('тестинг', 2, 2, 'UTF-8'));
+ }
+
+} \ No newline at end of file