From 2807b5cc8c1dc0b316d4eba2a467cd903078ac84 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Tue, 3 Apr 2012 15:05:45 +0200 Subject: transformed untf8_ test to phpunit --- _testing/unittests/inc/utf8_html.test.php | 72 +++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 _testing/unittests/inc/utf8_html.test.php (limited to '_testing/unittests/inc/utf8_html.test.php') diff --git a/_testing/unittests/inc/utf8_html.test.php b/_testing/unittests/inc/utf8_html.test.php new file mode 100644 index 000000000..9f40514fc --- /dev/null +++ b/_testing/unittests/inc/utf8_html.test.php @@ -0,0 +1,72 @@ +assertEquals(utf8_tohtml($in),$out); + } + + function test_from_2byte(){ + $in = "\xc3\xbc"; + $out = 'ü'; + $this->assertEquals(utf8_tohtml($in),$out); + } + + function test_from_3byte(){ + $in = "\xe2\x99\x8a"; + $out = '♊'; + $this->assertEquals(utf8_tohtml($in),$out); + } + + function test_from_4byte(){ + $in = "\xf4\x80\x80\x81"; + $out = '􀀁'; + $this->assertEquals(utf8_tohtml($in),$out); + } + + function test_to_1byte(){ + $out = 'a'; + $in = 'a'; + $this->assertEquals(utf8_unhtml($in),$out); + } + + function test_to_2byte(){ + $out = "\xc3\xbc"; + $in = 'ü'; + $this->assertEquals(utf8_unhtml($in),$out); + } + + function test_to_3byte(){ + $out = "\xe2\x99\x8a"; + $in = '♊'; + $this->assertEquals(utf8_unhtml($in),$out); + } + + function test_to_4byte(){ + $out = "\xf4\x80\x80\x81"; + $in = '􀀁'; + $this->assertEquals(utf8_unhtml($in),$out); + } + + function test_without_entities(){ + $out = '&&'; + $in = '&&'; + $this->assertEquals(utf8_unhtml($in),$out); + } + + function test_with_entities(){ + $out = '&&'; + $in = '&&'; + $this->assertEquals(utf8_unhtml($in,HTML_ENTITIES),$out); + } + +} + +//Setup VIM: ex: et ts=4 : -- cgit v1.2.3