Index: trunk/phase3/maintenance/tests/ArticleTest.php |
— | — | @@ -1,114 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -class ArticleTest extends PHPUnit_Framework_TestCase { |
5 | | - var $saveGlobals = array(); |
6 | | - |
7 | | - function setUp() { |
8 | | - global $wgContLang; |
9 | | - $wgContLang = Language::factory( 'en' ); |
10 | | - $globalSet = array( |
11 | | - 'wgLegacyEncoding' => false, |
12 | | - 'wgCompressRevisions' => false, |
13 | | - 'wgInputEncoding' => 'utf-8', |
14 | | - 'wgOutputEncoding' => 'utf-8' ); |
15 | | - foreach( $globalSet as $var => $data ) { |
16 | | - $this->saveGlobals[$var] = $GLOBALS[$var]; |
17 | | - $GLOBALS[$var] = $data; |
18 | | - } |
19 | | - } |
20 | | - |
21 | | - function tearDown() { |
22 | | - foreach( $this->saveGlobals as $var => $data ) { |
23 | | - $GLOBALS[$var] = $data; |
24 | | - } |
25 | | - } |
26 | | - |
27 | | - function testGetRevisionText() { |
28 | | - $row = new stdClass; |
29 | | - $row->old_flags = ''; |
30 | | - $row->old_text = 'This is a bunch of revision text.'; |
31 | | - $this->assertEquals( |
32 | | - 'This is a bunch of revision text.', |
33 | | - Revision::getRevisionText( $row ) ); |
34 | | - } |
35 | | - |
36 | | - function testGetRevisionTextGzip() { |
37 | | - $row = new stdClass; |
38 | | - $row->old_flags = 'gzip'; |
39 | | - $row->old_text = gzdeflate( 'This is a bunch of revision text.' ); |
40 | | - $this->assertEquals( |
41 | | - 'This is a bunch of revision text.', |
42 | | - Revision::getRevisionText( $row ) ); |
43 | | - } |
44 | | - |
45 | | - function testGetRevisionTextUtf8Native() { |
46 | | - $row = new stdClass; |
47 | | - $row->old_flags = 'utf-8'; |
48 | | - $row->old_text = "Wiki est l'\xc3\xa9cole superieur !"; |
49 | | - $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1'; |
50 | | - $this->assertEquals( |
51 | | - "Wiki est l'\xc3\xa9cole superieur !", |
52 | | - Revision::getRevisionText( $row ) ); |
53 | | - } |
54 | | - |
55 | | - function testGetRevisionTextUtf8Legacy() { |
56 | | - $row = new stdClass; |
57 | | - $row->old_flags = ''; |
58 | | - $row->old_text = "Wiki est l'\xe9cole superieur !"; |
59 | | - $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1'; |
60 | | - $this->assertEquals( |
61 | | - "Wiki est l'\xc3\xa9cole superieur !", |
62 | | - Revision::getRevisionText( $row ) ); |
63 | | - } |
64 | | - |
65 | | - function testGetRevisionTextUtf8NativeGzip() { |
66 | | - $row = new stdClass; |
67 | | - $row->old_flags = 'gzip,utf-8'; |
68 | | - $row->old_text = gzdeflate( "Wiki est l'\xc3\xa9cole superieur !" ); |
69 | | - $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1'; |
70 | | - $this->assertEquals( |
71 | | - "Wiki est l'\xc3\xa9cole superieur !", |
72 | | - Revision::getRevisionText( $row ) ); |
73 | | - } |
74 | | - |
75 | | - function testGetRevisionTextUtf8LegacyGzip() { |
76 | | - $row = new stdClass; |
77 | | - $row->old_flags = 'gzip'; |
78 | | - $row->old_text = gzdeflate( "Wiki est l'\xe9cole superieur !" ); |
79 | | - $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1'; |
80 | | - $this->assertEquals( |
81 | | - "Wiki est l'\xc3\xa9cole superieur !", |
82 | | - Revision::getRevisionText( $row ) ); |
83 | | - } |
84 | | - |
85 | | - function testCompressRevisionTextUtf8() { |
86 | | - $row = new stdClass; |
87 | | - $row->old_text = "Wiki est l'\xc3\xa9cole superieur !"; |
88 | | - $row->old_flags = Revision::compressRevisionText( $row->old_text ); |
89 | | - $this->assertTrue( false !== strpos( $row->old_flags, 'utf-8' ), |
90 | | - "Flags should contain 'utf-8'" ); |
91 | | - $this->assertFalse( false !== strpos( $row->old_flags, 'gzip' ), |
92 | | - "Flags should not contain 'gzip'" ); |
93 | | - $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !", |
94 | | - $row->old_text, "Direct check" ); |
95 | | - $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !", |
96 | | - Revision::getRevisionText( $row ), "getRevisionText" ); |
97 | | - } |
98 | | - |
99 | | - function testCompressRevisionTextUtf8Gzip() { |
100 | | - $GLOBALS['wgCompressRevisions'] = true; |
101 | | - $row = new stdClass; |
102 | | - $row->old_text = "Wiki est l'\xc3\xa9cole superieur !"; |
103 | | - $row->old_flags = Revision::compressRevisionText( $row->old_text ); |
104 | | - $this->assertTrue( false !== strpos( $row->old_flags, 'utf-8' ), |
105 | | - "Flags should contain 'utf-8'" ); |
106 | | - $this->assertTrue( false !== strpos( $row->old_flags, 'gzip' ), |
107 | | - "Flags should contain 'gzip'" ); |
108 | | - $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !", |
109 | | - gzinflate( $row->old_text ), "Direct check" ); |
110 | | - $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !", |
111 | | - Revision::getRevisionText( $row ), "getRevisionText" ); |
112 | | - } |
113 | | -} |
114 | | - |
115 | | - |
Index: trunk/phase3/maintenance/tests/RevisionTest.php |
— | — | @@ -0,0 +1,114 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class RevisionTest extends PHPUnit_Framework_TestCase { |
| 5 | + var $saveGlobals = array(); |
| 6 | + |
| 7 | + function setUp() { |
| 8 | + global $wgContLang; |
| 9 | + $wgContLang = Language::factory( 'en' ); |
| 10 | + $globalSet = array( |
| 11 | + 'wgLegacyEncoding' => false, |
| 12 | + 'wgCompressRevisions' => false, |
| 13 | + 'wgInputEncoding' => 'utf-8', |
| 14 | + 'wgOutputEncoding' => 'utf-8' ); |
| 15 | + foreach( $globalSet as $var => $data ) { |
| 16 | + $this->saveGlobals[$var] = $GLOBALS[$var]; |
| 17 | + $GLOBALS[$var] = $data; |
| 18 | + } |
| 19 | + } |
| 20 | + |
| 21 | + function tearDown() { |
| 22 | + foreach( $this->saveGlobals as $var => $data ) { |
| 23 | + $GLOBALS[$var] = $data; |
| 24 | + } |
| 25 | + } |
| 26 | + |
| 27 | + function testGetRevisionText() { |
| 28 | + $row = new stdClass; |
| 29 | + $row->old_flags = ''; |
| 30 | + $row->old_text = 'This is a bunch of revision text.'; |
| 31 | + $this->assertEquals( |
| 32 | + 'This is a bunch of revision text.', |
| 33 | + Revision::getRevisionText( $row ) ); |
| 34 | + } |
| 35 | + |
| 36 | + function testGetRevisionTextGzip() { |
| 37 | + $row = new stdClass; |
| 38 | + $row->old_flags = 'gzip'; |
| 39 | + $row->old_text = gzdeflate( 'This is a bunch of revision text.' ); |
| 40 | + $this->assertEquals( |
| 41 | + 'This is a bunch of revision text.', |
| 42 | + Revision::getRevisionText( $row ) ); |
| 43 | + } |
| 44 | + |
| 45 | + function testGetRevisionTextUtf8Native() { |
| 46 | + $row = new stdClass; |
| 47 | + $row->old_flags = 'utf-8'; |
| 48 | + $row->old_text = "Wiki est l'\xc3\xa9cole superieur !"; |
| 49 | + $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1'; |
| 50 | + $this->assertEquals( |
| 51 | + "Wiki est l'\xc3\xa9cole superieur !", |
| 52 | + Revision::getRevisionText( $row ) ); |
| 53 | + } |
| 54 | + |
| 55 | + function testGetRevisionTextUtf8Legacy() { |
| 56 | + $row = new stdClass; |
| 57 | + $row->old_flags = ''; |
| 58 | + $row->old_text = "Wiki est l'\xe9cole superieur !"; |
| 59 | + $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1'; |
| 60 | + $this->assertEquals( |
| 61 | + "Wiki est l'\xc3\xa9cole superieur !", |
| 62 | + Revision::getRevisionText( $row ) ); |
| 63 | + } |
| 64 | + |
| 65 | + function testGetRevisionTextUtf8NativeGzip() { |
| 66 | + $row = new stdClass; |
| 67 | + $row->old_flags = 'gzip,utf-8'; |
| 68 | + $row->old_text = gzdeflate( "Wiki est l'\xc3\xa9cole superieur !" ); |
| 69 | + $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1'; |
| 70 | + $this->assertEquals( |
| 71 | + "Wiki est l'\xc3\xa9cole superieur !", |
| 72 | + Revision::getRevisionText( $row ) ); |
| 73 | + } |
| 74 | + |
| 75 | + function testGetRevisionTextUtf8LegacyGzip() { |
| 76 | + $row = new stdClass; |
| 77 | + $row->old_flags = 'gzip'; |
| 78 | + $row->old_text = gzdeflate( "Wiki est l'\xe9cole superieur !" ); |
| 79 | + $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1'; |
| 80 | + $this->assertEquals( |
| 81 | + "Wiki est l'\xc3\xa9cole superieur !", |
| 82 | + Revision::getRevisionText( $row ) ); |
| 83 | + } |
| 84 | + |
| 85 | + function testCompressRevisionTextUtf8() { |
| 86 | + $row = new stdClass; |
| 87 | + $row->old_text = "Wiki est l'\xc3\xa9cole superieur !"; |
| 88 | + $row->old_flags = Revision::compressRevisionText( $row->old_text ); |
| 89 | + $this->assertTrue( false !== strpos( $row->old_flags, 'utf-8' ), |
| 90 | + "Flags should contain 'utf-8'" ); |
| 91 | + $this->assertFalse( false !== strpos( $row->old_flags, 'gzip' ), |
| 92 | + "Flags should not contain 'gzip'" ); |
| 93 | + $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !", |
| 94 | + $row->old_text, "Direct check" ); |
| 95 | + $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !", |
| 96 | + Revision::getRevisionText( $row ), "getRevisionText" ); |
| 97 | + } |
| 98 | + |
| 99 | + function testCompressRevisionTextUtf8Gzip() { |
| 100 | + $GLOBALS['wgCompressRevisions'] = true; |
| 101 | + $row = new stdClass; |
| 102 | + $row->old_text = "Wiki est l'\xc3\xa9cole superieur !"; |
| 103 | + $row->old_flags = Revision::compressRevisionText( $row->old_text ); |
| 104 | + $this->assertTrue( false !== strpos( $row->old_flags, 'utf-8' ), |
| 105 | + "Flags should contain 'utf-8'" ); |
| 106 | + $this->assertTrue( false !== strpos( $row->old_flags, 'gzip' ), |
| 107 | + "Flags should contain 'gzip'" ); |
| 108 | + $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !", |
| 109 | + gzinflate( $row->old_text ), "Direct check" ); |
| 110 | + $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !", |
| 111 | + Revision::getRevisionText( $row ), "getRevisionText" ); |
| 112 | + } |
| 113 | +} |
| 114 | + |
| 115 | + |
Property changes on: trunk/phase3/maintenance/tests/RevisionTest.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 116 | + native |
Name: svn:keywords |
2 | 117 | + Author Date Id Revision |