Index: trunk/phase3/tests/phpunit/MediaWikiTestCase.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | */ |
20 | 20 | const DB_PREFIX = 'unittest_'; |
21 | 21 | const ORA_DB_PREFIX = 'ut_'; |
22 | | - |
| 22 | + |
23 | 23 | protected $supportedDBs = array( |
24 | 24 | 'mysql', |
25 | 25 | 'sqlite', |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | $this->backupGlobals = false; |
33 | 33 | $this->backupStaticAttributes = false; |
34 | 34 | } |
35 | | - |
| 35 | + |
36 | 36 | function run( PHPUnit_Framework_TestResult $result = NULL ) { |
37 | 37 | /* Some functions require some kind of caching, and will end up using the db, |
38 | 38 | * which we can't allow, as that would open a new connection for mysql. |
— | — | @@ -40,11 +40,11 @@ |
41 | 41 | ObjectCache::$instances[CACHE_DB] = new HashBagOStuff; |
42 | 42 | |
43 | 43 | if( $this->needsDB() ) { |
44 | | - |
| 44 | + |
45 | 45 | global $wgDBprefix; |
46 | | - |
| 46 | + |
47 | 47 | $this->db = wfGetDB( DB_MASTER ); |
48 | | - |
| 48 | + |
49 | 49 | $this->checkDbIsSupported(); |
50 | 50 | |
51 | 51 | $this->oldTablePrefix = $wgDBprefix; |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | |
58 | 58 | $this->addCoreDBData(); |
59 | 59 | $this->addDBData(); |
60 | | - |
| 60 | + |
61 | 61 | parent::run( $result ); |
62 | 62 | |
63 | 63 | $this->resetDB(); |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | function dbPrefix() { |
70 | 70 | return $this->db->getType() == 'oracle' ? self::ORA_DB_PREFIX : self::DB_PREFIX; |
71 | 71 | } |
72 | | - |
| 72 | + |
73 | 73 | function needsDB() { |
74 | 74 | $rc = new ReflectionClass( $this ); |
75 | 75 | return strpos( $rc->getDocComment(), '@group Database' ) !== false; |
— | — | @@ -79,14 +79,14 @@ |
80 | 80 | * implement this method and do so |
81 | 81 | */ |
82 | 82 | function addDBData() {} |
83 | | - |
| 83 | + |
84 | 84 | private function addCoreDBData() { |
85 | 85 | |
86 | 86 | User::resetIdByNameCache(); |
87 | 87 | |
88 | 88 | //Make sysop user |
89 | 89 | $user = User::newFromName( 'UTSysop' ); |
90 | | - |
| 90 | + |
91 | 91 | if ( $user->idForName() == 0 ) { |
92 | 92 | $user->addToDatabase(); |
93 | 93 | $user->setPassword( 'UTSysopPassword' ); |
— | — | @@ -96,7 +96,7 @@ |
97 | 97 | $user->saveSettings(); |
98 | 98 | } |
99 | 99 | |
100 | | - |
| 100 | + |
101 | 101 | //Make 1 page with 1 revision |
102 | 102 | $article = new Article( Title::newFromText( 'UTPage' ) ); |
103 | 103 | $article->doEdit( 'UTContent', |
— | — | @@ -105,7 +105,7 @@ |
106 | 106 | false, |
107 | 107 | User::newFromName( 'UTSysop' ) ); |
108 | 108 | } |
109 | | - |
| 109 | + |
110 | 110 | private function initDB() { |
111 | 111 | global $wgDBprefix; |
112 | 112 | if ( $wgDBprefix === $this->dbPrefix() ) { |
— | — | @@ -182,7 +182,7 @@ |
183 | 183 | private function assertEmpty2( $value, $msg ) { |
184 | 184 | return $this->assertTrue( $value == '', $msg ); |
185 | 185 | } |
186 | | - |
| 186 | + |
187 | 187 | static private function unprefixTable( $tableName ) { |
188 | 188 | global $wgDBprefix; |
189 | 189 | return substr( $tableName, strlen( $wgDBprefix ) ); |
— | — | @@ -211,25 +211,25 @@ |
212 | 212 | } |
213 | 213 | return $tables; |
214 | 214 | } |
215 | | - |
| 215 | + |
216 | 216 | protected function checkDbIsSupported() { |
217 | 217 | if( !in_array( $this->db->getType(), $this->supportedDBs ) ) { |
218 | 218 | throw new MWException( $this->db->getType() . " is not currently supported for unit testing." ); |
219 | 219 | } |
220 | 220 | } |
221 | | - |
| 221 | + |
222 | 222 | public function getCliArg( $offset ) { |
223 | | - |
| 223 | + |
224 | 224 | if( isset( MediaWikiPHPUnitCommand::$additionalOptions[$offset] ) ) { |
225 | 225 | return MediaWikiPHPUnitCommand::$additionalOptions[$offset]; |
226 | 226 | } |
227 | | - |
| 227 | + |
228 | 228 | } |
229 | | - |
| 229 | + |
230 | 230 | public function setCliArg( $offset, $value ) { |
231 | | - |
| 231 | + |
232 | 232 | MediaWikiPHPUnitCommand::$additionalOptions[$offset] = $value; |
233 | | - |
| 233 | + |
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
Index: trunk/phase3/tests/phpunit/MediaWikiPHPUnitCommand.php |
— | — | @@ -1,36 +1,36 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class MediaWikiPHPUnitCommand extends PHPUnit_TextUI_Command { |
5 | | - |
6 | | - static $additionalOptions = array( |
7 | | - 'regex=' => false, |
| 5 | + |
| 6 | + static $additionalOptions = array( |
| 7 | + 'regex=' => false, |
8 | 8 | 'file=' => false, |
9 | 9 | 'keep-uploads' => false, |
10 | 10 | ); |
11 | | - |
| 11 | + |
12 | 12 | public function __construct() { |
13 | 13 | foreach( self::$additionalOptions as $option => $default ) { |
14 | 14 | $this->longOptions[$option] = $option . 'Handler'; |
15 | 15 | } |
16 | | - |
| 16 | + |
17 | 17 | } |
18 | | - |
| 18 | + |
19 | 19 | public static function main( $exit = true ) { |
20 | | - $command = new self; |
21 | | - $command->run($_SERVER['argv'], $exit); |
22 | | - } |
23 | | - |
24 | | - public function __call( $func, $args ) { |
25 | | - |
| 20 | + $command = new self; |
| 21 | + $command->run($_SERVER['argv'], $exit); |
| 22 | + } |
| 23 | + |
| 24 | + public function __call( $func, $args ) { |
| 25 | + |
26 | 26 | if( substr( $func, -7 ) == 'Handler' ) { |
27 | 27 | if( is_null( $args[0] ) ) $args[0] = true; //Booleans |
28 | 28 | self::$additionalOptions[substr( $func, 0, -7 ) ] = $args[0]; |
29 | 29 | } |
30 | 30 | } |
31 | | - |
| 31 | + |
32 | 32 | public function showHelp() { |
33 | 33 | parent::showHelp(); |
34 | | - |
| 34 | + |
35 | 35 | print <<<EOT |
36 | 36 | |
37 | 37 | ParserTest-specific options: |
— | — | @@ -38,9 +38,9 @@ |
39 | 39 | --regex="<regex>" Only run parser tests that match the given regex |
40 | 40 | --file="<filename>" Prints the version and exits. |
41 | 41 | --keep-uploads Re-use the same upload directory for each test, don't delete it |
42 | | - |
43 | 42 | |
| 43 | + |
44 | 44 | EOT; |
45 | 45 | } |
46 | | - |
| 46 | + |
47 | 47 | } |
Index: trunk/phase3/tests/phpunit/includes/api/ApiBlockTest.php |
— | — | @@ -12,14 +12,14 @@ |
13 | 13 | parent::setUp(); |
14 | 14 | $this->doLogin(); |
15 | 15 | } |
16 | | - |
| 16 | + |
17 | 17 | function getTokens() { |
18 | 18 | return $this->getTokenList( $this->sysopUser ); |
19 | 19 | } |
20 | 20 | |
21 | 21 | function addDBData() { |
22 | 22 | $user = User::newFromName( 'UTBlockee' ); |
23 | | - |
| 23 | + |
24 | 24 | if ( $user->getId() == 0 ) { |
25 | 25 | $user->addToDatabase(); |
26 | 26 | $user->setPassword( 'UTBlockeePassword' ); |
— | — | @@ -29,23 +29,23 @@ |
30 | 30 | } |
31 | 31 | |
32 | 32 | function testMakeNormalBlock() { |
33 | | - |
| 33 | + |
34 | 34 | $data = $this->getTokens(); |
35 | | - |
| 35 | + |
36 | 36 | $user = User::newFromName( 'UTBlockee' ); |
37 | | - |
| 37 | + |
38 | 38 | if ( !$user->getId() ) { |
39 | 39 | $this->markTestIncomplete( "The user UTBlockee does not exist" ); |
40 | 40 | } |
41 | | - |
| 41 | + |
42 | 42 | if( !isset( $data[0]['query']['pages'] ) ) { |
43 | 43 | $this->markTestIncomplete( "No block token found" ); |
44 | 44 | } |
45 | | - |
| 45 | + |
46 | 46 | $keys = array_keys( $data[0]['query']['pages'] ); |
47 | 47 | $key = array_pop( $keys ); |
48 | 48 | $pageinfo = $data[0]['query']['pages'][$key]; |
49 | | - |
| 49 | + |
50 | 50 | $data = $this->doApiRequest( array( |
51 | 51 | 'action' => 'block', |
52 | 52 | 'user' => 'UTBlockee', |
— | — | @@ -53,13 +53,13 @@ |
54 | 54 | 'token' => $pageinfo['blocktoken'] ), $data ); |
55 | 55 | |
56 | 56 | $block = Block::newFromTarget('UTBlockee'); |
57 | | - |
| 57 | + |
58 | 58 | $this->assertTrue( !is_null( $block ), 'Block is valid' ); |
59 | 59 | |
60 | 60 | $this->assertEquals( 'UTBlockee', (string)$block->getTarget() ); |
61 | 61 | $this->assertEquals( 'Some reason', $block->mReason ); |
62 | 62 | $this->assertEquals( 'infinity', $block->mExpiry ); |
63 | | - |
| 63 | + |
64 | 64 | } |
65 | 65 | |
66 | 66 | } |
Index: trunk/phase3/includes/search/SearchMySQL.php |
— | — | @@ -40,8 +40,8 @@ |
41 | 41 | parent::__construct( $db ); |
42 | 42 | } |
43 | 43 | |
44 | | - /** |
45 | | - * Parse the user's query and transform it into an SQL fragment which will |
| 44 | + /** |
| 45 | + * Parse the user's query and transform it into an SQL fragment which will |
46 | 46 | * become part of a WHERE clause |
47 | 47 | * |
48 | 48 | * @param $filteredText string |
— | — | @@ -419,7 +419,7 @@ |
420 | 420 | /** |
421 | 421 | * Check MySQL server's ft_min_word_len setting so we know |
422 | 422 | * if we need to pad short words... |
423 | | - * |
| 423 | + * |
424 | 424 | * @return int |
425 | 425 | */ |
426 | 426 | protected function minSearchLength() { |
Index: trunk/phase3/includes/specials/SpecialBlock.php |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | |
50 | 50 | /// @var Bool |
51 | 51 | protected $alreadyBlocked; |
52 | | - |
| 52 | + |
53 | 53 | /// @var Array |
54 | 54 | protected $preErrors = array(); |
55 | 55 | |
Index: trunk/phase3/includes/Block.php |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | */ |
23 | 23 | class Block { |
24 | 24 | /* public*/ var $mReason, $mTimestamp, $mAuto, $mExpiry, $mHideName, $mAngryAutoblock; |
25 | | - |
| 25 | + |
26 | 26 | protected |
27 | 27 | $mId, |
28 | 28 | $mFromMaster, |
— | — | @@ -262,7 +262,7 @@ |
263 | 263 | # This has the nice property that a /32 block is ranked equally with a |
264 | 264 | # single-IP block, which is exactly what it is... |
265 | 265 | $score = self::TYPE_RANGE - 1 + ( $size / 128 ); |
266 | | - |
| 266 | + |
267 | 267 | } else { |
268 | 268 | $score = $block->getType(); |
269 | 269 | } |