File: StringUtilTest.php

package info (click to toggle)
php-sabre-vobject 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 1,764 kB
  • sloc: php: 24,844; makefile: 40; xml: 22
file content (55 lines) | stat: -rw-r--r-- 1,004 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php

namespace Sabre\VObject;

class StringUtilTest extends \PHPUnit_Framework_TestCase {

    function testNonUTF8() {

        $string = StringUtil::isUTF8(chr(0xbf));

        $this->assertEquals(false, $string);

    }

    function testIsUTF8() {

        $string = StringUtil::isUTF8('I 💚 SabreDAV');

        $this->assertEquals(true, $string);

    }

    function testUTF8ControlChar() {

        $string = StringUtil::isUTF8(chr(0x00));

        $this->assertEquals(false, $string);

    }

    function testConvertToUTF8nonUTF8() {

        $string = StringUtil::convertToUTF8(chr(0xbf));

        $this->assertEquals(utf8_encode(chr(0xbf)), $string);

    }

    function testConvertToUTF8IsUTF8() {

        $string = StringUtil::convertToUTF8('I 💚 SabreDAV');

        $this->assertEquals('I 💚 SabreDAV', $string);

    }

    function testConvertToUTF8ControlChar() {

        $string = StringUtil::convertToUTF8(chr(0x00));

        $this->assertEquals('', $string);

    }

}