3 class ArticleTest
extends PHPUnit_Framework_TestCase
{
4 var $saveGlobals = array();
8 'wgLegacyEncoding' => false,
9 'wgCompressRevisions' => false,
10 'wgInputEncoding' => 'utf-8',
11 'wgOutputEncoding' => 'utf-8' );
12 foreach( $globalSet as $var => $data ) {
13 $this->saveGlobals
[$var] = $GLOBALS[$var];
14 $GLOBALS[$var] = $data;
19 foreach( $this->saveGlobals
as $var => $data ) {
20 $GLOBALS[$var] = $data;
24 function testGetRevisionText() {
27 $row->old_text
= 'This is a bunch of revision text.';
29 'This is a bunch of revision text.',
30 Revision
::getRevisionText( $row ) );
33 function testGetRevisionTextGzip() {
35 $row->old_flags
= 'gzip';
36 $row->old_text
= gzdeflate( 'This is a bunch of revision text.' );
38 'This is a bunch of revision text.',
39 Revision
::getRevisionText( $row ) );
42 function testGetRevisionTextUtf8Native() {
44 $row->old_flags
= 'utf-8';
45 $row->old_text
= "Wiki est l'\xc3\xa9cole superieur !";
46 $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1';
48 "Wiki est l'\xc3\xa9cole superieur !",
49 Revision
::getRevisionText( $row ) );
52 function testGetRevisionTextUtf8Legacy() {
55 $row->old_text
= "Wiki est l'\xe9cole superieur !";
56 $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1';
58 "Wiki est l'\xc3\xa9cole superieur !",
59 Revision
::getRevisionText( $row ) );
62 function testGetRevisionTextUtf8NativeGzip() {
64 $row->old_flags
= 'gzip,utf-8';
65 $row->old_text
= gzdeflate( "Wiki est l'\xc3\xa9cole superieur !" );
66 $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1';
68 "Wiki est l'\xc3\xa9cole superieur !",
69 Revision
::getRevisionText( $row ) );
72 function testGetRevisionTextUtf8LegacyGzip() {
74 $row->old_flags
= 'gzip';
75 $row->old_text
= gzdeflate( "Wiki est l'\xe9cole superieur !" );
76 $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1';
78 "Wiki est l'\xc3\xa9cole superieur !",
79 Revision
::getRevisionText( $row ) );
82 function testCompressRevisionTextUtf8() {
83 $row->old_text
= "Wiki est l'\xc3\xa9cole superieur !";
84 $row->old_flags
= Revision
::compressRevisionText( $row->old_text
);
85 $this->assertTrue( false !== strpos( $row->old_flags
, 'utf-8' ),
86 "Flags should contain 'utf-8'" );
87 $this->assertFalse( false !== strpos( $row->old_flags
, 'gzip' ),
88 "Flags should not contain 'gzip'" );
89 $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
90 $row->old_text
, "Direct check" );
91 $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
92 Revision
::getRevisionText( $row ), "getRevisionText" );
95 function testCompressRevisionTextUtf8Gzip() {
96 $GLOBALS['wgCompressRevisions'] = true;
97 $row->old_text
= "Wiki est l'\xc3\xa9cole superieur !";
98 $row->old_flags
= Revision
::compressRevisionText( $row->old_text
);
99 $this->assertTrue( false !== strpos( $row->old_flags
, 'utf-8' ),
100 "Flags should contain 'utf-8'" );
101 $this->assertTrue( false !== strpos( $row->old_flags
, 'gzip' ),
102 "Flags should contain 'gzip'" );
103 $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
104 gzinflate( $row->old_text
), "Direct check" );
105 $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
106 Revision
::getRevisionText( $row ), "getRevisionText" );