From a6722cc9aa2e30467ed9217d8a5388ce1cfcd9a9 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Thu, 2 Jun 2011 19:32:45 +0000 Subject: [PATCH] w/s changes. --- includes/Block.php | 4 +-- includes/search/SearchMySQL.php | 6 ++-- includes/specials/SpecialBlock.php | 2 +- tests/phpunit/MediaWikiPHPUnitCommand.php | 32 ++++++++--------- tests/phpunit/MediaWikiTestCase.php | 38 ++++++++++----------- tests/phpunit/includes/api/ApiBlockTest.php | 20 +++++------ 6 files changed, 51 insertions(+), 51 deletions(-) diff --git a/includes/Block.php b/includes/Block.php index 25b02ff889..fb294f1fb0 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -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(); } diff --git a/includes/search/SearchMySQL.php b/includes/search/SearchMySQL.php index a2c27ba73f..c52c9e5b20 100644 --- a/includes/search/SearchMySQL.php +++ b/includes/search/SearchMySQL.php @@ -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() { diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index 0b846ac0ac..b481b90e35 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -48,7 +48,7 @@ class SpecialBlock extends SpecialPage { /// @var Bool protected $alreadyBlocked; - + /// @var Array protected $preErrors = array(); diff --git a/tests/phpunit/MediaWikiPHPUnitCommand.php b/tests/phpunit/MediaWikiPHPUnitCommand.php index 6ca9976be5..c0d9f3637e 100644 --- a/tests/phpunit/MediaWikiPHPUnitCommand.php +++ b/tests/phpunit/MediaWikiPHPUnitCommand.php @@ -1,36 +1,36 @@ 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 <<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; - + } } diff --git a/tests/phpunit/includes/api/ApiBlockTest.php b/tests/phpunit/includes/api/ApiBlockTest.php index a7dbcf8384..b90e77b642 100644 --- a/tests/phpunit/includes/api/ApiBlockTest.php +++ b/tests/phpunit/includes/api/ApiBlockTest.php @@ -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 ); - + } } -- 2.20.1