-
Notifications
You must be signed in to change notification settings - Fork 7.8k
/
Copy pathbug75317.phpt
51 lines (45 loc) · 1.32 KB
/
bug75317.phpt
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
--TEST--
Bug #75317 (UConverter::setDestinationEncoding changes source instead of destinatination)
--EXTENSIONS--
intl
--FILE--
<?php
$utf8 = UConverter::getAliases('utf-8')[0];
$utf16 = UConverter::getAliases('utf-16')[0];
$utf32 = UConverter::getAliases('utf-32')[0];
$latin1 = UConverter::getAliases('latin1')[0];
function printResult($actual, $expected) {
var_dump($actual === $expected ? true : "expected: $expected, actual: $actual");
}
// test default values
$c = new UConverter();
printResult($c->getDestinationEncoding(), $utf8);
printResult($c->getSourceEncoding(), $utf8);
// test constructor args
$c = new UConverter('utf-16', 'latin1');
printResult($c->getDestinationEncoding(), $utf16);
printResult($c->getSourceEncoding(), $latin1);
// test setters
var_dump($c->setDestinationEncoding('utf-8'));
var_dump($c->setSourceEncoding('utf-32'));
printResult($c->getDestinationEncoding(), $utf8);
printResult($c->getSourceEncoding(), $utf32);
// test invalid inputs dont change values
var_dump($c->setDestinationEncoding('foobar') === false);
var_dump($c->setSourceEncoding('foobar') === false);
printResult($c->getDestinationEncoding(), $utf8);
printResult($c->getSourceEncoding(), $utf32);
?>
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)