aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/vobject/tests/Sabre/VObject/StringUtilTest.php
blob: 59a83d2945c168a1eb68e50313d82e006b0e1fcf (plain) (blame)
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
56
57
58
59
<?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);

    }

      



}