2 // vim: foldmethod=marker
4 * Ethna_SmartyPlugin_modifier_wordwrap_i18n_Test.php
6 * @author Yoshinari Takaoka <takaoka@beatcraft.com>
10 require_once ETHNA_BASE . '/class/Plugin/Smarty/modifier.wordwrap_i18n.php';
12 //{{{ Ethna_SmartyPlugin_modifier_wordwrap_i18n_Test
14 * Test Case For modifier_wordwrap_i18n.php
18 class Ethna_SmartyPlugin_modifier_wordwrap_i18n_Test extends Ethna_UnitTestBase
22 $ctl =& new Ethna_Controller();
23 $ctl->setClientEncoding('UTF-8');
26 // {{{ test_smarty_modifier_wordwrap_i18n
27 function test_smarty_modifier_wordwrap_i18n()
29 unset($GLOBALS['_Ethna_controller']);
32 $input_str = 'あいうaえaおaかきaaaくけこ';
38 $ctl =& new Ethna_Controller();
39 $actual = smarty_modifier_wordwrap_i18n($input_str, 8);
40 $this->assertEqual($expected, $actual);
41 unset($GLOBALS['_Ethna_controller']);
44 $ctl =& new Ethna_Controller();
45 $ctl->setClientEncoding('SJIS');
47 $sjis_input = mb_convert_encoding($input_str, 'SJIS', 'UTF-8');
48 $sjis_expected = mb_convert_encoding($expected, 'SJIS', 'UTF-8');
49 $sjis_actual = smarty_modifier_wordwrap_i18n($sjis_input, 8);
50 $this->assertEqual($sjis_expected, $sjis_actual);
51 unset($GLOBALS['_Ethna_controller']);
54 $ctl =& new Ethna_Controller();
55 $ctl->setClientEncoding('EUC-JP');
57 $eucjp_input = mb_convert_encoding($input_str, 'EUC-JP', 'UTF-8');
58 $eucjp_expected = mb_convert_encoding($expected, 'EUC-JP', 'UTF-8');
59 $eucjp_actual = smarty_modifier_wordwrap_i18n($eucjp_input, 8);
60 $this->assertEqual($eucjp_expected, $eucjp_actual);
63 function test_smarty_modifier_wordwrap_i18n_indent()
66 // indent を指定した場合、はじめの行は
70 unset($GLOBALS['_Ethna_controller']);
73 $input_str = 'あいうaえaおaかきaaaくけこ';
79 $ctl =& new Ethna_Controller();
80 $actual = smarty_modifier_wordwrap_i18n($input_str, 8, "\n", 4);
81 $this->assertEqual($expected, $actual);
82 unset($GLOBALS['_Ethna_controller']);
85 $ctl =& new Ethna_Controller();
86 $ctl->setClientEncoding('SJIS');
88 $sjis_input = mb_convert_encoding($input_str, 'SJIS', 'UTF-8');
89 $sjis_expected = mb_convert_encoding($expected, 'SJIS', 'UTF-8');
90 $sjis_actual = smarty_modifier_wordwrap_i18n($sjis_input, 8, "\n", 4);
91 $this->assertEqual($sjis_expected, $sjis_actual);
92 unset($GLOBALS['_Ethna_controller']);
95 $ctl =& new Ethna_Controller();
96 $ctl->setClientEncoding('EUC-JP');
98 $eucjp_input = mb_convert_encoding($input_str, 'EUC-JP', 'UTF-8');
99 $eucjp_expected = mb_convert_encoding($expected, 'EUC-JP', 'UTF-8');
100 $eucjp_actual = smarty_modifier_wordwrap_i18n($eucjp_input, 8, "\n", 4);
101 $this->assertEqual($eucjp_expected, $eucjp_actual);
104 function test_smarty_modifier_wordwrap_i18n_break()
106 unset($GLOBALS['_Ethna_controller']);
109 $input_str = 'あいうaえaおaかきaaaくけこ';
110 $expected = "あいうa\r\n"
115 $ctl =& new Ethna_Controller();
116 $actual = smarty_modifier_wordwrap_i18n($input_str, 8, "\r\n", 4);
117 $this->assertEqual($expected, $actual);
118 unset($GLOBALS['_Ethna_controller']);
121 $ctl =& new Ethna_Controller();
122 $ctl->setClientEncoding('SJIS');
124 $sjis_input = mb_convert_encoding($input_str, 'SJIS', 'UTF-8');
125 $sjis_expected = mb_convert_encoding($expected, 'SJIS', 'UTF-8');
126 $sjis_actual = smarty_modifier_wordwrap_i18n($sjis_input, 8, "\r\n", 4);
127 $this->assertEqual($sjis_expected, $sjis_actual);
128 unset($GLOBALS['_Ethna_controller']);
131 $ctl =& new Ethna_Controller();
132 $ctl->setClientEncoding('EUC-JP');
134 $eucjp_input = mb_convert_encoding($input_str, 'EUC-JP', 'UTF-8');
135 $eucjp_expected = mb_convert_encoding($expected, 'EUC-JP', 'UTF-8');
136 $eucjp_actual = smarty_modifier_wordwrap_i18n($eucjp_input, 8, "\r\n", 4);
137 $this->assertEqual($eucjp_expected, $eucjp_actual);