ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
StringUtilTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\VObject;
4
5use PHPUnit\Framework\TestCase;
6
7class StringUtilTest extends TestCase {
8
9 function testNonUTF8() {
10
11 $string = StringUtil::isUTF8(chr(0xbf));
12
13 $this->assertEquals(false, $string);
14
15 }
16
17 function testIsUTF8() {
18
19 $string = StringUtil::isUTF8('I 💚 SabreDAV');
20
21 $this->assertEquals(true, $string);
22
23 }
24
26
27 $string = StringUtil::isUTF8(chr(0x00));
28
29 $this->assertEquals(false, $string);
30
31 }
32
34
35 $string = StringUtil::convertToUTF8(chr(0xbf));
36
37 $this->assertEquals(utf8_encode(chr(0xbf)), $string);
38
39 }
40
42
43 $string = StringUtil::convertToUTF8('I 💚 SabreDAV');
44
45 $this->assertEquals('I 💚 SabreDAV', $string);
46
47 }
48
50
51 $string = StringUtil::convertToUTF8(chr(0x00));
52
53 $this->assertEquals('', $string);
54
55 }
56
57}
An exception for terminatinating execution or to throw for unit testing.
static convertToUTF8($str)
This method tries its best to convert the input string to UTF-8.
Definition: StringUtil.php:42
static isUTF8($str)
Returns true or false depending on if a string is valid UTF-8.
Definition: StringUtil.php:21