w/s changes.

This commit is contained in:
Mark A. Hershberger 2011-06-02 19:32:45 +00:00
parent 9574e81006
commit a6722cc9aa
6 changed files with 51 additions and 51 deletions

View file

@ -21,7 +21,7 @@
*/
class Block {
/* public*/ var $mReason, $mTimestamp, $mAuto, $mExpiry, $mHideName, $mAngryAutoblock;
protected
$mId,
$mFromMaster,
@ -262,7 +262,7 @@ class Block {
# This has the nice property that a /32 block is ranked equally with a
# single-IP block, which is exactly what it is...
$score = self::TYPE_RANGE - 1 + ( $size / 128 );
} else {
$score = $block->getType();
}

View file

@ -40,8 +40,8 @@ class SearchMySQL extends SearchEngine {
parent::__construct( $db );
}
/**
* Parse the user's query and transform it into an SQL fragment which will
/**
* Parse the user's query and transform it into an SQL fragment which will
* become part of a WHERE clause
*
* @param $filteredText string
@ -419,7 +419,7 @@ class SearchMySQL extends SearchEngine {
/**
* Check MySQL server's ft_min_word_len setting so we know
* if we need to pad short words...
*
*
* @return int
*/
protected function minSearchLength() {

View file

@ -48,7 +48,7 @@ class SpecialBlock extends SpecialPage {
/// @var Bool
protected $alreadyBlocked;
/// @var Array
protected $preErrors = array();

View file

@ -1,36 +1,36 @@
<?php
class MediaWikiPHPUnitCommand extends PHPUnit_TextUI_Command {
static $additionalOptions = array(
'regex=' => false,
static $additionalOptions = array(
'regex=' => false,
'file=' => false,
'keep-uploads' => false,
);
public function __construct() {
foreach( self::$additionalOptions as $option => $default ) {
$this->longOptions[$option] = $option . 'Handler';
}
}
public static function main( $exit = true ) {
$command = new self;
$command->run($_SERVER['argv'], $exit);
}
public function __call( $func, $args ) {
$command = new self;
$command->run($_SERVER['argv'], $exit);
}
public function __call( $func, $args ) {
if( substr( $func, -7 ) == 'Handler' ) {
if( is_null( $args[0] ) ) $args[0] = true; //Booleans
self::$additionalOptions[substr( $func, 0, -7 ) ] = $args[0];
}
}
public function showHelp() {
parent::showHelp();
print <<<EOT
ParserTest-specific options:
@ -38,9 +38,9 @@ ParserTest-specific options:
--regex="<regex>" Only run parser tests that match the given regex
--file="<filename>" Prints the version and exits.
--keep-uploads Re-use the same upload directory for each test, don't delete it
EOT;
}
}

View file

@ -18,7 +18,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
*/
const DB_PREFIX = 'unittest_';
const ORA_DB_PREFIX = 'ut_';
protected $supportedDBs = array(
'mysql',
'sqlite',
@ -31,7 +31,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
$this->backupGlobals = false;
$this->backupStaticAttributes = false;
}
function run( PHPUnit_Framework_TestResult $result = NULL ) {
/* Some functions require some kind of caching, and will end up using the db,
* which we can't allow, as that would open a new connection for mysql.
@ -40,11 +40,11 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
ObjectCache::$instances[CACHE_DB] = new HashBagOStuff;
if( $this->needsDB() ) {
global $wgDBprefix;
$this->db = wfGetDB( DB_MASTER );
$this->checkDbIsSupported();
$this->oldTablePrefix = $wgDBprefix;
@ -56,7 +56,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
$this->addCoreDBData();
$this->addDBData();
parent::run( $result );
$this->resetDB();
@ -68,7 +68,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
function dbPrefix() {
return $this->db->getType() == 'oracle' ? self::ORA_DB_PREFIX : self::DB_PREFIX;
}
function needsDB() {
$rc = new ReflectionClass( $this );
return strpos( $rc->getDocComment(), '@group Database' ) !== false;
@ -79,14 +79,14 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
* implement this method and do so
*/
function addDBData() {}
private function addCoreDBData() {
User::resetIdByNameCache();
//Make sysop user
$user = User::newFromName( 'UTSysop' );
if ( $user->idForName() == 0 ) {
$user->addToDatabase();
$user->setPassword( 'UTSysopPassword' );
@ -96,7 +96,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
$user->saveSettings();
}
//Make 1 page with 1 revision
$article = new Article( Title::newFromText( 'UTPage' ) );
$article->doEdit( 'UTContent',
@ -105,7 +105,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
false,
User::newFromName( 'UTSysop' ) );
}
private function initDB() {
global $wgDBprefix;
if ( $wgDBprefix === $this->dbPrefix() ) {
@ -182,7 +182,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
private function assertEmpty2( $value, $msg ) {
return $this->assertTrue( $value == '', $msg );
}
static private function unprefixTable( $tableName ) {
global $wgDBprefix;
return substr( $tableName, strlen( $wgDBprefix ) );
@ -211,25 +211,25 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
}
return $tables;
}
protected function checkDbIsSupported() {
if( !in_array( $this->db->getType(), $this->supportedDBs ) ) {
throw new MWException( $this->db->getType() . " is not currently supported for unit testing." );
}
}
public function getCliArg( $offset ) {
if( isset( MediaWikiPHPUnitCommand::$additionalOptions[$offset] ) ) {
return MediaWikiPHPUnitCommand::$additionalOptions[$offset];
}
}
public function setCliArg( $offset, $value ) {
MediaWikiPHPUnitCommand::$additionalOptions[$offset] = $value;
}
}

View file

@ -12,14 +12,14 @@ class ApiBlockTest extends ApiTestSetup {
parent::setUp();
$this->doLogin();
}
function getTokens() {
return $this->getTokenList( $this->sysopUser );
}
function addDBData() {
$user = User::newFromName( 'UTBlockee' );
if ( $user->getId() == 0 ) {
$user->addToDatabase();
$user->setPassword( 'UTBlockeePassword' );
@ -29,23 +29,23 @@ class ApiBlockTest extends ApiTestSetup {
}
function testMakeNormalBlock() {
$data = $this->getTokens();
$user = User::newFromName( 'UTBlockee' );
if ( !$user->getId() ) {
$this->markTestIncomplete( "The user UTBlockee does not exist" );
}
if( !isset( $data[0]['query']['pages'] ) ) {
$this->markTestIncomplete( "No block token found" );
}
$keys = array_keys( $data[0]['query']['pages'] );
$key = array_pop( $keys );
$pageinfo = $data[0]['query']['pages'][$key];
$data = $this->doApiRequest( array(
'action' => 'block',
'user' => 'UTBlockee',
@ -53,13 +53,13 @@ class ApiBlockTest extends ApiTestSetup {
'token' => $pageinfo['blocktoken'] ), $data );
$block = Block::newFromTarget('UTBlockee');
$this->assertTrue( !is_null( $block ), 'Block is valid' );
$this->assertEquals( 'UTBlockee', (string)$block->getTarget() );
$this->assertEquals( 'Some reason', $block->mReason );
$this->assertEquals( 'infinity', $block->mExpiry );
}
}