foreach ( self::$additionalOptions as $option => $default ) {
$this->longOptions[$option] = $option . 'Handler';
}
-
}
public static function main( $exit = true ) {
EOT;
}
-
}
protected function getNewTempFile() {
$fname = tempnam( wfTempDir(), 'MW_PHPUnit_' . get_class( $this ) . '_' );
$this->tmpfiles[] = $fname;
+
return $fname;
}
// where temporary directory creation is bundled and can be improved
unlink( $fname );
$this->assertTrue( wfMkdirParents( $fname ) );
+
return $fname;
}
* Stub. If a test needs to add additional data to the database, it should
* implement this method and do so
*/
- function addDBData() {}
+ function addDBData() {
+ }
private function addCoreDBData() {
# disabled for performance
'page_touched' => $this->db->timestamp(),
'page_latest' => 0,
'page_len' => 0 ), __METHOD__, array( 'IGNORE' ) );
-
}
User::resetIdByNameCache();
$user->saveSettings();
}
-
//Make 1 page with 1 revision
$page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
if ( !$page->getId() == 0 ) {
if ( ( $db->getType() == 'oracle' || !self::$useTemporaryTables ) && self::$reuseDB ) {
CloneDatabase::changePrefix( $prefix );
+
return;
} else {
$dbClone->cloneTableStructure();
private static function unprefixTable( $tableName ) {
global $wgDBprefix;
+
return substr( $tableName, strlen( $wgDBprefix ) );
}
unset( $tables['searchindex_segments'] );
$tables = array_flip( $tables );
}
+
return $tables;
}
if ( isset( MediaWikiPHPUnitCommand::$additionalOptions[$offset] ) ) {
return MediaWikiPHPUnitCommand::$additionalOptions[$offset];
}
-
}
public function setCliArg( $offset, $value ) {
MediaWikiPHPUnitCommand::$additionalOptions[$offset] = $value;
-
}
/**
) {
$wikitextNS = $ns;
+
return $wikitextNS;
}
}
if ( !$loaded ) {
$this->markTestSkipped( "PHP extension '$extName' is not loaded, skipping." );
}
+
return $loaded;
}
$this->assertInstanceOf( $expected, $pokemons, $message );
}
-
}
You are running these tests directly from phpunit. You may not have all globals correctly set.
Running phpunit.php instead is recommended.
EOF;
- require_once ( __DIR__ . "/phpunit.php" );
+ require_once( __DIR__ . "/phpunit.php" );
}
// Output a notice when running with older versions of PHPUnit
$this->assertEquals( $templates1, $templates2 );
$this->assertEquals( $templates1[0]->getFullText(), 'Historial' );
}
-
}
* debug function : dump the ipblocks table
*/
function dumpBlocks() {
- $v = $this->db->select( 'ipblocks', '*' );
+ $v = $this->db->select( 'ipblocks', '*' );
print "Got " . $v->numRows() . " rows. Full dump follow:\n";
foreach ( $v as $row ) {
print_r( $row );
$this->assertTrue( $this->block->equals( Block::newFromTarget( 'UTBlockee' ) ), "newFromTarget() returns the same block as the one that was made" );
$this->assertTrue( $this->block->equals( Block::newFromID( $this->blockId ) ), "newFromID() returns the same block as the one that was made" );
-
}
/**
// delta to stop one-off errors when things happen to go over a second mark.
$delta = abs( $this->madeAt - $this->block->mTimestamp );
$this->assertLessThan( 2, $delta, "If no timestamp is specified, the block is recorded as time()" );
-
}
/**
$u->addToDatabase();
unset( $u );
-
// Sanity check
$this->assertNull(
Block::newFromTarget( $username ),
$this->cdbAssert( "PHP error", $key, $v1, $value );
$this->cdbAssert( "DBA error", $key, $v2, $value );
}
-
}
private function randomString() {
for ( $j = 0; $j < $len; $j++ ) {
$s .= chr( mt_rand( 0, 255 ) );
}
+
return $s;
}
array( 'en', 'A', 'Aꦲ' ),
);
}
+
/**
* Opposite of testIsPrefix
*
$col = Collation::factory( $collation );
$this->assertEquals( $firstLetter, $col->getFirstLetter( $string ) );
}
+
function firstLetterProvider() {
return array(
array( 'uppercase', 'Abc', 'A' ),
protected function setUp() {
if ( !extension_loaded( 'xdiff' ) ) {
$this->markTestSkipped( 'The xdiff extension is not available' );
+
return;
}
if ( !function_exists( 'xdiff_string_rabdiff' ) ) {
$this->markTestSkipped( 'The version of xdiff extension is lower than 1.5.0' );
+
return;
}
if ( !extension_loaded( 'hash' ) && !extension_loaded( 'mhash' ) ) {
$this->markTestSkipped( 'Neither the hash nor mhash extension is available' );
+
return;
}
parent::setUp();
$this->object->getOptions()
);
}
-
}
$sampleUTF = "Östergötland_coat_of_arms.png";
-
//mb_substr
$substr_params = array(
array( 0, 0 ),
);
}
-
//mb_strlen
$this->assertEquals(
mb_strlen( $sampleUTF ),
'Fallback mb_strlen'
);
-
//mb_str(r?)pos
$strpos_params = array(
//array( 'ter' ),
'Fallback mb_strrpos with params ' . implode( ', ', $old_param_set )
);
}
-
}
$old_wgDebugTimestamps = $wgDebugTimestamps;
$wgDebugTimestamps = false;
-
wfDebug( "This is a normal string" );
$this->assertEquals( "This is a normal string", file_get_contents( $wgDebugLogFile ) );
unlink( $wgDebugLogFile );
$this->assertEquals( "This is nöt an ASCII string", file_get_contents( $wgDebugLogFile ) );
unlink( $wgDebugLogFile );
-
wfDebug( "\00305This has böth UTF and control chars\003" );
$this->assertEquals( " 05This has böth UTF and control chars ", file_get_contents( $wgDebugLogFile ) );
unlink( $wgDebugLogFile );
$this->assertGreaterThan( 5000000, preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) ) );
unlink( $wgDebugLogFile );
-
$wgDebugLogFile = $old_log_file;
$wgDebugTimestamps = $old_wgDebugTimestamps;
}
$this->assertEquals( $var1, 2, 'var1 is swapped' );
$this->assertEquals( $var2, 1, 'var2 is swapped' );
-
}
function testWfPercentTest() {
array( "$p//nds-nl.wikipedia.org", array( 'nl.wikipedia.org' ), true, "Substrings of domains match while they shouldn't, $pDesc URL" ),
) );
}
+
return $a;
}
public static function provideWfShellMaintenanceCmdList() {
global $wgPhpCli;
+
return array(
array( 'eval.php', array( '--help', '--test' ), array(),
"'$wgPhpCli' 'eval.php' '--help' '--test'",
public static function provideWfIsBadImageList() {
$blacklist = '* [[File:Bad.jpg]] except [[Nasty page]]';
+
return array(
array( 'Bad.jpg', false, $blacklist, true,
'Called on a bad image' ),
$url .= '#' . $fragment;
}
-
$cases[] = array(
$parts,
$url,
$x[] = array( $base, $str );
}
+
return $x;
}
}
}
}
+
return $retval;
}
}
if ( $n > 0 ) {
return self::intermediateFunction( $level, $n - 1 );
}
+
return wfGetCaller( $level );
}
array( '1k', 1024, 'One kb lowercased' ),
);
}
-
}
public static function provideNormalTimestamps() {
$t = gmmktime( 12, 34, 56, 1, 15, 2001 );
+
return array(
// TS_UNIX
array( $t, TS_MW, '20010115123456', 'TS_UNIX to TS_MW' ),
public static function provideHooks() {
$i = new NothingClass();
+
return array(
array( 'Object and method', array( $i, 'someNonStatic' ), 'changed-nonstatic', 'changed-nonstatic' ),
array( 'Object and no method', array( $i ), 'changed-onevent', 'original' ),
array( 'Class::method static call', array( 'NothingClass::someStatic' ), 'changed-static', 'original' ),
array( 'Global function', array( 'NothingFunction' ), 'changed-func', 'original' ),
array( 'Global function with data', array( 'NothingFunctionData', 'data' ), 'data', 'original' ),
- array( 'Closure', array( function( &$foo, $bar ) {
- $foo = 'changed-closure';
- return true;
- } ), 'changed-closure', 'original' ),
- array( 'Closure with data', array( function( $data, &$foo, $bar ) {
- $foo = $data;
- return true;
- }, 'data' ), 'data', 'original' )
+ array( 'Closure', array( function ( &$foo, $bar ) {
+ $foo = 'changed-closure';
+
+ return true;
+ } ), 'changed-closure', 'original' ),
+ array( 'Closure with data', array( function ( $data, &$foo, $bar ) {
+ $foo = $data;
+
+ return true;
+ }, 'data' ), 'data', 'original' )
);
}
}
public function testFalseReturn() {
- Hooks::register( 'MediaWikiHooksTest001', function( &$foo ) { return false; } );
- Hooks::register( 'MediaWikiHooksTest001', function( &$foo ) { $foo = 'test'; return true; } );
+ Hooks::register( 'MediaWikiHooksTest001', function ( &$foo ) {
+ return false;
+ } );
+ Hooks::register( 'MediaWikiHooksTest001', function ( &$foo ) {
+ $foo = 'test';
+
+ return true;
+ } );
$foo = 'original';
Hooks::run( 'MediaWikiHooksTest001', array( &$foo ) );
$this->assertSame( 'original', $foo, 'Hooks continued processing after a false return.' );
* @expectedException FatalError
*/
public function testFatalError() {
- Hooks::register( 'MediaWikiHooksTest001', function() { return 'test'; } );
+ Hooks::register( 'MediaWikiHooksTest001', function () {
+ return 'test';
+ } );
Hooks::run( 'MediaWikiHooksTest001', array() );
}
}
function NothingFunction( &$foo, &$bar ) {
$foo = 'changed-func';
+
return true;
}
function NothingFunctionData( $data, &$foo, &$bar ) {
$foo = $data;
+
return true;
}
public static function someStatic( &$foo, &$bar ) {
$foo = 'changed-static';
+
return true;
}
$this->calls++;
$foo = 'changed-nonstatic';
$bar = 'changed-nonstatic';
+
return true;
}
public function onMediaWikiHooksTest001( &$foo, &$bar ) {
$this->calls++;
$foo = 'changed-onevent';
+
return true;
}
public function someNonStaticWithData( $data, &$foo, &$bar ) {
$this->calls++;
$foo = $data;
+
return true;
}
}
foreach ( $types as $type ) {
$cases[] = array( $type );
}
+
return $cases;
}
isset( $case[3] ) ? $case[3] : ''
);
}
+
return $ret;
}
'Allow special case "step=any".'
);
}
-
}
throw new MWException( __METHOD__ . ': allow_url_fopen needs to be enabled for pure PHP' .
' http requests to work. If possible, curl should be used instead. See http://php.net/curl.' );
}
+
return new PhpHttpRequestTester( $url, $options );
default:
}
'tg' => new ReplacementArray()
);
}
-
}
class LanguageToTest extends Language {
$po->addImage( "Foo.png" );
-
$this->assertLinksUpdate( $t, $po, 'imagelinks', 'il_to', 'il_from = 111', array(
array( 'Foo.png' ),
) );
$po->addLanguageLink( Title::newFromText( "en:Foo" )->getFullText() );
-
$this->assertLinksUpdate( $t, $po, 'langlinks', 'll_lang, ll_title', 'll_from = 111', array(
array( 'En', 'Foo' ),
) );
public static function someMethod() {
return func_get_args();
}
-
}
class MWBlankClass {
public function testGetAssociated() {
$this->assertEquals( NS_TALK, MWNamespace::getAssociated( NS_MAIN ) );
$this->assertEquals( NS_MAIN, MWNamespace::getAssociated( NS_TALK ) );
-
}
### Exceptions with getAssociated()
NS_SPECIAL, NS_MEDIA,
"NS_SPECIAL and NS_MEDIA are different subject namespaces"
);
-
}
/**
'$wgContentNamespaces is an array with only NS_MAIN by default'
);
-
# test !is_array( $wgcontentNamespaces )
$wgContentNamespaces = '';
$this->assertEquals( NS_MAIN, MWNamespace::getContentNamespaces() );
$matches = $router->parse( "/wiki/Foo" );
$this->assertEquals( $matches, array( 'title' => 'bar%20$1' ) );
}
-
}
, $this->context
, $preferences
);
+
return $preferences;
}
}
for ( $i = 1; $i <= $num; $i++ ) {
$ret[] = array( $i );
}
+
return $ret;
}
$ret[] = array( $day[0], $month[0] );
}
}
+
return $ret;
}
}
$context->setTitle( $curTitle );
$this->assertTrue( $curTitle->equals( $context->getWikiPage()->getTitle() ),
"When a title is updated the WikiPage should be purged and recreated on-demand with the new title." );
-
}
public function testImportScopedSession() {
*/
public static function resourceLoaderRegisterModules( &$resourceLoader ) {
self::$resourceLoaderRegisterModulesHook = true;
+
return true;
}
self::$resourceLoaderRegisterModulesHook = false;
$resourceLoader = new ResourceLoader();
$this->assertTrue( self::$resourceLoaderRegisterModulesHook );
+
return $resourceLoader;
}
/* Stubs */
-class ResourceLoaderTestModule extends ResourceLoaderModule {}
+class ResourceLoaderTestModule extends ResourceLoaderModule {
+}
/* Hooks */
global $wgHooks;
$this->assertTrue( true ); // ok
}
}
-
}
// for immutable content like wikitext, this should be the same object
$this->assertSame( $content, $content2 );
}
-
}
class RevisionTestModifyableContent extends TextContent {
public function setText( $text ) {
$this->mText = $text;
}
-
}
class RevisionTestModifyableContentHandler extends TextContentHandler {
array( array( 'foo.' => 'baz' ), 'foo.=baz', 'A . is allowed as last character' ),
array( array( 'foo6' => 'baz' ), 'foo6=baz', 'Numbers are allowed' ),
-
# This bit is more relaxed than XML rules, but some extensions use
# it, like ProofreadPage (see bug 27539)
array( array( '1foo' => 'baz' ), '1foo=baz', 'Leading numbers are allowed' ),
$message
);
}
-
}
break;
}
}
+
return array(
'suffix' => $site,
'lang' => $lang,
$escaped .= $char;
}
}
+
return $escaped;
}
, $title->getParentCategories()
);
}
-
}
}
}
$this->user->saveSettings();
-
}
}
$title = Title::newFromText( $title );
$this->assertEquals( $expectedBool, $title->isWikitextPage() );
}
-
}
$this->user = $this->userUser;
}
-
}
function setUserPerm( $perm ) {
$this->title->userCan( $action, $this->user, true ) );
$this->assertEquals( $check[$action][3],
$this->title->quickUserCan( $action, $this->user ) );
-
# count( User::getGroupsWithPermissions( $action ) ) < 1
}
}
$this->title->userCan( 'edit', $this->user ) );
$this->assertEquals( array(),
$this->title->getUserPermissionsErrors( 'edit', $this->user ) );
-
}
function testActionPermissions() {
$this->assertEquals( true,
$this->title->userCan( 'create', $this->user ) );
-
$this->setUserPerm( array( 'createpage' ) );
$this->assertEquals( array( array( 'titleprotected', 'Useruser', 'test' ) ),
$this->title->getUserPermissionsErrors( 'create', $this->user ) );
$this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
$this->assertEquals( false,
$this->title->userCan( 'move-target', $this->user ) );
-
}
function testUserBlock() {
'Useruser', null, '23:00, 31 December 1969', '127.0.8.1',
$wgLang->timeanddate( wfTimestamp( TS_MW, $now ), true ) ) ),
$this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
-
# $action != 'read' && $action != 'createaccount' && $user->isBlockedFrom( $this )
# $user->blockedFor() == ''
# $user->mBlock->mExpiry == 'infinity'
foreach ( $errors as $error ) {
$result[] = $error[0];
}
+
return $result;
}
$text = preg_replace( '!\s*(</p>)!sm', '\1', $text ); # don't let tidy confuse us
$this->assertEquals( $expectedHtml, $text );
+
return $po;
}
$this->assertEquals( $expected, $text );
}
-
}
$page = new WikiPage( $page->getTitle() );
$this->assertEquals( 'WikitextContentHandler', get_class( $page->getContentHandler() ) );
}
-
}
$token = $a['token'];
// Finally create the account
- $ret = $this->doApiRequest( array(
- 'action' => 'createaccount',
- 'name' => 'Apitestnew',
- 'password' => $password,
- 'token' => $token,
- 'email' => 'test@domain.test',
- 'realname' => 'Test Name' ), $ret[2]
+ $ret = $this->doApiRequest(
+ array(
+ 'action' => 'createaccount',
+ 'name' => 'Apitestnew',
+ 'password' => $password,
+ 'token' => $token,
+ 'email' => 'test@domain.test',
+ 'realname' => 'Test Name'
+ ),
+ $ret[2]
);
$result = $ret[0];
$mapping[$key] = 'unused';
}
}
+
return $mapping;
}
'optionname' => null,
'optionvalue' => null,
);
+
return array_merge( $request, $custom );
}
private function executeQuery( $request ) {
$this->mContext->setRequest( new FauxRequest( $request, true, $this->mSession ) );
$this->mTested->execute();
+
return $this->mTested->getResult()->getData();
}
} catch ( UsageException $e ) {
$this->assertEquals( 'notloggedin', $e->getCodeString() );
$this->assertEquals( 'Anonymous users cannot change preferences', $e->getMessage() );
+
return;
}
$this->fail( "UsageException was not thrown" );
} catch ( UsageException $e ) {
$this->assertEquals( 'nooptionname', $e->getCodeString() );
$this->assertEquals( 'The optionname parameter must be set', $e->getMessage() );
+
return;
}
$this->fail( "UsageException was not thrown" );
} catch ( UsageException $e ) {
$this->assertEquals( 'nochanges', $e->getCodeString() );
$this->assertEquals( 'No changes were requested', $e->getMessage() );
+
return;
}
$this->fail( "UsageException was not thrown" );
"Parse request for nonexistent page must give 'missingtitle' error: " . var_export( $ex->getMessageArray(), true ) );
}
}
-
}
$this->assertArrayHasKey( $pages[$v['title']], $v );
}
}
-
}
protected function editPage( $pageName, $text, $summary = '', $defaultNs = NS_MAIN ) {
$title = Title::newFromText( $pageName, $defaultNs );
$page = WikiPage::factory( $title );
+
return $page->doEditContent( ContentHandler::makeContent( $text, $title ), $summary );
}
$session['wsEditToken'] = $session['wsToken'];
// add token to request parameters
$params['token'] = md5( $session['wsToken'] ) . User::EDIT_TOKEN_SUFFIX;
+
return $this->doApiRequest( $params, $session, false, $user );
} else {
throw new Exception( "request data not in right format" );
'titles' => 'Main Page',
'intoken' => 'edit|delete|protect|move|block|unblock|watch',
'prop' => 'info' ), $session, false, $user->user );
+
return $data;
}
}
class MockApi extends ApiBase {
- public function execute() {}
+ public function execute() {
+ }
- public function getVersion() {}
+ public function getVersion() {
+ }
- public function __construct() {}
+ public function __construct() {
+ }
public function getAllowedParams() {
return array(
if ( $user !== null ) {
$context->setUser( $user );
}
+
return $context;
}
}
// see if it now doesn't exist; reload
$title = Title::newFromText( $title->getText(), NS_FILE );
}
+
return !( $title && $title instanceof Title && $title->exists() );
}
foreach ( $dupes as $dupe ) {
$success &= $this->deleteFileByTitle( $dupe->getTitle() );
}
+
return $success;
}
);
return true;
-
}
function fakeUploadChunk( $fieldName, $fileName, $type, & $chunkData ) {
function clearFakeUploads() {
$_FILES = array();
}
-
}
$this->assertArrayHasKey( 'lgtoken', $result['login'] );
$this->assertNotEmpty( $session, 'API Login must return a session' );
- return $session;
+ return $session;
}
/**
$this->deleteFileByFileName( $fileName );
$this->deleteFileByContent( $filePath );
-
if ( !$this->fakeUploadFile( 'file', $fileName, $mimeType, $filePath ) ) {
$this->markTestIncomplete( "Couldn't upload file!\n" );
}
$this->assertEquals( 'Success', $result['upload']['result'] );
$this->assertFalse( $exception );
-
// second upload with the same content (but different name)
if ( !$this->fakeUploadFile( 'file', $fileNames[1], $mimeType, $filePaths[0] ) ) {
foreach ( $filenames as $filename ) {
$this->{$imageWriteMethod}( $this->getImageSpec(), $format, $filename );
}
+
return $filenames;
}
}
return $filenames;
-
}
array( 'x' => $originX, 'y' => $originY - $radius )
);
$draws[] = $draw;
-
}
$spec['draws'] = $draws;
foreach ( $shape as $point ) {
$points[] = $point['x'] . ',' . $point['y'];
}
+
return join( " ", $points );
}
}
$tSpec['draws'][] = $tDraw;
}
+
return $tSpec;
}
$command = wfEscapeShellArg( $wgImageMagickConvertCommand ) . " " . implode( " ", $args );
$retval = null;
wfShellExec( $command, $retval );
+
return ( $retval === 0 );
}
for ( $i = 0; $i <= 2; $i++ ) {
$components[] = mt_rand( 0, 255 );
}
+
return 'rgb(' . join( ', ', $components ) . ')';
}
for ( $i = 0; $i < $count; $i += 2 ) {
$pairs[] = array( $lines[$i], $lines[$i + 1] );
}
+
return $pairs;
}
return $lines;
}
-
}
$this->assertInternalType( 'array', unserialize( $data ) );
$this->assertGreaterThan( 0, count( (array)$data ) );
-
}
-
}
// put 'continue' params at the end - lazy method
$a = strpos( $a, 'continue' ) !== false ? 'zzz ' . $a : $a;
$b = strpos( $b, 'continue' ) !== false ? 'zzz ' . $b : $b;
+
return strcmp( $a, $b );
} );
$reqStr = http_build_query( $request );
if ( $expectedCount > $count ) {
print "***** $id Finished early in $count turns. $expectedCount was expected\n";
}
+
return $result;
} elseif ( !$useContinue ) {
$this->assertFalse( 'Non-smart query must be requested all at once' );
'action' => 'query',
'titles' => 'Project:articleA|article_B' ) );
-
$this->assertArrayHasKey( 'query', $data[0] );
$this->assertArrayHasKey( 'normalized', $data[0]['query'] );
),
$data[0]['query']['normalized'][1]
);
-
}
function testTitlesAreRejectedIfInvalid() {
$this->assertArrayHasKey( 'missing', $data[0]['query']['pages'][-2] );
$this->assertArrayHasKey( 'invalid', $data[0]['query']['pages'][-1] );
}
-
}
* @file
*/
-
/** This class has some common functionality for testing query module
*/
abstract class ApiQueryTestBase extends ApiTestCase {
$request = array_merge_recursive( $request, $req );
$this->mergeExpected( $expected, $exp );
}
+
return array( $request, $expected );
}
$this->assertArrayHasKey( 1, $v, self::PARAM_ASSERT );
$this->assertType( 'array', $v[0], self::PARAM_ASSERT );
$this->assertType( 'array', $v[1], self::PARAM_ASSERT );
+
return $v;
}
for ( $i = $firstKey; $i <= $lastKey; $i++ ) {
$expected["cache-key-$i"] = array( "prop-$i" => "value-$i" );
}
+
return $expected;
}
$cache->getCache(),
"Filling a $cacheMaxEntries entries cache with $entryToFill entries"
);
-
}
/**
),
$cache->getCache()
);
-
}
-
}
/**
*/
public function unserializeContent( $blob, $format = null ) {
$d = unserialize( $blob );
+
return new DummyContentForTesting( $d );
}
public function testEquals( Content $a, Content $b = null, $equal = false ) {
$this->assertEquals( $equal, $a->equals( $b ) );
}
-
}
array( new JavaScriptContent( "hallo" ), new JavaScriptContent( "HALLO" ), false ),
);
}
-
}
$this->assertEquals( $expectedNative, $converted->getNativeData() );
}
}
-
}
/*
public function testGetUndoContent( Revision $current, Revision $undo, Revision $undoafter = null ) {}
*/
-
}
),
"DELETE FROM table " .
"WHERE field IN (" .
- "SELECT field_join FROM table_join WHERE alias = 'text'" .
+ "SELECT field_join FROM table_join WHERE alias = 'text'" .
")"
),
array(
),
"DELETE FROM table " .
"WHERE field IN (" .
- "SELECT field_join FROM table_join " .
+ "SELECT field_join FROM table_join " .
")"
),
);
"INSERT IGNORE INTO table " .
"(field,field2) " .
"VALUES " .
- "('text','2')," .
- "('multi','3')"
+ "('text','2')," .
+ "('multi','3')"
),
);
}
"INSERT INTO insert_table " .
"(field_insert,field) " .
"SELECT field_select,field2 " .
- "FROM select_table"
+ "FROM select_table"
),
array(
array(
"INSERT INTO insert_table " .
"(field_insert,field) " .
"SELECT field_select,field2 " .
- "FROM select_table " .
- "WHERE field = '2'"
+ "FROM select_table " .
+ "WHERE field = '2'"
),
array(
array(
"INSERT IGNORE INTO insert_table " .
"(field_insert,field) " .
"SELECT field_select,field2 " .
- "FROM select_table " .
- "WHERE field = '2' " .
- "ORDER BY field"
+ "FROM select_table " .
+ "WHERE field = '2' " .
+ "ORDER BY field"
),
);
}
"DELETE FROM replace_table " .
"WHERE ( field='text' ); " .
"INSERT INTO replace_table " .
- "(field,field2) " .
- "VALUES ('text','text2')"
+ "(field,field2) " .
+ "VALUES ('text','text2')"
),
array(
array(
"DELETE FROM module_deps " .
"WHERE ( md_module='module' AND md_skin='skin' ); " .
"INSERT INTO module_deps " .
- "(md_module,md_skin,md_deps) " .
- "VALUES ('module','skin','deps')"
+ "(md_module,md_skin,md_deps) " .
+ "VALUES ('module','skin','deps')"
),
array(
array(
"DELETE FROM module_deps " .
"WHERE ( md_module='module' AND md_skin='skin' ); " .
"INSERT INTO module_deps " .
- "(md_module,md_skin,md_deps) " .
- "VALUES ('module','skin','deps'); " .
- "DELETE FROM module_deps " .
+ "(md_module,md_skin,md_deps) " .
+ "VALUES ('module','skin','deps'); " .
+ "DELETE FROM module_deps " .
"WHERE ( md_module='module2' AND md_skin='skin2' ); " .
"INSERT INTO module_deps " .
- "(md_module,md_skin,md_deps) " .
- "VALUES ('module2','skin2','deps2')"
+ "(md_module,md_skin,md_deps) " .
+ "VALUES ('module2','skin2','deps2')"
),
array(
array(
"DELETE FROM module_deps " .
"WHERE ( md_module='module' ) OR ( md_skin='skin' ); " .
"INSERT INTO module_deps " .
- "(md_module,md_skin,md_deps) " .
- "VALUES ('module','skin','deps'); " .
- "DELETE FROM module_deps " .
+ "(md_module,md_skin,md_deps) " .
+ "VALUES ('module','skin','deps'); " .
+ "DELETE FROM module_deps " .
"WHERE ( md_module='module2' ) OR ( md_skin='skin2' ); " .
"INSERT INTO module_deps " .
- "(md_module,md_skin,md_deps) " .
- "VALUES ('module2','skin2','deps2')"
+ "(md_module,md_skin,md_deps) " .
+ "VALUES ('module2','skin2','deps2')"
),
array(
array(
function query( $sql, $fname = '', $tempIgnore = false ) {
$this->lastQuery = $sql;
+
return true;
}
$db->sourceFile( "$IP/tests/phpunit/data/db/sqlite/tables-$version.sql" );
$updater = DatabaseUpdater::newForDB( $db, false, $maint );
$updater->doUpdates( array( 'core' ) );
+
return $db;
}
}
$list = array_flip( $list );
sort( $list );
+
return $list;
}
$cols[$col->name] = $col;
}
ksort( $cols );
+
return $cols;
}
$indexes[$index->name] = $index;
}
ksort( $indexes );
+
return $indexes;
}
public function getLastSqls() {
$lastSqls = implode( '; ', $this->lastSqls );
$this->lastSqls = array();
+
return $lastSqls;
}
public function tableExists( $table, $fname = __METHOD__ ) {
$this->checkFunctionName( $fname );
+
return in_array( $table, (array)$this->tablesExists );
}
*/
protected function getRowInstance( array $data, $loadDefaults ) {
$class = $this->getRowClass();
+
return new $class( $this->getTableInstance(), $data, $loadDefaults );
}
*/
public function getTable() {
$class = $this->getTableClass();
+
return $class::singleton();
}
$db->ignoreErrors( false );
}
-
}
/**
'blob' => new stdClass()
);
}
-
}
-class TestORMRow extends ORMRow {}
+class TestORMRow extends ORMRow {
+}
class TestORMTable extends ORMTable {
protected function getFieldPrefix() {
return 'test_';
}
-
-
}
"Source file $source does not exist ($backendName)." );
$this->assertEquals( false, $this->backend->fileExists( array( 'src' => $dest ) ),
"Destination file $dest does not exist ($backendName)." );
+
return; // done
}
"Source file $source does not exist ($backendName)." );
$this->assertEquals( false, $this->backend->fileExists( array( 'src' => $dest ) ),
"Destination file $dest does not exist ($backendName)." );
+
return; // done
}
public static function provider_testPrepareAndClean() {
$base = self::baseStorePath();
+
return array(
array( "$base/unittest-cont1/e/a/z/some_file1.txt", true ),
array( "$base/unittest-cont2/a/z/some_file2.txt", true ),
// test helper wrapper for backend prepare() function
private function create( array $params ) {
$params['op'] = 'create';
+
return $this->backend->doQuickOperations( array( $params ) );
}
$result = $this->repo->store( $srcPath, 'temp', $dstRel, $flags );
$result->value = $this->repo->getVirtualUrl( 'temp' ) . '/' . $dstUrlRel;
$this->createdFiles[] = $result->value;
+
return $result;
}
if ( !( $this->$q instanceof JobQueueDB ) ) {
$this->$q->setTestingPrefix( 'unittests-' . wfRandomString( 32 ) );
}
- } catch ( MWException $e ) {}; // unsupported? (@TODO: what if it was another error?)
+ } catch ( MWException $e ) {
+ }; // unsupported? (@TODO: what if it was another error?)
}
}
$jobs = iterator_to_array( $queue->getAllQueuedJobs() );
$this->assertEquals( 2, count( $jobs ), "Queue iterator size is correct ($desc)" );
-
$job1 = $queue->pop();
$this->assertFalse( $queue->isEmpty(), "Queue is not empty ($desc)" );
strtolower( FormatJson::encode( "\xf0\xa0\x80\x80" ) ),
'Test encoding an broken json_encode character (U+20000)'
);
-
}
public function testDecodeReturnType() {
$cases[] = array( $from, '"' . ( $leaveUnescaped ? $from : $to ) . '"' );
}
}
+
return $cases;
}
}
*/
protected function getNew( array $elements = array() ) {
$class = $this->getInstanceClass();
+
return new $class( $elements );
}
public function testOffsetSet( array $elements ) {
if ( $elements === array() ) {
$this->assertTrue( true );
+
return;
}
$this->assertArrayEquals( $list, $copy, true, true );
}
-
}
$res = $handler->getTiffByteOrder( $this->filePath . 'test.tiff' );
$this->assertEquals( 'LE', $res );
}
-
}
);
$this->assertEquals( $expected, $data );
}
-
-
}
$res = IPTC::Parse( $iptcData );
$this->assertEquals( array( '¼' ), $res['Keywords'] );
}
-
}
// encoded as just \xA9.
$expected = "© 2010 Bawolff";
-
$this->assertArrayHasKey( 'text', $meta );
$meta = $meta['text'];
$this->assertArrayHasKey( 'Copyright', $meta );
'greyscale-na-png.png' );
$this->assertEquals( 'greyscale', $meta['colorType'] );
}
-
}
$r = new XMLReader();
if ( !method_exists( $r, 'readInnerXML' ) ) {
$this->markTestSkipped( 'XMLReader::readInnerXML() does not exist (libxml >2.6.20 needed).' );
+
return;
}
$this->assertMetadata( $infile, $expected );
public static function provideSvgFiles() {
$base = __DIR__ . '/../../data/media';
+
return array(
array(
"$base/Wikimedia-logo.svg",
include( $xmpPath . $file[0] . '.result.php' );
$data[] = array( $xmp, $result, '[' . $file[0] . '.xmp] ' . $file[1] );
}
+
return $data;
}
$this->assertEquals( $expected, $actual );
}
-
}
array( '2001-05-12T15', null ),
array( '2001-12T15:13', null ),
);
-
}
-
}
$name = $this->getCliArg( 'use-bagostuff=' );
$this->cache = ObjectCache::newFromId( $name );
-
} else {
// no type defined - use simple hash
$this->cache = new HashBagOStuff;
$parserTester = new $parserTestClassName( $testsName );
$suite->addTestSuite( new ReflectionClass ( $parserTester ) );
}
+
return $suite;
}
}
$tmpGlobals['wgStyleDirectory'] = "$IP/skins";
}
-
foreach ( $tmpGlobals as $var => $val ) {
if ( array_key_exists( $var, $GLOBALS ) ) {
$this->savedInitialGlobals[$var] = $GLOBALS[$var];
// wfDebug( "Creating upload directory $dir\n" );
if ( file_exists( $dir ) ) {
wfDebug( "Already exists!\n" );
+
return $dir;
}
global $wgParserTestFiles;
$this->file = $wgParserTestFiles[0];
}
+
return new TestFileIterator( $this->file, $this );
}
}
$id++;
-
}
}
}
}
}
+
return $opts;
}
if ( substr( $opt, 0, 2 ) == '[[' ) {
return substr( $opt, 2, -2 );
}
+
return $opt;
}
'text' => '<pre style="margin-left: 1.6em">foo</pre>',
), $ret, 'callParserFunction works for {{#tag:pre|foo|style=margin-left: 1.6em}}' );
}
-
// TODO: Add tests for cleanSig() / cleanSigInSig(), getSection(), replaceSection(), getPreloadText()
}
# sort them numerically so we will compare simply that we received
# the expected matches.
sort( $matches );
+
return $matches;
}
$this->fetchIds( $this->search->searchTitle( 'smithee' ) ),
"Title power search failed" );
}
-
}
function update( $text, $title = 'Test', $id = 1 ) {
$u = new SearchUpdate( $id, $title, $text );
$u->doUpdate();
+
return array( MockSearch::$title, MockSearch::$text );
}
$this->assertContains( $path, $site->getPageUrl() );
$this->assertContains( $expected, $site->getPageUrl( $page ) );
}
-
}
$this->assertTrue( $copy->hasInternalId( $site->getInternalId() ) );
}
}
-
}
$sites = $store->getSites();
$this->assertEquals( 0, $sites->count() );
}
-
}
$this->assertEquals( $serialization, serialize( $newInstance ) );
}
-
}
$sitesTable->clear();
$sitesTable->saveSites( TestSites::getSites() );
}
-
}
/** return false if condition begin with 'rc_timestamp ' */
private static function filterOutRcTimestampCondition( $var ) {
return ( false === strpos( $var, 'rc_timestamp ' ) );
-
}
public function testRcNsFilter() {
array( NS_TALK, NS_MAIN ),
);
}
-
}
)
, $message
);
-
}
public static function provideSearchOptionsTests() {
foreach ( $opt as $name => $value ) {
$u->setOption( $name, $value );
}
+
return $u;
}
$pageTitle,
"Search term '{$term}' should not be expanded in Special:Search <title>"
);
-
}
}
$module->execute();
wfSetupSession( $sessionId );
+
return array( $module->getResultData(), $req );
}
$this->user->addGroup( 'users' );
-
$data = $this->doAsyncUpload( $token );
$this->assertEquals( $data[0]['upload']['result'], 'Warning' );
$this->assertFalse( $job );
return;
-
/*
// Broken until using leavemessage with ignorewarnings is supported
$job->run();
}
class UploadTestHandler extends UploadBase {
- public function initializeFromRequest( &$request ) {}
+ public function initializeFromRequest( &$request ) {
+ }
public function testTitleValidation( $name ) {
$this->mTitle = false;
$this->mDesiredDestName = $name;
$this->mTitleError = UploadBase::OK;
$this->getTitle();
+
return $this->mTitleError;
}
-
-
}
unset( $this->languageObject );
parent::tearDown();
}
-
}
'formatTimePeriod() rounding, recursion, (>48h)'
),
);
-
}
function testTruncate() {
array( 'n', 'just n' ),
array( 'n is in 5', 'is in' ),
);
+
return $tests;
}
-
}
return true;
}
}
+
return false;
}
return true;
}
}
+
return false;
}
$this->assertTextNode( "title", $name );
$this->assertTextNode( "ns", $ns );
$this->assertTextNode( "id", $id );
-
}
/**
* @param $parentid int|false: (optional) id of the parent revision
*/
protected function assertRevision( $id, $summary, $text_id, $text_bytes, $text_sha1, $text = false, $parentid = false,
- $model = CONTENT_MODEL_WIKITEXT, $format = CONTENT_FORMAT_WIKITEXT ) {
-
+ $model = CONTENT_MODEL_WIKITEXT, $format = CONTENT_FORMAT_WIKITEXT
+ ) {
$this->assertNodeStart( "revision" );
$this->skipWhitespace();
public function execute() {
$this->testCase->fail( __METHOD__ . " called unexpectedly" );
}
-
}
class MaintenanceTest extends MediaWikiTestCase {
// test.*Intermittent.* tests), the objective of these tests is not to describe
// consistent behavior, but rather currently existing behavior.
-
function testOutputEmpty() {
$this->m->output( "" );
$this->assertOutputPrePostShutdown( "", false );
$m2->simulateShutdown();
$this->assertOutputPrePostShutdown( "foobar\n\n", false );
}
-
-
}
private function assertPrefetchEquals( $expected, $page, $revision ) {
$this->assertEquals( $expected, $this->dump->prefetch( $page, $revision ),
"Prefetch of page $page revision $revision" );
-
}
function testSequential() {
</siteinfo>
';
-
// An array holding the pages that are available for prefetch
$available_pages = array();
return $fname;
}
-
}
// DumpTestCase
$this->exceptionFromAddDBData = $e;
}
-
}
protected function setUp() {
array( $this->pageId2, $this->pageId3, $this->pageId4 ),
array( $this->pageId1 + 1, $this->pageId2 + 1, $this->pageId3 + 1 ),
"Page ids increasing without holes" );
-
}
function testPlain() {
$this->assertPageEnd();
$this->assertDumpEnd();
-
}
/**
$minDuration = 2; // We want the dump to take at least this many seconds
$checkpointAfter = 0.5; // Generate checkpoint after this many seconds
-
// Until a dump takes at least $minDuration seconds, perform a dump and check
// duration. If the dump did not take long enough increase the iteration
// count, to generate a bigger stub file next time.
$content .= $tail;
$this->assertEquals( strlen( $content ), file_put_contents(
$fname, $content ), "Length of prepared stub" );
+
return $fname;
}
}
if ( $parameters !== null ) {
$logEntry->setParameters( $parameters );
}
+
return $logEntry->insert();
}
$user2, NS_MAIN, "PageA", "SomeOtherComment",
array( 'key1' => 1, 3 => 'value3' ) );
$this->assertGreaterThan( 0, $this->logId3 );
-
} catch ( Exception $e ) {
// We'd love to pass $e directly. However, ... see
// documentation of exceptionFromAddDBData in
// DumpTestCase
$this->exceptionFromAddDBData = $e;
}
-
}
// the following statement to catch good output
$this->expectOutputString( '' );
}
-
}
// DumpTestCase
$this->exceptionFromAddDBData = $e;
}
-
}
protected function setUp() {
array( $this->pageId2, $this->pageId3, $this->pageId4 ),
array( $this->pageId1 + 1, $this->pageId2 + 1, $this->pageId3 + 1 ),
"Page ids increasing without holes" );
-
}
function testFullTextPlain() {
$this->expectETAOutput();
}
-
-
}
return fopen( 'data://text/plain,' . $this->mockStdinText, 'r' );
}
-
}
/**
$this->textId3 . "\n23\nFetchTextTestPage2Text2"
) ) );
}
-
}
$this->expectOutputRegex( "/^[[:space:]]*\[wgDBprefix\][[:space:]]*=> "
. $wgDBprefix . "$/m" );
}
-
-
}
unset( $_SERVER['argv'][$key] ); // the option
unset( $_SERVER['argv'][$key + 1] ); // its value
$_SERVER['argv'] = array_values( $_SERVER['argv'] );
-
}
}
$file,
);
}
-
}
// Restore settings
return $cases;
}
-
}
** http://valid.no.desc.org/
'
);
-
}
/**
$wgNamespaceAliases['Image'] = NS_FILE;
$wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
-
$wgEnableParserCache = false;
DeferredUpdates::clearPendingUpdates();
$wgMemc = wfGetMainCache();
if ( file_exists( $dir ) ) {
wfDebug( "Already exists!\n" );
+
return $dir;
}
// the UploadFromUrlTest class
class_exists( 'UploadFromUrlTest' );
$suite = new UploadFromUrlTestSuite( 'UploadFromUrlTest' );
+
return $suite;
}
}