mirrored from git://develop.git.wordpress.org/
/
canonicalCharset.php
88 lines (64 loc) · 2.47 KB
/
canonicalCharset.php
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/*
* Validate that badly named charsets always return the correct format for UTF-8 and ISO-8859-1.
*
* @since 4.8.0
*/
class Tests_Functions_CanonicalCharset extends WP_UnitTestCase {
public function test_utf_8_lower() {
$this->assertEquals( 'UTF-8', _canonical_charset( 'utf-8' ) );
}
public function test_utf_8_upper() {
$this->assertEquals( 'UTF-8', _canonical_charset( 'UTF-8' ) );
}
public function test_utf_8_mixxed() {
$this->assertEquals( 'UTF-8', _canonical_charset( 'Utf-8' ) );
}
public function test_utf_8() {
$this->assertEquals( 'UTF-8', _canonical_charset( 'UTF8' ) );
}
public function test_iso_lower() {
$this->assertEquals( 'ISO-8859-1', _canonical_charset( 'iso-8859-1' ) );
}
public function test_iso_upper() {
$this->assertEquals( 'ISO-8859-1', _canonical_charset( 'ISO-8859-1' ) );
}
public function test_iso_mixxed() {
$this->assertEquals( 'ISO-8859-1', _canonical_charset( 'Iso8859-1' ) );
}
public function test_iso() {
$this->assertEquals( 'ISO-8859-1', _canonical_charset( 'ISO8859-1' ) );
}
public function test_random() {
$this->assertEquals( 'random', _canonical_charset( 'random' ) );
}
public function test_empty() {
$this->assertEquals( '', _canonical_charset( '' ) );
}
/**
* @ticket 23688
*/
function test_update_option_blog_charset() {
$orig_blog_charset = get_option( 'blog_charset' );
update_option( 'blog_charset', 'utf8' );
$this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) );
update_option( 'blog_charset', 'utf-8' );
$this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) );
update_option( 'blog_charset', 'UTF8' );
$this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) );
update_option( 'blog_charset', 'UTF-8' );
$this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) );
update_option( 'blog_charset', 'ISO-8859-1' );
$this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) );
update_option( 'blog_charset', 'ISO8859-1' );
$this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) );
update_option( 'blog_charset', 'iso8859-1' );
$this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) );
update_option( 'blog_charset', 'iso-8859-1' );
$this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) );
// Arbitrary strings are passed through.
update_option( 'blog_charset', 'foobarbaz' );
$this->assertEquals( 'foobarbaz', get_option( 'blog_charset' ) );
update_option( 'blog_charset', $orig_blog_charset );
}
}