4 define( 'MEDIAWIKI', true );
9 require_ok( 'includes/Defines.php' );
10 require_ok( 'includes/ProfilerStub.php' );
11 require_ok( 'includes/GlobalFunctions.php' );
12 require_ok( 'languages/Language.php' );
13 require_ok( 'includes/Revision.php' );
15 $wgContLang = Language
::factory( 'en' );
16 $wgLegacyEncoding = false;
17 $wgCompressRevisions = false;
18 $wgInputEncoding = 'utf-8';
19 $wgOutputEncoding = 'utf-8';
23 $row->old_text
= 'This is a bunch of revision text.';
24 cmp_ok( Revision
::getRevisionText( $row ), '==',
25 'This is a bunch of revision text.', 'Get revision text' );
28 $row->old_flags
= 'gzip';
29 $row->old_text
= gzdeflate( 'This is a bunch of revision text.' );
30 cmp_ok( Revision
::getRevisionText( $row ), '==',
31 'This is a bunch of revision text.', 'Get revision text with gzip compression' );
33 $wgLegacyEncoding = 'iso-8859-1';
36 $row->old_flags
= 'utf-8';
37 $row->old_text
= "Wiki est l'\xc3\xa9cole superieur !";
38 cmp_ok( Revision
::getRevisionText( $row ), '==',
39 "Wiki est l'\xc3\xa9cole superieur !", 'Get revision text utf-8 native' );
43 $row->old_text
= "Wiki est l'\xe9cole superieur !";
44 cmp_ok( Revision
::getRevisionText( $row ), '==',
45 "Wiki est l'\xc3\xa9cole superieur !", 'Get revision text utf-8 legacy' );
48 $row->old_flags
= 'gzip,utf-8';
49 $row->old_text
= gzdeflate( "Wiki est l'\xc3\xa9cole superieur !" );
50 cmp_ok( Revision
::getRevisionText( $row ), '==',
51 "Wiki est l'\xc3\xa9cole superieur !", 'Get revision text utf-8 native and gzip' );
54 $row->old_flags
= 'gzip';
55 $row->old_text
= gzdeflate( "Wiki est l'\xe9cole superieur !" );
56 cmp_ok( Revision
::getRevisionText( $row ), '==',
57 "Wiki est l'\xc3\xa9cole superieur !", 'Get revision text utf-8 native and gzip' );
60 $row->old_text
= "Wiki est l'\xc3\xa9cole superieur !";
61 $row->old_flags
= Revision
::compressRevisionText( $row->old_text
);
62 like( $row->old_flags
, '/utf-8/', "Flags should contain 'utf-8'" );
63 unlike( $row->old_flags
, '/gzip/', "Flags should not contain 'gzip'" );
64 cmp_ok( $row->old_text
, '==',
65 "Wiki est l'\xc3\xa9cole superieur !", "Direct check" );
66 cmp_ok( Revision
::getRevisionText( $row ), '==',
67 "Wiki est l'\xc3\xa9cole superieur !", "getRevisionText" );
69 $wgCompressRevisions = true;
72 $row->old_text
= "Wiki est l'\xc3\xa9cole superieur !";
73 $row->old_flags
= Revision
::compressRevisionText( $row->old_text
);
74 like( $row->old_flags
, '/utf-8/', "Flags should contain 'utf-8'" );
75 like( $row->old_flags
, '/gzip/', "Flags should contain 'gzip'" );
76 cmp_ok( gzinflate( $row->old_text
), '==',
77 "Wiki est l'\xc3\xa9cole superieur !", "Direct check" );
78 cmp_ok( Revision
::getRevisionText( $row ), '==',
79 "Wiki est l'\xc3\xa9cole superieur !", "getRevisionText" );