* Ported tests from test/ branch to t/ branch

* Added maint option to Makefile, only does maintenance tests
* Added .htaccess file in t/ to disallow acces from the web
This commit is contained in:
Alexandre Emsenhuber 2008-04-11 15:56:13 +00:00
parent 68bbfc12c0
commit c6a6d446a7
9 changed files with 604 additions and 0 deletions

View file

@ -21,5 +21,8 @@ test: t/Test.php
fast: t/Test.php
$(PROVE_BIN) $(FAST_TESTS)
maint:
$(PROVE_BIN) $(MAINTENANCE_TESTS)
verbose: t/Test.php
$(PROVE_BIN) -v $(ALL_TESTS) | egrep -v '^ok'

1
t/.htaccess Normal file
View file

@ -0,0 +1 @@
Deny from all

165
t/Search.inc Normal file
View file

@ -0,0 +1,165 @@
<?php
$wgCommandLineMode = true;
$self = 'Search.t';
define( 'MEDIAWIKI', true );
require 't/Test.php';
require 'includes/Defines.php';
require 'includes/ProfilerStub.php';
require 'LocalSettings.php';
require 'AdminSettings.php';
require 'includes/Setup.php';
function buildTestDatabase( $tables ) {
global $wgDBprefix, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname, $wgDBtype;
$oldPrefix = $wgDBprefix;
$wgDBprefix = 'parsertest';
$class = 'Database' . ucfirst( $wgDBtype );
$db = new $class (
$wgDBserver,
$wgDBadminuser,
$wgDBadminpassword,
$wgDBname );
if( $db->isOpen() ) {
if ( !( stristr( $db->getSoftwareLink(), 'MySQL') && version_compare( $db->getServerVersion(), '4.1', '<' ) ) ) {
# Database that supports CREATE TABLE ... LIKE
foreach ($tables as $tbl) {
$newTableName = $db->tableName( $tbl );
#$tableName = $oldPrefix . $tbl;
$tableName = $tbl;
$db->query("CREATE TEMPORARY TABLE $newTableName (LIKE $tableName)");
}
} else {
# Hack for MySQL versions < 4.1, which don't support
# "CREATE TABLE ... LIKE". Note that
# "CREATE TEMPORARY TABLE ... SELECT * FROM ... LIMIT 0"
# would not create the indexes we need....
foreach ($tables as $tbl) {
$res = $db->query("SHOW CREATE TABLE $tbl");
$row = $db->fetchRow($res);
$create = $row[1];
$create_tmp = preg_replace('/CREATE TABLE `(.*?)`/', 'CREATE TEMPORARY TABLE `'
. $wgDBprefix . '\\1`', $create);
if ($create === $create_tmp) {
# Couldn't do replacement
wfDie( "could not create temporary table $tbl" );
}
$db->query($create_tmp);
}
}
return $db;
} else {
// Something amiss
return null;
}
}
class SearchEngineTest {
var $db, $search;
function __construct( SearchEngine $search ){
$this->search = $search;
$this->db = $this->search->db;
}
function insertSearchData() {
$this->db->safeQuery( <<<END
INSERT INTO ! (page_id,page_namespace,page_title,page_latest)
VALUES (1, 0, 'Main_Page', 1),
(2, 1, 'Main_Page', 2),
(3, 0, 'Smithee', 3),
(4, 1, 'Smithee', 4),
(5, 0, 'Unrelated_page', 5),
(6, 0, 'Another_page', 6),
(7, 4, 'Help', 7),
(8, 0, 'Thppt', 8),
(9, 0, 'Alan_Smithee', 9),
(10, 0, 'Pages', 10)
END
, $this->db->tableName( 'page' ) );
$this->db->safeQuery( <<<END
INSERT INTO ! (rev_id,rev_page)
VALUES (1, 1),
(2, 2),
(3, 3),
(4, 4),
(5, 5),
(6, 6),
(7, 7),
(8, 8),
(9, 9),
(10, 10)
END
, $this->db->tableName( 'revision' ) );
$this->db->safeQuery( <<<END
INSERT INTO ! (old_id,old_text)
VALUES (1, 'This is a main page'),
(2, 'This is a talk page to the main page, see [[smithee]]'),
(3, 'A smithee is one who smiths. See also [[Alan Smithee]]'),
(4, 'This article sucks.'),
(5, 'Nothing in this page is about the S word.'),
(6, 'This page also is unrelated.'),
(7, 'Help me!'),
(8, 'Blah blah'),
(9, 'yum'),
(10,'are food')
END
, $this->db->tableName( 'text' ) );
$this->db->safeQuery( <<<END
INSERT INTO ! (si_page,si_title,si_text)
VALUES (1, 'main page', 'this is a main page'),
(2, 'main page', 'this is a talk page to the main page, see smithee'),
(3, 'smithee', 'a smithee is one who smiths see also alan smithee'),
(4, 'smithee', 'this article sucks'),
(5, 'unrelated page', 'nothing in this page is about the s word'),
(6, 'another page', 'this page also is unrelated'),
(7, 'help', 'help me'),
(8, 'thppt', 'blah blah'),
(9, 'alan smithee', 'yum'),
(10, 'pages', 'are food')
END
, $this->db->tableName( 'searchindex' ) );
}
function fetchIds( $results ) {
$matches = array();
while( $row = $results->next() ) {
$matches[] = $row->getTitle()->getPrefixedText();
}
$results->free();
# Search is not guaranteed to return results in a certain order;
# sort them numerically so we will compare simply that we received
# the expected matches.
sort( $matches );
return $matches;
}
function run(){
if( is_null( $this->db ) ){
fail( "Can't find a database to test with." );
return;
}
$this->insertSearchData();
plan( 4 );
$exp = array( 'Smithee' );
$got = $this->fetchIds( $this->search->searchText( 'smithee' ) );
is( $got, $exp, "Plain search" );
$exp = array( 'Alan Smithee', 'Smithee' );
$got = $this->fetchIds( $this->search->searchTitle( 'smithee' ) );
is( $got, $exp, "Title search" );
$this->search->setNamespaces( array( 0, 1, 4 ) );
$exp = array( 'Smithee', 'Talk:Main Page', );
$got = $this->fetchIds( $this->search->searchText( 'smithee' ) );
is( $got, $exp, "Power search" );
$exp = array( 'Alan Smithee', 'Smithee', 'Talk:Smithee', );
$got = $this->fetchIds( $this->search->searchTitle( 'smithee' ) );
is( $got, $exp, "Title power search" );
}
}

55
t/inc/Database.t Normal file
View file

@ -0,0 +1,55 @@
#!/usr/bin/env php
<?php
define( 'MEDIAWIKI', true );
require 't/Test.php';
require 'includes/Defines.php';
require 'LocalSettings.php';
plan( 13 );
require_ok( 'includes/ProfilerStub.php' );
require_ok( 'includes/GlobalFunctions.php' );
require_ok( 'includes/Exception.php' );
require_ok( 'includes/Database.php' );
$db = new Database( $wgDBserver, $wgDBuser, $wgDBpassword );
cmp_ok( $db->addQuotes( NULL ), '==',
'NULL', 'Add quotes to NULL' );
cmp_ok( $db->addQuotes( 1234 ), '==',
"'1234'", 'Add quotes to int' );
cmp_ok( $db->addQuotes( 1234.5678 ), '==',
"'1234.5678'", 'Add quotes to float' );
cmp_ok( $db->addQuotes( 'string' ), '==',
"'string'", 'Add quotes to string' );
cmp_ok( $db->addQuotes( "string's cause trouble" ), '==',
"'string\'s cause trouble'", 'Add quotes to quoted string' );
$sql = $db->fillPrepared(
'SELECT * FROM interwiki', array() );
cmp_ok( $sql, '==',
'SELECT * FROM interwiki', 'FillPrepared empty' );
$sql = $db->fillPrepared(
'SELECT * FROM cur WHERE cur_namespace=? AND cur_title=?',
array( 4, "Snicker's_paradox" ) );
cmp_ok( $sql, '==',
"SELECT * FROM cur WHERE cur_namespace='4' AND cur_title='Snicker\'s_paradox'", 'FillPrepared question' );
$sql = $db->fillPrepared(
'SELECT user_id FROM ! WHERE user_name=?',
array( '"user"', "Slash's Dot" ) );
cmp_ok( $sql, '==',
"SELECT user_id FROM \"user\" WHERE user_name='Slash\'s Dot'", 'FillPrepared quoted' );
$sql = $db->fillPrepared(
"SELECT * FROM cur WHERE cur_title='This_\\&_that,_WTF\\?\\!'",
array( '"user"', "Slash's Dot" ) );
cmp_ok( $sql, '==',
"SELECT * FROM cur WHERE cur_title='This_&_that,_WTF?!'", 'FillPrepared raw' );

154
t/inc/Global.t Normal file
View file

@ -0,0 +1,154 @@
#!/usr/bin/env php
<?php
define( 'MEDIAWIKI', true );
require 't/Test.php';
require 'includes/Defines.php';
require 'LocalSettings.php';
plan( 48 );
require_ok( 'includes/ProfilerStub.php' );
require_ok( 'includes/GlobalFunctions.php' );
$wgReadOnly = null;
$wgReadOnlyFile = tempnam(wfTempDir(), "mwtest_readonly");
unlink( $wgReadOnlyFile );
isnt( wfRandom(), wfRandom(), "Two differents random" );
is( wfUrlencode( "\xE7\x89\xB9\xE5\x88\xA5:Contributions/Foobar" ),
"%E7%89%B9%E5%88%A5:Contributions/Foobar", 'Urlencode' );
is( wfReadOnly(), false, 'Empty read only' );
is( wfReadOnly(), false, 'Empty read only, second time' );
$f = fopen( $wgReadOnlyFile, "wt" );
fwrite( $f, 'Message' );
fclose( $f );
$wgReadOnly = null;
is( wfReadOnly(), true, 'Read only file set' );
is( wfReadOnly(), true, 'Read only file set, second time' );
unlink( $wgReadOnlyFile );
$wgReadOnly = null;
is( wfReadOnly(), false, 'Read only reset' );
is( wfReadOnly(), false, 'Read only reset, second time' );
is( wfQuotedPrintable( "\xc4\x88u legebla?", "UTF-8" ),
"=?UTF-8?Q?=C4=88u=20legebla=3F?=", 'Quoted printable' );
$start = wfTime();
is( gettype( $start ), 'float', 'Time (type)' );
$end = wfTime();
cmp_ok( $end, '>', $start, 'Time' );
$arr = wfArrayToCGI(
array( 'baz' => 'AT&T', 'ignore' => '' ),
array( 'foo' => 'bar', 'baz' => 'overridden value' ) );
is( $arr, "baz=AT%26T&foo=bar", 'Array to CGI' );
$mime = mimeTypeMatch( 'text/html', array(
'application/xhtml+xml' => 1.0,
'text/html' => 0.7,
'text/plain' => 0.3
) );
is( $mime, 'text/html', 'Mime (1)' );
$mime = mimeTypeMatch( 'text/html', array(
'image/*' => 1.0,
'text/*' => 0.5
) );
is( $mime, 'text/*', 'Mime (2)' );
$mime = mimeTypeMatch( 'text/html', array( '*/*' => 1.0 ) );
is( $mime, '*/*', 'Mime (3)' );
$mime = mimeTypeMatch( 'text/html', array(
'image/png' => 1.0,
'image/svg+xml' => 0.5
) );
is( $mime, null, 'Mime (4)' );
$mime = wfNegotiateType(
array( 'application/xhtml+xml' => 1.0,
'text/html' => 0.7,
'text/plain' => 0.5,
'text/*' => 0.2 ),
array( 'text/html' => 1.0 ) );
is( $mime, 'text/html', 'Negotiate Mime (1)' );
$mime = wfNegotiateType(
array( 'application/xhtml+xml' => 1.0,
'text/html' => 0.7,
'text/plain' => 0.5,
'text/*' => 0.2 ),
array( 'application/xhtml+xml' => 1.0,
'text/html' => 0.5 ) );
is( $mime, 'application/xhtml+xml', 'Negotiate Mime (2)' );
$mime = wfNegotiateType(
array( 'text/html' => 1.0,
'text/plain' => 0.5,
'text/*' => 0.5,
'application/xhtml+xml' => 0.2 ),
array( 'application/xhtml+xml' => 1.0,
'text/html' => 0.5 ) );
is( $mime, 'text/html', 'Negotiate Mime (3)' );
$mime = wfNegotiateType(
array( 'text/*' => 1.0,
'image/*' => 0.7,
'*/*' => 0.3 ),
array( 'application/xhtml+xml' => 1.0,
'text/html' => 0.5 ) );
is( $mime, 'text/html', 'Negotiate Mime (4)' );
$mime = wfNegotiateType(
array( 'text/*' => 1.0 ),
array( 'application/xhtml+xml' => 1.0 ) );
is( $mime, null, 'Negotiate Mime (5)' );
$t = gmmktime( 12, 34, 56, 1, 15, 2001 );
is( wfTimestamp( TS_MW, $t ), '20010115123456', 'TS_UNIX to TS_MW' );
is( wfTimestamp( TS_UNIX, $t ), 979562096, 'TS_UNIX to TS_UNIX' );
is( wfTimestamp( TS_DB, $t ), '2001-01-15 12:34:56', 'TS_UNIX to TS_DB' );
$t = '20010115123456';
is( wfTimestamp( TS_MW, $t ), '20010115123456', 'TS_MW to TS_MW' );
is( wfTimestamp( TS_UNIX, $t ), 979562096, 'TS_MW to TS_UNIX' );
is( wfTimestamp( TS_DB, $t ), '2001-01-15 12:34:56', 'TS_MW to TS_DB' );
$t = '2001-01-15 12:34:56';
is( wfTimestamp( TS_MW, $t ), '20010115123456', 'TS_DB to TS_MW' );
is( wfTimestamp( TS_UNIX, $t ), 979562096, 'TS_DB to TS_UNIX' );
is( wfTimestamp( TS_DB, $t ), '2001-01-15 12:34:56', 'TS_DB to TS_DB' );
$sets = array(
'' => '',
'/' => '',
'\\' => '',
'//' => '',
'\\\\' => '',
'a' => 'a',
'aaaa' => 'aaaa',
'/a' => 'a',
'\\a' => 'a',
'/aaaa' => 'aaaa',
'\\aaaa' => 'aaaa',
'/aaaa/' => 'aaaa',
'\\aaaa\\' => 'aaaa',
'\\aaaa\\' => 'aaaa',
'/mnt/upload3/wikipedia/en/thumb/8/8b/Zork_Grand_Inquisitor_box_cover.jpg/93px-Zork_Grand_Inquisitor_box_cover.jpg' => '93px-Zork_Grand_Inquisitor_box_cover.jpg',
'C:\\Progra~1\\Wikime~1\\Wikipe~1\\VIEWER.EXE' => 'VIEWER.EXE',
'Östergötland_coat_of_arms.png' => 'Östergötland_coat_of_arms.png',
);
foreach( $sets as $from => $to ) {
is( $to, wfBaseName( $from ),
"wfBaseName('$from') => '$to'");
}

56
t/inc/ImageFunctions.t Normal file
View file

@ -0,0 +1,56 @@
#!/usr/bin/env php
<?php
define( 'MEDIAWIKI', true );
require 't/Test.php';
require 'includes/Defines.php';
$vals = array(
array(
'width' => 50,
'height' => 50,
'tests' => array(
50 => 50,
17 => 17,
18 => 18 ) ),
array(
'width' => 366,
'height' => 300,
'tests' => array(
50 => 61,
17 => 21,
18 => 22 ) ),
array(
'width' => 300,
'height' => 366,
'tests' => array(
50 => 41,
17 => 14,
18 => 15 ) ),
array(
'width' => 100,
'height' => 400,
'tests' => array(
50 => 12,
17 => 4,
18 => 4 ) )
);
plan( 3 + 3 * count( $vals ) );
require_ok( 'includes/ProfilerStub.php' );
require_ok( 'includes/GlobalFunctions.php' );
require_ok( 'includes/ImageFunctions.php' );
foreach( $vals as $row ) {
extract( $row );
foreach( $tests as $max => $expected ) {
$y = round( $expected * $height / $width );
$result = wfFitBoxWidth( $width, $height, $max );
$y2 = round( $result * $height / $width );
is( $result, $expected,
"($width, $height, $max) wanted: {$expected}x{$y}, got: {$result}x{$y2}" );
}
}

77
t/inc/LocalFile.t Normal file
View file

@ -0,0 +1,77 @@
#!/usr/bin/env php
<?php
define( 'MEDIAWIKI', true );
require 't/Test.php';
require 'includes/Defines.php';
require 'includes/ProfilerStub.php';
require 'LocalSettings.php';
require 'includes/Setup.php';
/**
* These tests should work regardless of $wgCapitalLinks
*/
$info = array(
'name' => 'test',
'directory' => '/testdir',
'url' => '/testurl',
'hashLevels' => 2,
'transformVia404' => false,
);
plan( 35 );
$repo_hl0 = new LocalRepo( array( 'hashLevels' => 0 ) + $info );
$repo_hl2 = new LocalRepo( array( 'hashLevels' => 2 ) + $info );
$repo_lc = new LocalRepo( array( 'initialCapital' => false ) + $info );
$file_hl0 = $repo_hl0->newFile( 'test!' );
$file_hl2 = $repo_hl2->newFile( 'test!' );
$file_lc = $repo_lc->newFile( 'test!' );
is( $file_hl0->getHashPath(), '', 'Get hash path, hasLev 0' );
is( $file_hl2->getHashPath(), 'a/a2/', 'Get hash path, hasLev 2' );
is( $file_lc->getHashPath(), 'c/c4/', 'Get hash path, lc first' );
is( $file_hl0->getRel(), 'Test!', 'Get rel path, hasLev 0' );
is( $file_hl2->getRel(), 'a/a2/Test!', 'Get rel path, hasLev 2' );
is( $file_lc->getRel(), 'c/c4/test!', 'Get rel path, lc first' );
is( $file_hl0->getUrlRel(), 'Test%21', 'Get rel url, hasLev 0' );
is( $file_hl2->getUrlRel(), 'a/a2/Test%21', 'Get rel url, hasLev 2' );
is( $file_lc->getUrlRel(), 'c/c4/test%21', 'Get rel url, lc first' );
is( $file_hl0->getArchivePath(), '/testdir/archive', 'Get archive path, hasLev 0' );
is( $file_hl2->getArchivePath(), '/testdir/archive/a/a2', 'Get archive path, hasLev 2' );
is( $file_hl0->getArchivePath( '!' ), '/testdir/archive/!', 'Get archive path, hasLev 0' );
is( $file_hl2->getArchivePath( '!' ), '/testdir/archive/a/a2/!', 'Get archive path, hasLev 2' );
is( $file_hl0->getThumbPath(), '/testdir/thumb/Test!', 'Get thumb path, hasLev 0' );
is( $file_hl2->getThumbPath(), '/testdir/thumb/a/a2/Test!', 'Get thumb path, hasLev 2' );
is( $file_hl0->getThumbPath( 'x' ), '/testdir/thumb/Test!/x', 'Get thumb path, hasLev 0' );
is( $file_hl2->getThumbPath( 'x' ), '/testdir/thumb/a/a2/Test!/x', 'Get thumb path, hasLev 2' );
is( $file_hl0->getArchiveUrl(), '/testurl/archive', 'Get archive url, hasLev 0' );
is( $file_hl2->getArchiveUrl(), '/testurl/archive/a/a2', 'Get archive url, hasLev 2' );
is( $file_hl0->getArchiveUrl( '!' ), '/testurl/archive/%21', 'Get archive url, hasLev 0' );
is( $file_hl2->getArchiveUrl( '!' ), '/testurl/archive/a/a2/%21', 'Get archive url, hasLev 2' );
is( $file_hl0->getThumbUrl(), '/testurl/thumb/Test%21', 'Get thumb url, hasLev 0' );
is( $file_hl2->getThumbUrl(), '/testurl/thumb/a/a2/Test%21', 'Get thumb url, hasLev 2' );
is( $file_hl0->getThumbUrl( 'x' ), '/testurl/thumb/Test%21/x', 'Get thumb url, hasLev 0' );
is( $file_hl2->getThumbUrl( 'x' ), '/testurl/thumb/a/a2/Test%21/x', 'Get thumb url, hasLev 2' );
is( $file_hl0->getArchiveVirtualUrl(), 'mwrepo://test/public/archive', 'Get archive virtual url, hasLev 0' );
is( $file_hl2->getArchiveVirtualUrl(), 'mwrepo://test/public/archive/a/a2', 'Get archive virtual url, hasLev 2' );
is( $file_hl0->getArchiveVirtualUrl( '!' ), 'mwrepo://test/public/archive/%21', 'Get archive virtual url, hasLev 0' );
is( $file_hl2->getArchiveVirtualUrl( '!' ), 'mwrepo://test/public/archive/a/a2/%21', 'Get archive virtual url, hasLev 2' );
is( $file_hl0->getThumbVirtualUrl(), 'mwrepo://test/public/thumb/Test%21', 'Get thumb virtual url, hasLev 0' );
is( $file_hl2->getThumbVirtualUrl(), 'mwrepo://test/public/thumb/a/a2/Test%21', 'Get thumb virtual url, hasLev 2' );
is( $file_hl0->getThumbVirtualUrl( '!' ), 'mwrepo://test/public/thumb/Test%21/%21', 'Get thumb virtual url, hasLev 0' );
is( $file_hl2->getThumbVirtualUrl( '!' ), 'mwrepo://test/public/thumb/a/a2/Test%21/%21', 'Get thumb virtual url, hasLev 2' );
is( $file_hl0->getUrl(), '/testurl/Test%21', 'Get url, hasLev 0' );
is( $file_hl2->getUrl(), '/testurl/a/a2/Test%21', 'Get url, hasLev 2' );

79
t/inc/Revision.t Normal file
View file

@ -0,0 +1,79 @@
#!/usr/bin/env php
<?php
define( 'MEDIAWIKI', true );
require 't/Test.php';
plan( 19 );
require_ok( 'includes/Defines.php' );
require_ok( 'includes/ProfilerStub.php' );
require_ok( 'includes/GlobalFunctions.php' );
require_ok( 'languages/Language.php' );
require_ok( 'includes/Revision.php' );
$wgContLang = Language::factory( 'en' );
$wgLegacyEncoding = false;
$wgCompressRevisions = false;
$wgInputEncoding = 'utf-8';
$wgOutputEncoding = 'utf-8';
$row = new stdClass;
$row->old_flags = '';
$row->old_text = 'This is a bunch of revision text.';
cmp_ok( Revision::getRevisionText( $row ), '==',
'This is a bunch of revision text.', 'Get revision text' );
$row = new stdClass;
$row->old_flags = 'gzip';
$row->old_text = gzdeflate( 'This is a bunch of revision text.' );
cmp_ok( Revision::getRevisionText( $row ), '==',
'This is a bunch of revision text.', 'Get revision text with gzip compression' );
$wgLegacyEncoding = 'iso-8859-1';
$row = new stdClass;
$row->old_flags = 'utf-8';
$row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
cmp_ok( Revision::getRevisionText( $row ), '==',
"Wiki est l'\xc3\xa9cole superieur !", 'Get revision text utf-8 native' );
$row = new stdClass;
$row->old_flags = '';
$row->old_text = "Wiki est l'\xe9cole superieur !";
cmp_ok( Revision::getRevisionText( $row ), '==',
"Wiki est l'\xc3\xa9cole superieur !", 'Get revision text utf-8 legacy' );
$row = new stdClass;
$row->old_flags = 'gzip,utf-8';
$row->old_text = gzdeflate( "Wiki est l'\xc3\xa9cole superieur !" );
cmp_ok( Revision::getRevisionText( $row ), '==',
"Wiki est l'\xc3\xa9cole superieur !", 'Get revision text utf-8 native and gzip' );
$row = new stdClass;
$row->old_flags = 'gzip';
$row->old_text = gzdeflate( "Wiki est l'\xe9cole superieur !" );
cmp_ok( Revision::getRevisionText( $row ), '==',
"Wiki est l'\xc3\xa9cole superieur !", 'Get revision text utf-8 native and gzip' );
$row = new stdClass;
$row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
$row->old_flags = Revision::compressRevisionText( $row->old_text );
like( $row->old_flags, '/utf-8/', "Flags should contain 'utf-8'" );
unlike( $row->old_flags, '/gzip/', "Flags should not contain 'gzip'" );
cmp_ok( $row->old_text, '==',
"Wiki est l'\xc3\xa9cole superieur !", "Direct check" );
cmp_ok( Revision::getRevisionText( $row ), '==',
"Wiki est l'\xc3\xa9cole superieur !", "getRevisionText" );
$wgCompressRevisions = true;
$row = new stdClass;
$row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
$row->old_flags = Revision::compressRevisionText( $row->old_text );
like( $row->old_flags, '/utf-8/', "Flags should contain 'utf-8'" );
like( $row->old_flags, '/gzip/', "Flags should contain 'gzip'" );
cmp_ok( gzinflate( $row->old_text ), '==',
"Wiki est l'\xc3\xa9cole superieur !", "Direct check" );
cmp_ok( Revision::getRevisionText( $row ), '==',
"Wiki est l'\xc3\xa9cole superieur !", "getRevisionText" );

14
t/inc/Search.t Normal file
View file

@ -0,0 +1,14 @@
#!/usr/bin/env php
<?php
require 't/Search.inc';
$db = buildTestDatabase( array( 'page', 'revision', 'text', 'searchindex' ) );
if( is_null( $db ) ){
fail( 'no db' );
exit();
}
$t = new SearchEngineTest( new SearchMySQL( $db ) );
$t->run();
/* vim: set filetype=php: */