Index: trunk/phase3/maintenance/tests/selenium/SeleniumTestSuite.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | const RESULT_ERROR = 3; |
13 | 13 | |
14 | 14 | public abstract function addTests(); |
15 | | - |
| 15 | + |
16 | 16 | public function setUp() { |
17 | 17 | // Hack because because PHPUnit version 3.0.6 which is on prototype does not |
18 | 18 | // run setUp as part of TestSuite::run |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | public function loadPage( $title, $action ) { |
41 | 41 | $this->selenium->loadPage( $title, $action ); |
42 | 42 | } |
43 | | - |
| 43 | + |
44 | 44 | protected function setLoginBeforeTests( $loginBeforeTests = true ) { |
45 | 45 | $this->loginBeforeTests = $loginBeforeTests; |
46 | 46 | } |
Index: trunk/phase3/maintenance/tests/selenium/Selenium.php |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | self::$_instance = $this; |
43 | 43 | } else { |
44 | 44 | throw new MWException( "Already have one Selenium instance." ); |
45 | | - } |
| 45 | + } |
46 | 46 | } |
47 | 47 | |
48 | 48 | public function start() { |
— | — | @@ -62,7 +62,7 @@ |
63 | 63 | public function login() { |
64 | 64 | if ( strlen( $this->user ) == 0 ) { |
65 | 65 | return; |
66 | | - } |
| 66 | + } |
67 | 67 | $this->open( self::$url . '/index.php?title=Special:Userlogin' ); |
68 | 68 | $this->type( 'wpName1', $this->user ); |
69 | 69 | $this->type( 'wpPassword1', $this->pass ); |
— | — | @@ -133,7 +133,7 @@ |
134 | 134 | public function setVerbose( $verbose ) { |
135 | 135 | $this->verbose = $verbose; |
136 | 136 | } |
137 | | - |
| 137 | + |
138 | 138 | public function setAvailableBrowsers( $availableBrowsers ) { |
139 | 139 | $this->browsers = $availableBrowsers; |
140 | 140 | } |
— | — | @@ -141,15 +141,15 @@ |
142 | 142 | public function setJUnitLogfile( $junitlogfile ) { |
143 | 143 | $this->junitlogfile = $junitlogfile; |
144 | 144 | } |
145 | | - |
| 145 | + |
146 | 146 | public function getJUnitLogfile( ) { |
147 | 147 | return $this->junitlogfile; |
148 | | - } |
149 | | - |
| 148 | + } |
| 149 | + |
150 | 150 | public function setRunAgainstGrid( $runagainstgrid ) { |
151 | 151 | $this->runagainstgrid = $runagainstgrid; |
152 | 152 | } |
153 | | - |
| 153 | + |
154 | 154 | public function setBrowser( $b ) { |
155 | 155 | if ($this->runagainstgrid) { |
156 | 156 | $this->browser = $b; |
— | — | @@ -161,7 +161,7 @@ |
162 | 162 | |
163 | 163 | $this->browser = $this->browsers[$b]; |
164 | 164 | } |
165 | | - |
| 165 | + |
166 | 166 | public function getAvailableBrowsers() { |
167 | 167 | return $this->browsers; |
168 | 168 | } |
Index: trunk/phase3/maintenance/tests/selenium/SeleniumServerManager.php |
— | — | @@ -34,8 +34,8 @@ |
35 | 35 | private $SeleniumServerExecPath; |
36 | 36 | |
37 | 37 | public function __construct( $startServer, |
38 | | - $serverPort, |
39 | | - $serverExecPath ) { |
| 38 | + $serverPort, |
| 39 | + $serverExecPath ) { |
40 | 40 | $this->OS = (string) PHP_OS; |
41 | 41 | if ( isset( $startServer ) ) |
42 | 42 | $this->SeleniumStartServer = $startServer; |
— | — | @@ -172,11 +172,11 @@ |
173 | 173 | |
174 | 174 | $commandSuffix = ' > /dev/null 2>&1'. ' & echo $!'; |
175 | 175 | $portText = ' -port ' . $this->SeleniumServerPort; |
176 | | - $command = "java -jar " . |
| 176 | + $command = "java -jar " . |
177 | 177 | escapeshellarg($this->SeleniumServerExecPath) . |
178 | 178 | $portText . $commandSuffix; |
179 | | - exec($command ,$op); |
180 | | - $pid = (int)$op[0]; |
| 179 | + exec($command ,$op); |
| 180 | + $pid = (int)$op[0]; |
181 | 181 | if ( $pid != "" ) |
182 | 182 | $this->SeleniumServerPid = $pid; |
183 | 183 | else { |
— | — | @@ -190,8 +190,8 @@ |
191 | 191 | |
192 | 192 | wfSuppressWarnings(); |
193 | 193 | for ( $cnt = 1; |
194 | | - $cnt <= $this->SeleniumServerStartTimeout; |
195 | | - $cnt++ ) { |
| 194 | + $cnt <= $this->SeleniumServerStartTimeout; |
| 195 | + $cnt++ ) { |
196 | 196 | $fp = fsockopen ( 'localhost', |
197 | 197 | $this->SeleniumServerPort, |
198 | 198 | $errno, $errstr, 0 ); |
— | — | @@ -212,19 +212,19 @@ |
213 | 213 | else return 'running'; |
214 | 214 | |
215 | 215 | } |
216 | | - // No Server execution path defined. |
| 216 | + // No Server execution path defined. |
217 | 217 | return 'failed'; |
218 | 218 | } |
219 | 219 | |
220 | 220 | private function startServerOnWindows() { |
221 | | - // Unimplemented. |
| 221 | + // Unimplemented. |
222 | 222 | return 'failed'; |
223 | 223 | } |
224 | 224 | |
225 | 225 | private function stopServerOnUnix() { |
226 | 226 | |
227 | 227 | if ( !empty( $this->SeleniumServerPid ) && |
228 | | - $this->SeleniumServerPid != 'NaN' ) { |
| 228 | + $this->SeleniumServerPid != 'NaN' ) { |
229 | 229 | exec( "kill -9 " . $this->SeleniumServerPid ); |
230 | 230 | return 'stopped'; |
231 | 231 | } |
— | — | @@ -232,7 +232,7 @@ |
233 | 233 | } |
234 | 234 | |
235 | 235 | private function stopServerOnWindows() { |
236 | | - // Unimplemented. |
| 236 | + // Unimplemented. |
237 | 237 | return 'failed'; |
238 | 238 | |
239 | 239 | } |
Index: trunk/phase3/maintenance/tests/selenium/SeleniumConfig.php |
— | — | @@ -4,16 +4,16 @@ |
5 | 5 | } |
6 | 6 | |
7 | 7 | class SeleniumConfig { |
8 | | - |
| 8 | + |
9 | 9 | /* |
10 | 10 | * Retreives the Selenium configuration values from an ini file. |
11 | 11 | * See sample config file in selenium_settings.ini.sample |
12 | | - * |
| 12 | + * |
13 | 13 | */ |
14 | 14 | |
15 | | - public static function getSeleniumSettings ( &$seleniumSettings, |
16 | | - &$seleniumBrowsers, |
17 | | - &$seleniumTestSuites, |
| 15 | + public static function getSeleniumSettings ( &$seleniumSettings, |
| 16 | + &$seleniumBrowsers, |
| 17 | + &$seleniumTestSuites, |
18 | 18 | $seleniumConfigFile = null ) { |
19 | 19 | if ( strlen( $seleniumConfigFile ) == 0 ) { |
20 | 20 | global $wgSeleniumConfigFile; |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | if ( strlen( $seleniumConfigFile ) == 0 || !file_exists( $seleniumConfigFile ) ) { |
25 | 25 | throw new MWException( "Unable to read local Selenium Settings from " . $seleniumConfigFile . "\n" ); |
26 | 26 | } |
27 | | - |
| 27 | + |
28 | 28 | if ( !defined( 'PHP_VERSION_ID' ) || |
29 | 29 | ( PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 3 ) ) { |
30 | 30 | $configArray = self::parse_5_2_ini_file( $seleniumConfigFile ); |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 | wfSuppressWarnings(); |
40 | 40 | //we may need to change how this is set. But for now leave it in the ini file |
41 | 41 | $seleniumBrowsers = $configArray['SeleniumSettings']['browsers']; |
42 | | - |
| 42 | + |
43 | 43 | $seleniumSettings['host'] = $configArray['SeleniumSettings']['host']; |
44 | 44 | $seleniumSettings['port'] = $configArray['SeleniumSettings']['port']; |
45 | 45 | $seleniumSettings['wikiUrl'] = $configArray['SeleniumSettings']['wikiUrl']; |
— | — | @@ -58,7 +58,7 @@ |
59 | 59 | $seleniumTestSuites = $configArray['SeleniumTests']['testSuite']; |
60 | 60 | wfRestoreWarnings(); |
61 | 61 | } |
62 | | - return true; |
| 62 | + return true; |
63 | 63 | } |
64 | 64 | |
65 | 65 | private static function parse_5_2_ini_file ( $ConfigFile ) { |
Index: trunk/phase3/maintenance/tests/parserTests.php |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | require_once( dirname( __FILE__ ) . '/../commandLine.inc' ); |
32 | 32 | |
33 | 33 | if ( isset( $options['help'] ) ) { |
34 | | - echo <<<ENDS |
| 34 | + echo <<<ENDS |
35 | 35 | MediaWiki $wgVersion parser test suite |
36 | 36 | Usage: php parserTests.php [options...] |
37 | 37 | |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | --quiet Suppress notification of passed tests (shows only failed tests) |
41 | 41 | --show-output Show expected and actual output |
42 | 42 | --color[=yes|no] Override terminal detection and force color output on or off |
43 | | - use wgCommandLineDarkBg = true; if your term is dark |
| 43 | + use wgCommandLineDarkBg = true; if your term is dark |
44 | 44 | --regex Only run tests whose descriptions which match given regex |
45 | 45 | --file=<testfile> Run test cases from a custom file instead of parserTests.txt |
46 | 46 | --record Record tests in database |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | --upload Upload test results to remote wiki (per \$wgParserTestRemote) |
56 | 56 | |
57 | 57 | ENDS; |
58 | | - exit( 0 ); |
| 58 | + exit( 0 ); |
59 | 59 | } |
60 | 60 | |
61 | 61 | # Cases of weird db corruption were encountered when running tests on earlyish |
Index: trunk/phase3/maintenance/tests/phpunit/includes/TitlePermissionTest.php |
— | — | @@ -273,7 +273,7 @@ |
274 | 274 | '' => array( array( ), array( ), array( ), true ) ); |
275 | 275 | global $wgUser; |
276 | 276 | $wgUser = self::$user; |
277 | | - foreach ( array( "edit", "protect", "" ) as $action ) { |
| 277 | + foreach ( array( "edit", "protect", "" ) as $action ) { |
278 | 278 | $this->setUserPerm( null ); |
279 | 279 | $this->assertEquals( $check[$action][0], |
280 | 280 | self::$title->getUserPermissionsErrors( $action, self::$user, true ) ); |
Index: trunk/phase3/maintenance/tests/phpunit/includes/UploadFromUrlTest.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | ini_set( 'log_errors', 1 ); |
21 | 21 | ini_set( 'error_reporting', 1 ); |
22 | 22 | ini_set( 'display_errors', 1 ); |
23 | | - |
| 23 | + |
24 | 24 | if ( wfLocalFile( 'UploadFromUrlTest.png' )->exists() ) { |
25 | 25 | $this->deleteFile( 'UploadFromUrlTest.png' ); |
26 | 26 | } |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | protected function doApiRequest( $params, $unused = null ) { |
30 | 30 | $sessionId = session_id(); |
31 | 31 | session_write_close(); |
32 | | - |
| 32 | + |
33 | 33 | $req = new FauxRequest( $params, true, $_SESSION ); |
34 | 34 | $module = new ApiMain( $req, true ); |
35 | 35 | $module->execute(); |
— | — | @@ -77,7 +77,7 @@ |
78 | 78 | * @depends testLogin |
79 | 79 | * @depends testClearQueue |
80 | 80 | */ |
81 | | - public function testSetupUrlDownload( $data ) { |
| 81 | + public function testSetupUrlDownload( $data ) { |
82 | 82 | $token = self::$user->editToken(); |
83 | 83 | $exception = false; |
84 | 84 | |
— | — | @@ -142,7 +142,7 @@ |
143 | 143 | ), $data ); |
144 | 144 | |
145 | 145 | $this->assertEquals( $data[0]['upload']['result'], 'Queued', 'Queued upload' ); |
146 | | - |
| 146 | + |
147 | 147 | $job = Job::pop(); |
148 | 148 | $this->assertThat( $job, $this->isInstanceOf( 'UploadFromUrlJob' ), 'Queued upload inserted' ); |
149 | 149 | } |
— | — | @@ -160,7 +160,7 @@ |
161 | 161 | $this->assertEquals( $data[0]['upload']['result'], 'Success' ); |
162 | 162 | $this->assertEquals( $data[0]['upload']['filename'], 'UploadFromUrlTest.png' ); |
163 | 163 | $this->assertTrue( wfLocalFile( $data[0]['upload']['filename'] )->exists() ); |
164 | | - |
| 164 | + |
165 | 165 | $this->deleteFile( 'UploadFromUrlTest.png' ); |
166 | 166 | |
167 | 167 | return $data; |
— | — | @@ -177,11 +177,11 @@ |
178 | 178 | |
179 | 179 | |
180 | 180 | $data = $this->doAsyncUpload( $token ); |
181 | | - |
| 181 | + |
182 | 182 | $this->assertEquals( $data[0]['upload']['result'], 'Warning' ); |
183 | 183 | $this->assertTrue( isset( $data[0]['upload']['sessionkey'] ) ); |
184 | | - |
185 | | - $data = $this->doApiRequest( array( |
| 184 | + |
| 185 | + $data = $this->doApiRequest( array( |
186 | 186 | 'action' => 'upload', |
187 | 187 | 'sessionkey' => $data[0]['upload']['sessionkey'], |
188 | 188 | 'filename' => 'UploadFromUrlTest.png', |
— | — | @@ -191,7 +191,7 @@ |
192 | 192 | $this->assertEquals( $data[0]['upload']['result'], 'Success' ); |
193 | 193 | $this->assertEquals( $data[0]['upload']['filename'], 'UploadFromUrlTest.png' ); |
194 | 194 | $this->assertTrue( wfLocalFile( $data[0]['upload']['filename'] )->exists() ); |
195 | | - |
| 195 | + |
196 | 196 | $this->deleteFile( 'UploadFromUrlTest.png' ); |
197 | 197 | |
198 | 198 | return $data; |
— | — | @@ -224,18 +224,18 @@ |
225 | 225 | |
226 | 226 | return $data; |
227 | 227 | } |
228 | | - |
| 228 | + |
229 | 229 | public function testLeaveMessage() { |
230 | 230 | $token = self::$user->editToken(); |
231 | | - |
| 231 | + |
232 | 232 | $talk = self::$user->getTalkPage(); |
233 | 233 | if ( $talk->exists() ) { |
234 | 234 | $a = new Article( $talk ); |
235 | 235 | $a->doDeleteArticle( '' ); |
236 | 236 | } |
237 | | - |
| 237 | + |
238 | 238 | $this->assertFalse( (bool)$talk->getArticleId( Title::GAID_FOR_UPDATE ), 'User talk does not exist' ); |
239 | | - |
| 239 | + |
240 | 240 | $data = $this->doApiRequest( array( |
241 | 241 | 'action' => 'upload', |
242 | 242 | 'filename' => 'UploadFromUrlTest.png', |
— | — | @@ -245,19 +245,19 @@ |
246 | 246 | 'leavemessage' => 1, |
247 | 247 | 'ignorewarnings' => 1, |
248 | 248 | ) ); |
249 | | - |
| 249 | + |
250 | 250 | $job = Job::pop(); |
251 | 251 | $this->assertEquals( 'UploadFromUrlJob', get_class( $job ) ); |
252 | 252 | $job->run(); |
253 | | - |
254 | | - $this->assertTrue( wfLocalFile( 'UploadFromUrlTest.png' )->exists() ); |
| 253 | + |
| 254 | + $this->assertTrue( wfLocalFile( 'UploadFromUrlTest.png' )->exists() ); |
255 | 255 | $this->assertTrue( (bool)$talk->getArticleId( Title::GAID_FOR_UPDATE ), 'User talk exists' ); |
256 | | - |
| 256 | + |
257 | 257 | $this->deleteFile( 'UploadFromUrlTest.png' ); |
258 | | - |
| 258 | + |
259 | 259 | $talkRev = Revision::newFromTitle( $talk ); |
260 | 260 | $talkSize = $talkRev->getSize(); |
261 | | - |
| 261 | + |
262 | 262 | $exception = false; |
263 | 263 | try { |
264 | 264 | $data = $this->doApiRequest( array( |
— | — | @@ -273,27 +273,27 @@ |
274 | 274 | $this->assertEquals( 'Using leavemessage without ignorewarnings is not supported', $e->getMessage() ); |
275 | 275 | } |
276 | 276 | $this->assertTrue( $exception ); |
277 | | - |
| 277 | + |
278 | 278 | $job = Job::pop(); |
279 | 279 | $this->assertFalse( $job ); |
280 | | - |
| 280 | + |
281 | 281 | return; |
282 | 282 | |
283 | 283 | /** |
284 | 284 | // Broken until using leavemessage with ignorewarnings is supported |
285 | 285 | $job->run(); |
286 | | - |
| 286 | + |
287 | 287 | $this->assertFalse( wfLocalFile( 'UploadFromUrlTest.png' )->exists() ); |
288 | | - |
| 288 | + |
289 | 289 | $talkRev = Revision::newFromTitle( $talk ); |
290 | 290 | $this->assertTrue( $talkRev->getSize() > $talkSize, 'New message left' ); |
291 | 291 | */ |
292 | 292 | } |
293 | | - |
| 293 | + |
294 | 294 | /** |
295 | | - * Helper function to perform an async upload, execute the job and fetch |
| 295 | + * Helper function to perform an async upload, execute the job and fetch |
296 | 296 | * the status |
297 | | - * |
| 297 | + * |
298 | 298 | * @return array The result of action=upload&statuskey=key |
299 | 299 | */ |
300 | 300 | private function doAsyncUpload( $token, $ignoreWarnings = false, $leaveMessage = false ) { |
— | — | @@ -310,28 +310,28 @@ |
311 | 311 | if ( $leaveMessage ) { |
312 | 312 | $params['leavemessage'] = 1; |
313 | 313 | } |
314 | | - |
| 314 | + |
315 | 315 | $data = $this->doApiRequest( $params ); |
316 | 316 | $this->assertEquals( $data[0]['upload']['result'], 'Queued' ); |
317 | 317 | $this->assertTrue( isset( $data[0]['upload']['statuskey'] ) ); |
318 | 318 | $statusKey = $data[0]['upload']['statuskey']; |
319 | | - |
| 319 | + |
320 | 320 | $job = Job::pop(); |
321 | 321 | $this->assertEquals( 'UploadFromUrlJob', get_class( $job ) ); |
322 | | - |
323 | | - $status = $job->run(); |
| 322 | + |
| 323 | + $status = $job->run(); |
324 | 324 | $this->assertTrue( $status ); |
325 | | - |
326 | | - $data = $this->doApiRequest( array( |
| 325 | + |
| 326 | + $data = $this->doApiRequest( array( |
327 | 327 | 'action' => 'upload', |
328 | 328 | 'statuskey' => $statusKey, |
329 | 329 | 'token' => $token, |
330 | 330 | ) ); |
331 | | - |
| 331 | + |
332 | 332 | return $data; |
333 | 333 | } |
334 | | - |
335 | 334 | |
| 335 | + |
336 | 336 | /** |
337 | 337 | * |
338 | 338 | */ |
Index: trunk/phase3/maintenance/tests/phpunit/includes/SiteConfigurationTest.php |
— | — | @@ -287,7 +287,7 @@ |
288 | 288 | 'get(): parameter replacement on an non-existing wiki' |
289 | 289 | ); |
290 | 290 | } |
291 | | - |
| 291 | + |
292 | 292 | function testGetAll() { |
293 | 293 | $this->mConf->siteParamsCallback = 'getSiteParams'; |
294 | 294 | |
Index: trunk/phase3/maintenance/tests/phpunit/includes/db/DatabaseSqliteTest.php |
— | — | @@ -65,7 +65,7 @@ |
66 | 66 | $this->replaceVars( "ALTER TABLE foo\nADD COLUMN foo_bar int(10) unsigned DEFAULT 42" ) |
67 | 67 | ); |
68 | 68 | } |
69 | | - |
| 69 | + |
70 | 70 | public function testTableName() { |
71 | 71 | // @todo Moar! |
72 | 72 | $db = new DatabaseSqliteStandalone( ':memory:' ); |
Index: trunk/phase3/maintenance/tests/phpunit/includes/XmlTest.php |
— | — | @@ -115,7 +115,7 @@ |
116 | 116 | ); |
117 | 117 | $this->assertEquals( |
118 | 118 | '<label for="id" class="nice">name</label>', |
119 | | - Xml::label( 'name', 'id', array( |
| 119 | + Xml::label( 'name', 'id', array( |
120 | 120 | 'generated' => true, |
121 | 121 | 'class' => 'nice', |
122 | 122 | 'anotherattr' => 'value', |
Index: trunk/phase3/maintenance/tests/phpunit/includes/GlobalTest.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | unlink( $wgReadOnlyFile ); |
10 | 10 | $wgContLang = $wgLang = Language::factory( 'en' ); |
11 | 11 | } |
12 | | - |
| 12 | + |
13 | 13 | function tearDown() { |
14 | 14 | global $wgReadOnlyFile; |
15 | 15 | if ( file_exists( $wgReadOnlyFile ) ) { |
— | — | @@ -16,7 +16,7 @@ |
17 | 17 | } |
18 | 18 | $wgReadOnlyFile = $this->originals['wgReadOnlyFile']; |
19 | 19 | } |
20 | | - |
| 20 | + |
21 | 21 | function testRandom() { |
22 | 22 | # This could hypothetically fail, but it shouldn't ;) |
23 | 23 | $this->assertFalse( |
— | — | @@ -32,25 +32,25 @@ |
33 | 33 | function testReadOnlyEmpty() { |
34 | 34 | global $wgReadOnly; |
35 | 35 | $wgReadOnly = null; |
36 | | - |
| 36 | + |
37 | 37 | $this->assertFalse( wfReadOnly() ); |
38 | 38 | $this->assertFalse( wfReadOnly() ); |
39 | 39 | } |
40 | 40 | |
41 | 41 | function testReadOnlySet() { |
42 | 42 | global $wgReadOnly, $wgReadOnlyFile; |
43 | | - |
| 43 | + |
44 | 44 | $f = fopen( $wgReadOnlyFile, "wt" ); |
45 | 45 | fwrite( $f, 'Message' ); |
46 | 46 | fclose( $f ); |
47 | 47 | $wgReadOnly = null; |
48 | | - |
| 48 | + |
49 | 49 | $this->assertTrue( wfReadOnly() ); |
50 | 50 | $this->assertTrue( wfReadOnly() ); |
51 | 51 | |
52 | 52 | unlink( $wgReadOnlyFile ); |
53 | 53 | $wgReadOnly = null; |
54 | | - |
| 54 | + |
55 | 55 | $this->assertFalse( wfReadOnly() ); |
56 | 56 | $this->assertFalse( wfReadOnly() ); |
57 | 57 | } |
— | — | @@ -195,53 +195,53 @@ |
196 | 196 | '20010115T123456Z', |
197 | 197 | wfTimestamp( TS_ISO_8601_BASIC, '2001-01-15 12:34:56' ), |
198 | 198 | 'TS_DB to TS_ISO_8601_BASIC' ); |
199 | | - |
| 199 | + |
200 | 200 | # rfc2822 section 3.3 |
201 | | - |
| 201 | + |
202 | 202 | $this->assertEquals( |
203 | 203 | 'Mon, 15 Jan 2001 12:34:56 GMT', |
204 | 204 | wfTimestamp( TS_RFC2822, '20010115123456' ), |
205 | 205 | 'TS_MW to TS_RFC2822' ); |
206 | | - |
| 206 | + |
207 | 207 | $this->assertEquals( |
208 | 208 | '20010115123456', |
209 | 209 | wfTimestamp( TS_MW, 'Mon, 15 Jan 2001 12:34:56 GMT' ), |
210 | 210 | 'TS_RFC2822 to TS_MW' ); |
211 | | - |
| 211 | + |
212 | 212 | $this->assertEquals( |
213 | 213 | '20010115123456', |
214 | 214 | wfTimestamp( TS_MW, ' Mon, 15 Jan 2001 12:34:56 GMT' ), |
215 | 215 | 'TS_RFC2822 with leading space to TS_MW' ); |
216 | | - |
| 216 | + |
217 | 217 | $this->assertEquals( |
218 | 218 | '20010115123456', |
219 | 219 | wfTimestamp( TS_MW, '15 Jan 2001 12:34:56 GMT' ), |
220 | 220 | 'TS_RFC2822 without optional day-of-week to TS_MW' ); |
221 | | - |
| 221 | + |
222 | 222 | # FWS = ([*WSP CRLF] 1*WSP) / obs-FWS ; Folding white space |
223 | | - # obs-FWS = 1*WSP *(CRLF 1*WSP) ; Section 4.2 |
| 223 | + # obs-FWS = 1*WSP *(CRLF 1*WSP) ; Section 4.2 |
224 | 224 | $this->assertEquals( |
225 | 225 | '20010115123456', |
226 | 226 | wfTimestamp( TS_MW, 'Mon, 15 Jan 2001 12:34:56 GMT' ), |
227 | 227 | 'TS_RFC2822 to TS_MW' ); |
228 | | - |
| 228 | + |
229 | 229 | # WSP = SP / HTAB ; rfc2234 |
230 | 230 | $this->assertEquals( |
231 | 231 | '20010115123456', |
232 | 232 | wfTimestamp( TS_MW, "Mon, 15 Jan\x092001 12:34:56 GMT" ), |
233 | 233 | 'TS_RFC2822 with HTAB to TS_MW' ); |
234 | | - |
| 234 | + |
235 | 235 | $this->assertEquals( |
236 | 236 | '20010115123456', |
237 | 237 | wfTimestamp( TS_MW, "Mon, 15 Jan\x09 \x09 2001 12:34:56 GMT" ), |
238 | 238 | 'TS_RFC2822 with HTAB and SP to TS_MW' ); |
239 | | - |
| 239 | + |
240 | 240 | $this->assertEquals( |
241 | 241 | '19941106084937', |
242 | 242 | wfTimestamp( TS_MW, "Sun, 6 Nov 94 08:49:37 GMT" ), |
243 | 243 | 'TS_RFC2822 with obsolete year to TS_MW' ); |
244 | 244 | } |
245 | | - |
| 245 | + |
246 | 246 | /** |
247 | 247 | * This test checks wfTimestamp() with values outside. |
248 | 248 | * It needs PHP 64 bits or PHP > 5.1. |
— | — | @@ -310,8 +310,8 @@ |
311 | 311 | wfTimestamp( TS_RFC2822, '-62135596800'), |
312 | 312 | 'Year 1'); |
313 | 313 | |
314 | | - /* It is not clear if we should generate a year 0 or not |
315 | | - * We are completely off RFC2822 requirement of year being |
| 314 | + /* It is not clear if we should generate a year 0 or not |
| 315 | + * We are completely off RFC2822 requirement of year being |
316 | 316 | * 1900 or later. |
317 | 317 | */ |
318 | 318 | $this->assertEquals( 'Wed, 18 Oct 0000 00:00:00 GMT', |
— | — | @@ -320,32 +320,32 @@ |
321 | 321 | } |
322 | 322 | |
323 | 323 | function testHttpDate() { |
324 | | - # The Resource Loader uses wfTimestamp() to convert timestamps |
| 324 | + # The Resource Loader uses wfTimestamp() to convert timestamps |
325 | 325 | # from If-Modified-Since header. |
326 | 326 | # Thus it must be able to parse all rfc2616 date formats |
327 | 327 | # http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1 |
328 | | - |
| 328 | + |
329 | 329 | $this->assertEquals( |
330 | 330 | '19941106084937', |
331 | 331 | wfTimestamp( TS_MW, 'Sun, 06 Nov 1994 08:49:37 GMT' ), |
332 | 332 | 'RFC 822 date' ); |
333 | | - |
| 333 | + |
334 | 334 | $this->assertEquals( |
335 | 335 | '19941106084937', |
336 | 336 | wfTimestamp( TS_MW, 'Sunday, 06-Nov-94 08:49:37 GMT' ), |
337 | 337 | 'RFC 850 date' ); |
338 | | - |
| 338 | + |
339 | 339 | $this->assertEquals( |
340 | 340 | '19941106084937', |
341 | 341 | wfTimestamp( TS_MW, 'Sun Nov 6 08:49:37 1994' ), |
342 | 342 | "ANSI C's asctime() format" ); |
343 | | - |
| 343 | + |
344 | 344 | // See http://www.squid-cache.org/mail-archive/squid-users/200307/0122.html and r77171 |
345 | 345 | $this->assertEquals( |
346 | 346 | '20101122141242', |
347 | 347 | wfTimestamp( TS_MW, 'Mon, 22 Nov 2010 14:12:42 GMT; length=52626' ), |
348 | 348 | "Netscape extension to HTTP/1.0" ); |
349 | | - |
| 349 | + |
350 | 350 | } |
351 | 351 | |
352 | 352 | function testBasename() { |
Index: trunk/phase3/maintenance/tests/phpunit/includes/IPTest.php |
— | — | @@ -1,10 +1,10 @@ |
2 | 2 | <?php |
3 | | -/* |
| 3 | +/* |
4 | 4 | * Tests for IP validity functions. Ported from /t/inc/IP.t by avar. |
5 | 5 | */ |
6 | 6 | |
7 | 7 | class IPTest extends PHPUnit_Framework_TestCase { |
8 | | - // not sure it should be tested with boolean false. hashar 20100924 |
| 8 | + // not sure it should be tested with boolean false. hashar 20100924 |
9 | 9 | public function testisIPAddress() { |
10 | 10 | $this->assertFalse( IP::isIPAddress( false ), 'Boolean false is not an IP' ); |
11 | 11 | $this->assertFalse( IP::isIPAddress( true ), 'Boolean true is not an IP' ); |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | $this->assertTrue( IP::isIPAddress( '74.24.52.13/20', 'IPv4 range' ) ); |
26 | 26 | $this->assertTrue( IP::isIPAddress( 'fc:100:a:d:1:e:ac:0/24' ), 'IPv6 range' ); |
27 | 27 | $this->assertTrue( IP::isIPAddress( 'fc::100:a:d:1:e:ac/96' ), 'IPv6 range with "::"' ); |
28 | | - |
| 28 | + |
29 | 29 | $validIPs = array( 'fc:100::', 'fc:100:a:d:1:e:ac::', 'fc::100', '::fc:100:a:d:1:e:ac', |
30 | 30 | '::fc', 'fc::100:a:d:1:e:ac', 'fc:100:a:d:1:e:ac:0', '124.24.52.13', '1.24.52.13' ); |
31 | 31 | foreach ( $validIPs as $ip ) { |
— | — | @@ -114,7 +114,7 @@ |
115 | 115 | |
116 | 116 | // tests isValid() |
117 | 117 | public function testInvalidIPs() { |
118 | | - // Out of range... |
| 118 | + // Out of range... |
119 | 119 | foreach ( range( 256, 999 ) as $i ) { |
120 | 120 | $a = sprintf( "%03d", $i ); |
121 | 121 | $b = sprintf( "%02d", $i ); |
— | — | @@ -267,7 +267,7 @@ |
268 | 268 | * representing the network mask and the bit mask. |
269 | 269 | */ |
270 | 270 | function testCIDRParsing() { |
271 | | - $this->assertFalseCIDR( '192.0.2.0' , "missing mask" ); |
| 271 | + $this->assertFalseCIDR( '192.0.2.0' , "missing mask" ); |
272 | 272 | $this->assertFalseCIDR( '192.0.2.0/', "missing bitmask" ); |
273 | 273 | |
274 | 274 | // Verify if statement |
— | — | @@ -283,7 +283,7 @@ |
284 | 284 | $this->assertEquals( array( 0, 0 ), IP::parseCIDR('255.255.255.255/0') ); |
285 | 285 | |
286 | 286 | // FIXME : add more tests. |
287 | | - |
| 287 | + |
288 | 288 | # This part test network shifting |
289 | 289 | $this->assertNet( '192.0.0.0' , '192.0.0.2/24' ); |
290 | 290 | $this->assertNet( '192.168.5.0', '192.168.5.13/24'); |
— | — | @@ -293,6 +293,6 @@ |
294 | 294 | $this->assertNet( '10.0.0.4' , '10.0.0.4/30' ); |
295 | 295 | $this->assertNet( '172.17.32.0', '172.17.35.48/21' ); |
296 | 296 | $this->assertNet( '10.128.0.0' , '10.135.0.0/9' ); |
297 | | - $this->assertNet( '134.0.0.0' , '134.0.5.1/8' ); |
| 297 | + $this->assertNet( '134.0.0.0' , '134.0.5.1/8' ); |
298 | 298 | } |
299 | 299 | } |
Index: trunk/phase3/maintenance/tests/phpunit/includes/ParserOptionsTest.php |
— | — | @@ -4,33 +4,33 @@ |
5 | 5 | |
6 | 6 | private $popts; |
7 | 7 | private $pcache; |
8 | | - |
| 8 | + |
9 | 9 | function setUp() { |
10 | 10 | ParserTest::setUp(); //reuse setup from parser tests |
11 | 11 | global $wgContLang, $wgUser; |
12 | 12 | $wgContLang = new StubContLang; |
13 | 13 | $this->popts = new ParserOptions( $wgUser ); |
14 | | - $this->pcache = ParserCache::singleton(); |
| 14 | + $this->pcache = ParserCache::singleton(); |
15 | 15 | } |
16 | | - |
| 16 | + |
17 | 17 | function tearDown() { |
18 | 18 | parent::tearDown(); |
19 | 19 | } |
20 | | - |
| 20 | + |
21 | 21 | /** |
22 | 22 | * ParserOptions::optionsHash was not giving consistent results when $wgUseDynamicDates was set |
23 | 23 | * @group Database |
24 | 24 | */ |
25 | | - function testGetParserCacheKeyWithDynamicDates() { |
| 25 | + function testGetParserCacheKeyWithDynamicDates() { |
26 | 26 | global $wgUseDynamicDates; |
27 | 27 | $wgUseDynamicDates = true; |
28 | | - |
| 28 | + |
29 | 29 | $title = Title::newFromText( "Some test article" ); |
30 | | - $article = new Article( $title ); |
31 | | - |
| 30 | + $article = new Article( $title ); |
| 31 | + |
32 | 32 | $pcacheKeyBefore = $this->pcache->getKey( $article, $this->popts ); |
33 | 33 | $this->assertNotNull( $this->popts->getDateFormat() ); |
34 | | - $pcacheKeyAfter = $this->pcache->getKey( $article, $this->popts ); |
35 | | - $this->assertEquals( $pcacheKeyBefore, $pcacheKeyAfter ); |
| 34 | + $pcacheKeyAfter = $this->pcache->getKey( $article, $this->popts ); |
| 35 | + $this->assertEquals( $pcacheKeyBefore, $pcacheKeyAfter ); |
36 | 36 | } |
37 | 37 | } |
Index: trunk/phase3/maintenance/tests/phpunit/includes/SeleniumConfigurationTest.php |
— | — | @@ -4,14 +4,14 @@ |
5 | 5 | |
6 | 6 | /* |
7 | 7 | * The file where the test temporarity stores the selenium config. |
8 | | - * This should be cleaned up as part of teardown. |
| 8 | + * This should be cleaned up as part of teardown. |
9 | 9 | */ |
10 | 10 | private $tempFileName; |
11 | | - |
| 11 | + |
12 | 12 | /* |
13 | 13 | * String containing the a sample selenium settings |
14 | 14 | */ |
15 | | - private $testConfig0 = |
| 15 | + private $testConfig0 = |
16 | 16 | ' |
17 | 17 | [SeleniumSettings] |
18 | 18 | browsers[firefox] = "*firefox" |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | |
32 | 32 | [SeleniumTests] |
33 | 33 | testSuite[SimpleSeleniumTestSuite] = "maintenance/tests/selenium/SimpleSeleniumTestSuite.php" |
34 | | -testSuite[TestSuiteName] = "testSuitePath" |
| 34 | +testSuite[TestSuiteName] = "testSuitePath" |
35 | 35 | '; |
36 | 36 | /* |
37 | 37 | * Array of expected browsers from $testConfig0 |
— | — | @@ -60,14 +60,14 @@ |
61 | 61 | */ |
62 | 62 | private $testSuites0 = array( |
63 | 63 | 'SimpleSeleniumTestSuite' => 'maintenance/tests/selenium/SimpleSeleniumTestSuite.php', |
64 | | - 'TestSuiteName' => 'testSuitePath' |
| 64 | + 'TestSuiteName' => 'testSuitePath' |
65 | 65 | ); |
66 | | - |
67 | | - |
| 66 | + |
| 67 | + |
68 | 68 | /* |
69 | 69 | * Another sample selenium settings file contents |
70 | 70 | */ |
71 | | - private $testConfig1 = |
| 71 | + private $testConfig1 = |
72 | 72 | ' |
73 | 73 | [SeleniumSettings] |
74 | 74 | host = "localhost" |
— | — | @@ -96,15 +96,15 @@ |
97 | 97 | /* |
98 | 98 | * Expected test suites from $testConfig1 |
99 | 99 | */ |
100 | | - private $testSuites1 = null; |
101 | | - |
102 | | - |
| 100 | + private $testSuites1 = null; |
| 101 | + |
| 102 | + |
103 | 103 | public function setUp() { |
104 | 104 | if ( !defined( 'SELENIUMTEST' ) ) { |
105 | 105 | define( 'SELENIUMTEST', true ); |
106 | 106 | } |
107 | 107 | } |
108 | | - |
| 108 | + |
109 | 109 | /* |
110 | 110 | * Clean up the temporary file used to store the selenium settings. |
111 | 111 | */ |
— | — | @@ -115,90 +115,90 @@ |
116 | 116 | } |
117 | 117 | parent::tearDown(); |
118 | 118 | } |
119 | | - |
| 119 | + |
120 | 120 | /** |
121 | | - * @expectedException MWException |
122 | | - * @group SeleniumFramework |
123 | | - */ |
124 | | - public function testErrorOnIncorrectConfigFile() { |
| 121 | + * @expectedException MWException |
| 122 | + * @group SeleniumFramework |
| 123 | + */ |
| 124 | + public function testErrorOnIncorrectConfigFile() { |
125 | 125 | $seleniumSettings; |
126 | 126 | $seleniumBrowsers; |
127 | 127 | $seleniumTestSuites; |
128 | 128 | |
129 | | - SeleniumConfig::getSeleniumSettings($seleniumSettings, |
130 | | - $seleniumBrowsers, |
| 129 | + SeleniumConfig::getSeleniumSettings($seleniumSettings, |
| 130 | + $seleniumBrowsers, |
131 | 131 | $seleniumTestSuites, |
132 | 132 | "Some_fake_settings_file.ini" ); |
133 | 133 | |
134 | 134 | } |
135 | | - |
| 135 | + |
136 | 136 | /** |
137 | | - * @expectedException MWException |
138 | | - * @group SeleniumFramework |
139 | | - */ |
140 | | - public function testErrorOnMissingConfigFile() { |
| 137 | + * @expectedException MWException |
| 138 | + * @group SeleniumFramework |
| 139 | + */ |
| 140 | + public function testErrorOnMissingConfigFile() { |
141 | 141 | $seleniumSettings; |
142 | 142 | $seleniumBrowsers; |
143 | 143 | $seleniumTestSuites; |
144 | 144 | global $wgSeleniumConfigFile; |
145 | 145 | $wgSeleniumConfigFile = ''; |
146 | | - SeleniumConfig::getSeleniumSettings($seleniumSettings, |
147 | | - $seleniumBrowsers, |
| 146 | + SeleniumConfig::getSeleniumSettings($seleniumSettings, |
| 147 | + $seleniumBrowsers, |
148 | 148 | $seleniumTestSuites); |
149 | 149 | } |
150 | | - |
| 150 | + |
151 | 151 | /** |
152 | | - * @group SeleniumFramework |
153 | | - */ |
154 | | - public function testUsesGlobalVarForConfigFile() { |
| 152 | + * @group SeleniumFramework |
| 153 | + */ |
| 154 | + public function testUsesGlobalVarForConfigFile() { |
155 | 155 | $seleniumSettings; |
156 | 156 | $seleniumBrowsers; |
157 | 157 | $seleniumTestSuites; |
158 | 158 | global $wgSeleniumConfigFile; |
159 | 159 | $this->writeToTempFile( $this->testConfig0 ); |
160 | 160 | $wgSeleniumConfigFile = $this->tempFileName; |
161 | | - SeleniumConfig::getSeleniumSettings($seleniumSettings, |
162 | | - $seleniumBrowsers, |
| 161 | + SeleniumConfig::getSeleniumSettings($seleniumSettings, |
| 162 | + $seleniumBrowsers, |
163 | 163 | $seleniumTestSuites); |
164 | 164 | $this->assertEquals($seleniumSettings, $this->testSettings0 , |
165 | 165 | 'The selenium settings should have been read from the file defined in $wgSeleniumConfigFile' |
166 | 166 | ); |
167 | | - $this->assertEquals($seleniumBrowsers, $this->testBrowsers0, |
| 167 | + $this->assertEquals($seleniumBrowsers, $this->testBrowsers0, |
168 | 168 | 'The available browsers should have been read from the file defined in $wgSeleniumConfigFile' |
169 | 169 | ); |
170 | | - $this->assertEquals($seleniumTestSuites, $this->testSuites0, |
| 170 | + $this->assertEquals($seleniumTestSuites, $this->testSuites0, |
171 | 171 | 'The test suites should have been read from the file defined in $wgSeleniumConfigFile' |
172 | | - ); |
| 172 | + ); |
173 | 173 | } |
174 | | - |
| 174 | + |
175 | 175 | /** |
176 | | - * @group SeleniumFramework |
177 | | - * @dataProvider sampleConfigs |
178 | | - */ |
179 | | - public function testgetSeleniumSettings($sampleConfig, $expectedSettings, $expectedBrowsers, $expectedSuites ) { |
| 176 | + * @group SeleniumFramework |
| 177 | + * @dataProvider sampleConfigs |
| 178 | + */ |
| 179 | + public function testgetSeleniumSettings($sampleConfig, $expectedSettings, $expectedBrowsers, $expectedSuites ) { |
180 | 180 | $this->writeToTempFile( $sampleConfig ); |
181 | 181 | $seleniumSettings; |
182 | 182 | $seleniumBrowsers; |
183 | 183 | $seleniumTestSuites; |
184 | 184 | |
185 | | - SeleniumConfig::getSeleniumSettings($seleniumSettings, |
186 | | - $seleniumBrowsers, |
| 185 | + SeleniumConfig::getSeleniumSettings($seleniumSettings, |
| 186 | + $seleniumBrowsers, |
187 | 187 | $seleniumTestSuites, |
188 | 188 | $this->tempFileName ); |
189 | | - |
190 | | - $this->assertEquals($seleniumSettings, $expectedSettings, |
| 189 | + |
| 190 | + $this->assertEquals($seleniumSettings, $expectedSettings, |
191 | 191 | "The selenium settings for the following test configuration was not retrieved correctly" . $sampleConfig |
192 | 192 | ); |
193 | | - $this->assertEquals($seleniumBrowsers, $expectedBrowsers, |
| 193 | + $this->assertEquals($seleniumBrowsers, $expectedBrowsers, |
194 | 194 | "The available browsers for the following test configuration was not retrieved correctly" . $sampleConfig |
195 | 195 | ); |
196 | | - $this->assertEquals($seleniumTestSuites, $expectedSuites, |
| 196 | + $this->assertEquals($seleniumTestSuites, $expectedSuites, |
197 | 197 | "The test suites for the following test configuration was not retrieved correctly" . $sampleConfig |
198 | 198 | ); |
199 | | - |
200 | | - |
| 199 | + |
| 200 | + |
201 | 201 | } |
202 | | - |
| 202 | + |
203 | 203 | /* |
204 | 204 | * create a temp file and write text to it. |
205 | 205 | * @param $testToWrite the text to write to the temp file |
— | — | @@ -209,11 +209,11 @@ |
210 | 210 | fwrite($tempFile , $textToWrite); |
211 | 211 | fclose($tempFile); |
212 | 212 | } |
213 | | - |
| 213 | + |
214 | 214 | /* |
215 | 215 | * Returns an array containing: |
216 | 216 | * The contents of the selenium cingiguration ini file |
217 | | - * The expected selenium configuration array that getSeleniumSettings should return |
| 217 | + * The expected selenium configuration array that getSeleniumSettings should return |
218 | 218 | * The expected available browsers array that getSeleniumSettings should return |
219 | 219 | * The expected test suites arrya that getSeleniumSettings should return |
220 | 220 | */ |
— | — | @@ -223,6 +223,6 @@ |
224 | 224 | array($this->testConfig1, $this->testSettings1, $this->testBrowsers1, $this->testSuites1 ) |
225 | 225 | ); |
226 | 226 | } |
227 | | - |
228 | 227 | |
| 228 | + |
229 | 229 | } |
Index: trunk/phase3/maintenance/tests/phpunit/includes/search/SearchDbTest.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | $this->db = wfGetDB( DB_MASTER ); |
16 | 16 | if ( !$this->db ) { |
17 | 17 | $this->markTestIncomplete( "Can't find a database to test with." ); |
18 | | - } |
| 18 | + } |
19 | 19 | |
20 | 20 | parent::setup(); |
21 | 21 | |
Index: trunk/phase3/maintenance/tests/phpunit/includes/search/SearchEngineTest.php |
— | — | @@ -33,26 +33,26 @@ |
34 | 34 | } |
35 | 35 | |
36 | 36 | function insertSearchData() { |
37 | | - if ( $this->pageExists( 'Not_Main_Page' ) ) { |
| 37 | + if ( $this->pageExists( 'Not_Main_Page' ) ) { |
38 | 38 | return; |
39 | | - } |
40 | | - $this->insertPage( "Not_Main_Page", "This is not a main page", 0 ); |
41 | | - $this->insertPage( 'Talk:Not_Main_Page', 'This is not a talk page to the main page, see [[smithee]]', 1 ); |
42 | | - $this->insertPage( 'Smithee', 'A smithee is one who smiths. See also [[Alan Smithee]]', 0 ); |
43 | | - $this->insertPage( 'Talk:Smithee', 'This article sucks.', 1 ); |
44 | | - $this->insertPage( 'Unrelated_page', 'Nothing in this page is about the S word.', 0 ); |
45 | | - $this->insertPage( 'Another_page', 'This page also is unrelated.', 0 ); |
46 | | - $this->insertPage( 'Help:Help', 'Help me!', 4 ); |
47 | | - $this->insertPage( 'Thppt', 'Blah blah', 0 ); |
48 | | - $this->insertPage( 'Alan_Smithee', 'yum', 0 ); |
49 | | - $this->insertPage( 'Pages', 'are\'food', 0 ); |
50 | | - $this->insertPage( 'HalfOneUp', 'AZ', 0 ); |
51 | | - $this->insertPage( 'FullOneUp', 'AZ', 0 ); |
52 | | - $this->insertPage( 'HalfTwoLow', 'az', 0 ); |
53 | | - $this->insertPage( 'FullTwoLow', 'az', 0 ); |
54 | | - $this->insertPage( 'HalfNumbers', '1234567890', 0 ); |
55 | | - $this->insertPage( 'FullNumbers', '1234567890', 0 ); |
56 | | - $this->insertPage( 'DomainName', 'example.com', 0 ); |
| 39 | + } |
| 40 | + $this->insertPage( "Not_Main_Page", "This is not a main page", 0 ); |
| 41 | + $this->insertPage( 'Talk:Not_Main_Page', 'This is not a talk page to the main page, see [[smithee]]', 1 ); |
| 42 | + $this->insertPage( 'Smithee', 'A smithee is one who smiths. See also [[Alan Smithee]]', 0 ); |
| 43 | + $this->insertPage( 'Talk:Smithee', 'This article sucks.', 1 ); |
| 44 | + $this->insertPage( 'Unrelated_page', 'Nothing in this page is about the S word.', 0 ); |
| 45 | + $this->insertPage( 'Another_page', 'This page also is unrelated.', 0 ); |
| 46 | + $this->insertPage( 'Help:Help', 'Help me!', 4 ); |
| 47 | + $this->insertPage( 'Thppt', 'Blah blah', 0 ); |
| 48 | + $this->insertPage( 'Alan_Smithee', 'yum', 0 ); |
| 49 | + $this->insertPage( 'Pages', 'are\'food', 0 ); |
| 50 | + $this->insertPage( 'HalfOneUp', 'AZ', 0 ); |
| 51 | + $this->insertPage( 'FullOneUp', 'AZ', 0 ); |
| 52 | + $this->insertPage( 'HalfTwoLow', 'az', 0 ); |
| 53 | + $this->insertPage( 'FullTwoLow', 'az', 0 ); |
| 54 | + $this->insertPage( 'HalfNumbers', '1234567890', 0 ); |
| 55 | + $this->insertPage( 'FullNumbers', '1234567890', 0 ); |
| 56 | + $this->insertPage( 'DomainName', 'example.com', 0 ); |
57 | 57 | } |
58 | 58 | |
59 | 59 | function removeSearchData() { |
— | — | @@ -62,7 +62,7 @@ |
63 | 63 | $article = new Article( $title, $id ); |
64 | 64 | $article->doDeleteArticle( "Search Test" ); |
65 | 65 | }*/ |
66 | | - } |
| 66 | + } |
67 | 67 | |
68 | 68 | function fetchIds( $results ) { |
69 | 69 | $this->assertTrue( is_object( $results ) ); |
— | — | @@ -81,82 +81,82 @@ |
82 | 82 | |
83 | 83 | // Modified version of WikiRevision::importOldRevision() |
84 | 84 | function insertPage( $pageName, $text, $ns ) { |
85 | | - $dbw = $this->db; |
86 | | - $title = Title::newFromText( $pageName ); |
| 85 | + $dbw = $this->db; |
| 86 | + $title = Title::newFromText( $pageName ); |
87 | 87 | |
88 | | - $userId = 0; |
89 | | - $userText = 'WikiSysop'; |
90 | | - $comment = 'Search Test'; |
| 88 | + $userId = 0; |
| 89 | + $userText = 'WikiSysop'; |
| 90 | + $comment = 'Search Test'; |
91 | 91 | |
92 | | - // avoid memory leak...? |
93 | | - $linkCache = LinkCache::singleton(); |
94 | | - $linkCache->clear(); |
| 92 | + // avoid memory leak...? |
| 93 | + $linkCache = LinkCache::singleton(); |
| 94 | + $linkCache->clear(); |
95 | 95 | |
96 | | - $article = new Article( $title ); |
97 | | - $pageId = $article->getId(); |
98 | | - $created = false; |
99 | | - if ( $pageId == 0 ) { |
100 | | - # must create the page... |
101 | | - $pageId = $article->insertOn( $dbw ); |
102 | | - $created = true; |
103 | | - } |
| 96 | + $article = new Article( $title ); |
| 97 | + $pageId = $article->getId(); |
| 98 | + $created = false; |
| 99 | + if ( $pageId == 0 ) { |
| 100 | + # must create the page... |
| 101 | + $pageId = $article->insertOn( $dbw ); |
| 102 | + $created = true; |
| 103 | + } |
104 | 104 | |
105 | | - # FIXME: Use original rev_id optionally (better for backups) |
106 | | - # Insert the row |
107 | | - $revision = new Revision( array( |
108 | | - 'page' => $pageId, |
109 | | - 'text' => $text, |
110 | | - 'comment' => $comment, |
111 | | - 'user' => $userId, |
112 | | - 'user_text' => $userText, |
113 | | - 'timestamp' => 0, |
114 | | - 'minor_edit' => false, |
| 105 | + # FIXME: Use original rev_id optionally (better for backups) |
| 106 | + # Insert the row |
| 107 | + $revision = new Revision( array( |
| 108 | + 'page' => $pageId, |
| 109 | + 'text' => $text, |
| 110 | + 'comment' => $comment, |
| 111 | + 'user' => $userId, |
| 112 | + 'user_text' => $userText, |
| 113 | + 'timestamp' => 0, |
| 114 | + 'minor_edit' => false, |
115 | 115 | ) ); |
116 | | - $revId = $revision->insertOn( $dbw ); |
117 | | - $changed = $article->updateIfNewerOn( $dbw, $revision ); |
| 116 | + $revId = $revision->insertOn( $dbw ); |
| 117 | + $changed = $article->updateIfNewerOn( $dbw, $revision ); |
118 | 118 | |
119 | | - $GLOBALS['wgTitle'] = $title; |
120 | | - if ( $created ) { |
121 | | - Article::onArticleCreate( $title ); |
122 | | - $article->createUpdates( $revision ); |
123 | | - } elseif ( $changed ) { |
124 | | - Article::onArticleEdit( $title ); |
125 | | - $article->editUpdates( |
126 | | - $text, $comment, false, 0, $revId ); |
127 | | - } |
| 119 | + $GLOBALS['wgTitle'] = $title; |
| 120 | + if ( $created ) { |
| 121 | + Article::onArticleCreate( $title ); |
| 122 | + $article->createUpdates( $revision ); |
| 123 | + } elseif ( $changed ) { |
| 124 | + Article::onArticleEdit( $title ); |
| 125 | + $article->editUpdates( |
| 126 | + $text, $comment, false, 0, $revId ); |
| 127 | + } |
128 | 128 | |
129 | | - $su = new SearchUpdate( $article->getId(), $pageName, $text ); |
130 | | - $su->doUpdate(); |
| 129 | + $su = new SearchUpdate( $article->getId(), $pageName, $text ); |
| 130 | + $su->doUpdate(); |
131 | 131 | |
132 | | - $this->pageList[] = array( $title, $article->getId() ); |
| 132 | + $this->pageList[] = array( $title, $article->getId() ); |
133 | 133 | |
134 | | - return true; |
135 | | - } |
| 134 | + return true; |
| 135 | + } |
136 | 136 | |
137 | 137 | function testFullWidth() { |
138 | | - $this->assertEquals( |
139 | | - array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ), |
140 | | - $this->fetchIds( $this->search->searchText( 'AZ' ) ), |
141 | | - "Search for normalized from Half-width Upper" ); |
142 | | - $this->assertEquals( |
143 | | - array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ), |
144 | | - $this->fetchIds( $this->search->searchText( 'az' ) ), |
145 | | - "Search for normalized from Half-width Lower" ); |
146 | | - $this->assertEquals( |
147 | | - array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ), |
148 | | - $this->fetchIds( $this->search->searchText( 'AZ' ) ), |
149 | | - "Search for normalized from Full-width Upper" ); |
150 | | - $this->assertEquals( |
151 | | - array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ), |
152 | | - $this->fetchIds( $this->search->searchText( 'az' ) ), |
153 | | - "Search for normalized from Full-width Lower" ); |
| 138 | + $this->assertEquals( |
| 139 | + array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ), |
| 140 | + $this->fetchIds( $this->search->searchText( 'AZ' ) ), |
| 141 | + "Search for normalized from Half-width Upper" ); |
| 142 | + $this->assertEquals( |
| 143 | + array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ), |
| 144 | + $this->fetchIds( $this->search->searchText( 'az' ) ), |
| 145 | + "Search for normalized from Half-width Lower" ); |
| 146 | + $this->assertEquals( |
| 147 | + array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ), |
| 148 | + $this->fetchIds( $this->search->searchText( 'AZ' ) ), |
| 149 | + "Search for normalized from Full-width Upper" ); |
| 150 | + $this->assertEquals( |
| 151 | + array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ), |
| 152 | + $this->fetchIds( $this->search->searchText( 'az' ) ), |
| 153 | + "Search for normalized from Full-width Lower" ); |
154 | 154 | } |
155 | 155 | |
156 | 156 | function testTextSearch() { |
157 | 157 | $this->assertEquals( |
158 | | - array( 'Smithee' ), |
159 | | - $this->fetchIds( $this->search->searchText( 'smithee' ) ), |
160 | | - "Plain search failed" ); |
| 158 | + array( 'Smithee' ), |
| 159 | + $this->fetchIds( $this->search->searchText( 'smithee' ) ), |
| 160 | + "Plain search failed" ); |
161 | 161 | } |
162 | 162 | |
163 | 163 | function testTextPowerSearch() { |
Index: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiTest.php |
— | — | @@ -98,7 +98,7 @@ |
99 | 99 | "lgpassword" => "bad", |
100 | 100 | ) |
101 | 101 | ); |
102 | | - |
| 102 | + |
103 | 103 | $result = $ret[0]; |
104 | 104 | |
105 | 105 | $this->assertNotType( "bool", $result ); |
Index: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiSetup.php |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | self::$user = new UserWrapper( 'User for MediaWiki automated tests', User::randomPassword() ); |
38 | 38 | self::$sysopUser = new UserWrapper( 'Sysop for MediaWiki automated tests', User::randomPassword(), 'sysop' ); |
39 | 39 | } |
40 | | - |
| 40 | + |
41 | 41 | $GLOBALS['wgUser'] = self::$sysopUser->user; |
42 | 42 | } |
43 | 43 | } |
Index: trunk/phase3/maintenance/tests/phpunit/includes/api/RandomImageGenerator.php |
— | — | @@ -1,21 +1,21 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -/* |
| 4 | +/* |
5 | 5 | * RandomImageGenerator -- does what it says on the tin. |
6 | 6 | * Requires Imagick, the ImageMagick library for PHP, or the command line equivalent (usually 'convert'). |
7 | 7 | * |
8 | 8 | * Because MediaWiki tests the uniqueness of media upload content, and filenames, it is sometimes useful to generate |
9 | 9 | * files that are guaranteed (or at least very likely) to be unique in both those ways. |
10 | | - * This generates a number of filenames with random names and random content (colored circles) |
| 10 | + * This generates a number of filenames with random names and random content (colored circles) |
11 | 11 | * |
12 | | - * It is also useful to have fresh content because our tests currently run in a "destructive" mode, and don't create a fresh new wiki for each |
| 12 | + * It is also useful to have fresh content because our tests currently run in a "destructive" mode, and don't create a fresh new wiki for each |
13 | 13 | * test run. |
14 | | - * Consequently, if we just had a few static files we kept re-uploading, we'd get lots of warnings about matching content or filenames, |
| 14 | + * Consequently, if we just had a few static files we kept re-uploading, we'd get lots of warnings about matching content or filenames, |
15 | 15 | * and even if we deleted those files, we'd get warnings about archived files. |
16 | 16 | * |
17 | 17 | * This can also be used with a cronjob to generate random files all the time -- I use it to have a constant, never ending supply when I'm |
18 | 18 | * testing interactively. |
19 | | - * |
| 19 | + * |
20 | 20 | * @file |
21 | 21 | * @author Neil Kandalgaonkar <neilk@wikimedia.org> |
22 | 22 | */ |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | private $maxHeight = 800; |
35 | 35 | private $circlesToDraw = 5; |
36 | 36 | private $imageWriteMethod; |
37 | | - |
| 37 | + |
38 | 38 | public function __construct( $options ) { |
39 | 39 | global $wgUseImageMagick, $wgImageMagickConvertCommand; |
40 | 40 | foreach ( array( 'dictionaryFile', 'minWidth', 'minHeight', 'maxHeight', 'circlesToDraw' ) as $property ) { |
— | — | @@ -62,12 +62,12 @@ |
63 | 63 | $this->imageWriteMethod = 'writeImageWithCommandLine'; |
64 | 64 | } else { |
65 | 65 | throw new Exception( "RandomImageGenerator: could not find a suitable method to write images" ); |
66 | | - } |
| 66 | + } |
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Writes random images with random filenames to disk in the directory you specify, or current working directory |
71 | | - * |
| 71 | + * |
72 | 72 | * @param $number Integer: number of filenames to write |
73 | 73 | * @param $format String: optional, must be understood by ImageMagick, such as 'jpg' or 'gif' |
74 | 74 | * @param $dir String: directory, optional (will default to current working directory) |
— | — | @@ -81,10 +81,10 @@ |
82 | 82 | return $filenames; |
83 | 83 | } |
84 | 84 | |
85 | | - /** |
| 85 | + /** |
86 | 86 | * Return a number of randomly-generated filenames |
87 | 87 | * Each filename uses two words randomly drawn from the dictionary, like elephantine_spatula.jpg |
88 | | - * |
| 88 | + * |
89 | 89 | * @param $number Integer: of filenames to generate |
90 | 90 | * @param $extension String: optional, defaults to 'jpg' |
91 | 91 | * @param $dir String: optional, defaults to current working directory |
— | — | @@ -103,23 +103,23 @@ |
104 | 104 | $basename = preg_replace( '/\s+/', '', $basename ); |
105 | 105 | $filenames[] = "$dir/$basename"; |
106 | 106 | } |
107 | | - |
| 107 | + |
108 | 108 | return $filenames; |
109 | | - |
| 109 | + |
110 | 110 | } |
111 | 111 | |
112 | 112 | |
113 | 113 | /** |
114 | | - * Generate data representing an image of random size (within limits), |
| 114 | + * Generate data representing an image of random size (within limits), |
115 | 115 | * consisting of randomly colored and sized circles against a random background color |
116 | 116 | * (This data is used in the writeImage* methods). |
117 | | - * @return {Mixed} |
| 117 | + * @return {Mixed} |
118 | 118 | */ |
119 | | - public function getImageSpec() { |
| 119 | + public function getImageSpec() { |
120 | 120 | $spec = array(); |
121 | | - |
122 | | - $spec['width'] = mt_rand( $this->minWidth, $this->maxWidth ); |
123 | | - $spec['height'] = mt_rand( $this->minHeight, $this->maxHeight ); |
| 121 | + |
| 122 | + $spec['width'] = mt_rand( $this->minWidth, $this->maxWidth ); |
| 123 | + $spec['height'] = mt_rand( $this->minHeight, $this->maxHeight ); |
124 | 124 | $spec['fill'] = $this->getRandomColor(); |
125 | 125 | |
126 | 126 | $diagonalLength = sqrt( pow( $spec['width'], 2 ) + pow( $spec['height'], 2 ) ); |
— | — | @@ -134,14 +134,14 @@ |
135 | 135 | |
136 | 136 | $draw = array(); |
137 | 137 | $draw['fill'] = $this->getRandomColor(); |
138 | | - $draw['circle'] = array( |
139 | | - 'originX' => $originX, |
140 | | - 'originY' => $originY, |
141 | | - 'perimeterX' => $perimeterX, |
142 | | - 'perimeterY' => $perimeterY |
| 138 | + $draw['circle'] = array( |
| 139 | + 'originX' => $originX, |
| 140 | + 'originY' => $originY, |
| 141 | + 'perimeterX' => $perimeterX, |
| 142 | + 'perimeterY' => $perimeterY |
143 | 143 | ); |
144 | 144 | $draws[] = $draw; |
145 | | - |
| 145 | + |
146 | 146 | } |
147 | 147 | |
148 | 148 | $spec['draws'] = $draws; |
— | — | @@ -156,12 +156,12 @@ |
157 | 157 | * @param $format: file format to write |
158 | 158 | * @param $filename: filename to write to |
159 | 159 | */ |
160 | | - public function writeImageWithApi( $spec, $format, $filename ) { |
| 160 | + public function writeImageWithApi( $spec, $format, $filename ) { |
161 | 161 | $image = new Imagick(); |
162 | 162 | $image->newImage( $spec['width'], $spec['height'], new ImagickPixel( $spec['fill'] ) ); |
163 | 163 | |
164 | 164 | foreach ( $spec['draws'] as $drawSpec ) { |
165 | | - $draw = new ImagickDraw(); |
| 165 | + $draw = new ImagickDraw(); |
166 | 166 | $draw->setFillColor( $drawSpec['fill'] ); |
167 | 167 | $circle = $drawSpec['circle']; |
168 | 168 | $draw->circle( $circle['originX'], $circle['originY'], $circle['perimeterX'], $circle['perimeterY'] ); |
— | — | @@ -178,9 +178,9 @@ |
179 | 179 | * |
180 | 180 | * Sample command line: |
181 | 181 | * $ convert -size 100x60 xc:rgb(90,87,45) \ |
182 | | - * -draw 'fill rgb(12,34,56) circle 41,39 44,57' \ |
183 | | - * -draw 'fill rgb(99,123,231) circle 59,39 56,57' \ |
184 | | - * -draw 'fill rgb(240,12,32) circle 50,21 50,3' filename.png |
| 182 | + * -draw 'fill rgb(12,34,56) circle 41,39 44,57' \ |
| 183 | + * -draw 'fill rgb(99,123,231) circle 59,39 56,57' \ |
| 184 | + * -draw 'fill rgb(240,12,32) circle 50,21 50,3' filename.png |
185 | 185 | * |
186 | 186 | * @param $spec: spec describing background and circles to draw |
187 | 187 | * @param $format: file format to write (unused by this method but kept so it has the same signature as writeImageWithApi) |
— | — | @@ -210,7 +210,7 @@ |
211 | 211 | |
212 | 212 | /** |
213 | 213 | * Generate a string of random colors for ImageMagick, like "rgb(12, 37, 98)" |
214 | | - * |
| 214 | + * |
215 | 215 | * @return {String} |
216 | 216 | */ |
217 | 217 | public function getRandomColor() { |
— | — | @@ -221,13 +221,13 @@ |
222 | 222 | return 'rgb(' . join(', ', $components) . ')'; |
223 | 223 | } |
224 | 224 | |
225 | | - /** |
| 225 | + /** |
226 | 226 | * Get an array of random pairs of random words, like array( array( 'foo', 'bar' ), array( 'quux', 'baz' ) ); |
227 | 227 | * |
228 | 228 | * @param $number Integer: number of pairs |
229 | 229 | * @return Array: of two-element arrays |
230 | 230 | */ |
231 | | - private function getRandomWordPairs( $number ) { |
| 231 | + private function getRandomWordPairs( $number ) { |
232 | 232 | $lines = $this->getRandomLines( $number * 2 ); |
233 | 233 | // construct pairs of words |
234 | 234 | $pairs = array(); |
— | — | @@ -238,16 +238,16 @@ |
239 | 239 | return $pairs; |
240 | 240 | } |
241 | 241 | |
242 | | - |
| 242 | + |
243 | 243 | /** |
244 | 244 | * Return N random lines from a file |
245 | | - * |
| 245 | + * |
246 | 246 | * Will throw exception if the file could not be read or if it had fewer lines than requested. |
247 | | - * |
| 247 | + * |
248 | 248 | * @param $number_desired Integer: number of lines desired |
249 | 249 | * @return Array: of exactly n elements, drawn randomly from lines the file |
250 | 250 | */ |
251 | | - private function getRandomLines( $number_desired ) { |
| 251 | + private function getRandomLines( $number_desired ) { |
252 | 252 | $filepath = $this->dictionaryFile; |
253 | 253 | |
254 | 254 | // initialize array of lines |
— | — | @@ -257,7 +257,7 @@ |
258 | 258 | } |
259 | 259 | |
260 | 260 | /* |
261 | | - * This algorithm obtains N random lines from a file in one single pass. It does this by replacing elements of |
| 261 | + * This algorithm obtains N random lines from a file in one single pass. It does this by replacing elements of |
262 | 262 | * a fixed-size array of lines, less and less frequently as it reads the file. |
263 | 263 | */ |
264 | 264 | $fh = fopen( $filepath, "r" ); |
— | — | @@ -266,12 +266,12 @@ |
267 | 267 | } |
268 | 268 | $line_number = 0; |
269 | 269 | $max_index = $number_desired - 1; |
270 | | - while( !feof( $fh ) ) { |
| 270 | + while( !feof( $fh ) ) { |
271 | 271 | $line = fgets( $fh ); |
272 | 272 | if ( $line !== false ) { |
273 | | - $line_number++; |
274 | | - $line = trim( $line ); |
275 | | - if ( mt_rand( 0, $line_number ) <= $max_index ) { |
| 273 | + $line_number++; |
| 274 | + $line = trim( $line ); |
| 275 | + if ( mt_rand( 0, $line_number ) <= $max_index ) { |
276 | 276 | $lines[ mt_rand( 0, $max_index ) ] = $line; |
277 | 277 | } |
278 | 278 | } |
— | — | @@ -280,7 +280,7 @@ |
281 | 281 | if ( $line_number < $number_desired ) { |
282 | 282 | throw new Exception( "not enough lines in $filepath" ); |
283 | 283 | } |
284 | | - |
| 284 | + |
285 | 285 | return $lines; |
286 | 286 | } |
287 | 287 | |
Index: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiUploadTest.php |
— | — | @@ -6,14 +6,14 @@ |
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** |
10 | | - * n.b. Ensure that you can write to the images/ directory as the |
| 10 | + * n.b. Ensure that you can write to the images/ directory as the |
11 | 11 | * user that will run tests. |
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Note for reviewers: this intentionally duplicates functionality already in "ApiSetup" and so on. |
15 | 15 | // This framework works better IMO and has less strangeness (such as test cases inheriting from "ApiSetup"...) |
16 | 16 | // (and in the case of the other Upload tests, this flat out just actually works... ) |
17 | | - |
| 17 | + |
18 | 18 | // TODO: refactor into several files |
19 | 19 | // TODO: port the other Upload tests, and other API tests to this framework |
20 | 20 | |
— | — | @@ -29,14 +29,14 @@ |
30 | 30 | public $user; |
31 | 31 | |
32 | 32 | function __construct( $username, $realname = 'Real Name', $email = 'sample@sample.com', $groups = array() ) { |
33 | | - $this->username = $username; |
34 | | - $this->realname = $realname; |
| 33 | + $this->username = $username; |
| 34 | + $this->realname = $realname; |
35 | 35 | $this->email = $email; |
36 | 36 | $this->groups = $groups; |
37 | 37 | |
38 | | - // don't allow user to hardcode or select passwords -- people sometimes run tests |
| 38 | + // don't allow user to hardcode or select passwords -- people sometimes run tests |
39 | 39 | // on live wikis. Sometimes we create sysop users in these tests. A sysop user with |
40 | | - // a known password would be a Bad Thing. |
| 40 | + // a known password would be a Bad Thing. |
41 | 41 | $this->password = User::randomPassword(); |
42 | 42 | |
43 | 43 | $this->user = User::newFromName( $this->username ); |
— | — | @@ -48,17 +48,17 @@ |
49 | 49 | // In core MediaWiki, there is no functionality to delete users, so this is the best we can do. |
50 | 50 | if ( !$this->user->getID() ) { |
51 | 51 | // create the user |
52 | | - $this->user = User::createNew( |
| 52 | + $this->user = User::createNew( |
53 | 53 | $this->username, array( |
54 | 54 | "email" => $this->email, |
55 | 55 | "real_name" => $this->realname |
56 | | - ) |
| 56 | + ) |
57 | 57 | ); |
58 | 58 | if ( !$this->user ) { |
59 | 59 | throw new Exception( "error creating user" ); |
60 | 60 | } |
61 | 61 | } |
62 | | - |
| 62 | + |
63 | 63 | // update the user to use the new random password and other details |
64 | 64 | $this->user->setPassword( $this->password ); |
65 | 65 | $this->user->setEmail( $this->email ); |
— | — | @@ -73,7 +73,7 @@ |
74 | 74 | } |
75 | 75 | } |
76 | 76 | $this->user->saveSettings(); |
77 | | - |
| 77 | + |
78 | 78 | } |
79 | 79 | |
80 | 80 | } |
— | — | @@ -90,17 +90,17 @@ |
91 | 91 | $wgRequest = new FauxRequest( array() ); |
92 | 92 | |
93 | 93 | self::$users = array( |
94 | | - 'sysop' => new ApiTestUser( |
95 | | - 'Apitestsysop', |
96 | | - 'Api Test Sysop', |
97 | | - 'api_test_sysop@sample.com', |
98 | | - array( 'sysop' ) |
| 94 | + 'sysop' => new ApiTestUser( |
| 95 | + 'Apitestsysop', |
| 96 | + 'Api Test Sysop', |
| 97 | + 'api_test_sysop@sample.com', |
| 98 | + array( 'sysop' ) |
99 | 99 | ), |
100 | | - 'uploader' => new ApiTestUser( |
| 100 | + 'uploader' => new ApiTestUser( |
101 | 101 | 'Apitestuser', |
102 | 102 | 'Api Test User', |
103 | 103 | 'api_test_user@sample.com', |
104 | | - array() |
| 104 | + array() |
105 | 105 | ) |
106 | 106 | ); |
107 | 107 | |
— | — | @@ -145,7 +145,7 @@ |
146 | 146 | */ |
147 | 147 | class ApiUploadTest extends ApiTestCase { |
148 | 148 | /** |
149 | | - * Fixture -- run before every test |
| 149 | + * Fixture -- run before every test |
150 | 150 | */ |
151 | 151 | public function setUp() { |
152 | 152 | global $wgEnableUploads, $wgEnableAPI; |
— | — | @@ -158,12 +158,12 @@ |
159 | 159 | ini_set( 'log_errors', 1 ); |
160 | 160 | ini_set( 'error_reporting', 1 ); |
161 | 161 | ini_set( 'display_errors', 1 ); |
162 | | - |
| 162 | + |
163 | 163 | $this->clearFakeUploads(); |
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
167 | | - * Fixture -- run after every test |
| 167 | + * Fixture -- run after every test |
168 | 168 | * Clean up temporary files etc. |
169 | 169 | */ |
170 | 170 | function tearDown() { |
— | — | @@ -177,10 +177,10 @@ |
178 | 178 | function testLogin() { |
179 | 179 | $user = self::$users['uploader']; |
180 | 180 | |
181 | | - $params = array( |
182 | | - 'action' => 'login', |
183 | | - 'lgname' => $user->username, |
184 | | - 'lgpassword' => $user->password |
| 181 | + $params = array( |
| 182 | + 'action' => 'login', |
| 183 | + 'lgname' => $user->username, |
| 184 | + 'lgpassword' => $user->password |
185 | 185 | ); |
186 | 186 | list( $result, , ) = $this->doApiRequest( $params ); |
187 | 187 | $this->assertArrayHasKey( "login", $result ); |
— | — | @@ -192,8 +192,8 @@ |
193 | 193 | 'action' => 'login', |
194 | 194 | 'lgtoken' => $token, |
195 | 195 | 'lgname' => $user->username, |
196 | | - 'lgpassword' => $user->password |
197 | | - ); |
| 196 | + 'lgpassword' => $user->password |
| 197 | + ); |
198 | 198 | list( $result, , $session ) = $this->doApiRequest( $params ); |
199 | 199 | $this->assertArrayHasKey( "login", $result ); |
200 | 200 | $this->assertArrayHasKey( "result", $result['login'] ); |
— | — | @@ -207,7 +207,7 @@ |
208 | 208 | /** |
209 | 209 | * @depends testLogin |
210 | 210 | */ |
211 | | - public function testUploadRequiresToken( $session ) { |
| 211 | + public function testUploadRequiresToken( $session ) { |
212 | 212 | $exception = false; |
213 | 213 | try { |
214 | 214 | $this->doApiRequest( array( |
— | — | @@ -222,8 +222,8 @@ |
223 | 223 | |
224 | 224 | /** |
225 | 225 | * @depends testLogin |
226 | | - */ |
227 | | - public function testUploadMissingParams( $session ) { |
| 226 | + */ |
| 227 | + public function testUploadMissingParams( $session ) { |
228 | 228 | global $wgUser; |
229 | 229 | $wgUser = self::$users['uploader']->user; |
230 | 230 | |
— | — | @@ -244,7 +244,7 @@ |
245 | 245 | /** |
246 | 246 | * @depends testLogin |
247 | 247 | */ |
248 | | - public function testUpload( $session ) { |
| 248 | + public function testUpload( $session ) { |
249 | 249 | global $wgUser; |
250 | 250 | $wgUser = self::$users['uploader']->user; |
251 | 251 | |
— | — | @@ -261,7 +261,7 @@ |
262 | 262 | $filePaths = $randomImageGenerator->writeImages( 1, $extension, dirname( wfTempDir() ) ); |
263 | 263 | $filePath = $filePaths[0]; |
264 | 264 | $fileSize = filesize( $filePath ); |
265 | | - $fileName = basename( $filePath ); |
| 265 | + $fileName = basename( $filePath ); |
266 | 266 | |
267 | 267 | $this->deleteFileByFileName( $fileName ); |
268 | 268 | $this->deleteFileByContent( $filePath ); |
— | — | @@ -299,7 +299,7 @@ |
300 | 300 | /** |
301 | 301 | * @depends testLogin |
302 | 302 | */ |
303 | | - public function testUploadZeroLength( $session ) { |
| 303 | + public function testUploadZeroLength( $session ) { |
304 | 304 | global $wgUser; |
305 | 305 | $wgUser = self::$users['uploader']->user; |
306 | 306 | |
— | — | @@ -340,7 +340,7 @@ |
341 | 341 | /** |
342 | 342 | * @depends testLogin |
343 | 343 | */ |
344 | | - public function testUploadSameFileName( $session ) { |
| 344 | + public function testUploadSameFileName( $session ) { |
345 | 345 | global $wgUser; |
346 | 346 | $wgUser = self::$users['uploader']->user; |
347 | 347 | |
— | — | @@ -356,7 +356,7 @@ |
357 | 357 | |
358 | 358 | $filePaths = $randomImageGenerator->writeImages( 2, $extension, dirname( wfTempDir() ) ); |
359 | 359 | // we'll reuse this filename |
360 | | - $fileName = basename( $filePaths[0] ); |
| 360 | + $fileName = basename( $filePaths[0] ); |
361 | 361 | |
362 | 362 | // clear any other files with the same name |
363 | 363 | $this->deleteFileByFileName( $fileName ); |
— | — | @@ -371,7 +371,7 @@ |
372 | 372 | ); |
373 | 373 | |
374 | 374 | // first upload .... should succeed |
375 | | - |
| 375 | + |
376 | 376 | if (! $this->fakeUploadFile( 'file', $fileName, $mimeType, $filePaths[0] ) ) { |
377 | 377 | $this->markTestIncomplete( "Couldn't upload file!\n" ); |
378 | 378 | } |
— | — | @@ -386,7 +386,7 @@ |
387 | 387 | $this->assertEquals( 'Success', $result['upload']['result'] ); |
388 | 388 | $this->assertFalse( $exception ); |
389 | 389 | |
390 | | - // second upload with the same name (but different content) |
| 390 | + // second upload with the same name (but different content) |
391 | 391 | |
392 | 392 | if (! $this->fakeUploadFile( 'file', $fileName, $mimeType, $filePaths[1] ) ) { |
393 | 393 | $this->markTestIncomplete( "Couldn't upload file!\n" ); |
— | — | @@ -414,7 +414,7 @@ |
415 | 415 | /** |
416 | 416 | * @depends testLogin |
417 | 417 | */ |
418 | | - public function testUploadSameContent( $session ) { |
| 418 | + public function testUploadSameContent( $session ) { |
419 | 419 | global $wgUser; |
420 | 420 | $wgUser = self::$users['uploader']->user; |
421 | 421 | |
— | — | @@ -428,7 +428,7 @@ |
429 | 429 | $this->markTestIncomplete( $e->getMessage() ); |
430 | 430 | } |
431 | 431 | $filePaths = $randomImageGenerator->writeImages( 1, $extension, dirname( wfTempDir() ) ); |
432 | | - $fileNames[0] = basename( $filePaths[0] ); |
| 432 | + $fileNames[0] = basename( $filePaths[0] ); |
433 | 433 | $fileNames[1] = "SameContentAs" . $fileNames[0]; |
434 | 434 | |
435 | 435 | // clear any other files with the same name or content |
— | — | @@ -437,7 +437,7 @@ |
438 | 438 | $this->deleteFileByFileName( $fileNames[1] ); |
439 | 439 | |
440 | 440 | // first upload .... should succeed |
441 | | - |
| 441 | + |
442 | 442 | $params = array( |
443 | 443 | 'action' => 'upload', |
444 | 444 | 'filename' => $fileNames[0], |
— | — | @@ -445,7 +445,7 @@ |
446 | 446 | 'comment' => 'dummy comment', |
447 | 447 | 'text' => "This is the page text for " . $fileNames[0], |
448 | 448 | ); |
449 | | - |
| 449 | + |
450 | 450 | if (! $this->fakeUploadFile( 'file', $fileNames[0], $mimeType, $filePaths[0] ) ) { |
451 | 451 | $this->markTestIncomplete( "Couldn't upload file!\n" ); |
452 | 452 | } |
— | — | @@ -461,12 +461,12 @@ |
462 | 462 | $this->assertFalse( $exception ); |
463 | 463 | |
464 | 464 | |
465 | | - // second upload with the same content (but different name) |
| 465 | + // second upload with the same content (but different name) |
466 | 466 | |
467 | 467 | if (! $this->fakeUploadFile( 'file', $fileNames[1], $mimeType, $filePaths[0] ) ) { |
468 | 468 | $this->markTestIncomplete( "Couldn't upload file!\n" ); |
469 | 469 | } |
470 | | - |
| 470 | + |
471 | 471 | $params = array( |
472 | 472 | 'action' => 'upload', |
473 | 473 | 'filename' => $fileNames[1], |
— | — | @@ -497,7 +497,7 @@ |
498 | 498 | /** |
499 | 499 | * @depends testLogin |
500 | 500 | */ |
501 | | - public function testUploadStash( $session ) { |
| 501 | + public function testUploadStash( $session ) { |
502 | 502 | global $wgUser; |
503 | 503 | $wgUser = self::$users['uploader']->user; |
504 | 504 | |
— | — | @@ -514,7 +514,7 @@ |
515 | 515 | $filePaths = $randomImageGenerator->writeImages( 1, $extension, dirname( wfTempDir() ) ); |
516 | 516 | $filePath = $filePaths[0]; |
517 | 517 | $fileSize = filesize( $filePath ); |
518 | | - $fileName = basename( $filePath ); |
| 518 | + $fileName = basename( $filePath ); |
519 | 519 | |
520 | 520 | $this->deleteFileByFileName( $fileName ); |
521 | 521 | $this->deleteFileByContent( $filePath ); |
— | — | @@ -545,15 +545,15 @@ |
546 | 546 | $this->assertEquals( $mimeType, $result['upload']['imageinfo']['mime'] ); |
547 | 547 | $this->assertTrue( isset( $result['upload']['sessionkey'] ) ); |
548 | 548 | $sessionkey = $result['upload']['sessionkey']; |
549 | | - |
550 | | - // it should be visible from Special:UploadStash |
| 549 | + |
| 550 | + // it should be visible from Special:UploadStash |
551 | 551 | // XXX ...but how to test this, with a fake WebRequest with the session? |
552 | 552 | |
553 | 553 | // now we should try to release the file from stash |
554 | 554 | $params = array( |
555 | 555 | 'action' => 'upload', |
556 | 556 | 'sessionkey' => $sessionkey, |
557 | | - 'filename' => $fileName, |
| 557 | + 'filename' => $fileName, |
558 | 558 | 'comment' => 'dummy comment', |
559 | 559 | 'text' => "This is the page text for $fileName, altered", |
560 | 560 | ); |
— | — | @@ -581,7 +581,7 @@ |
582 | 582 | * @param $title Title: title to be removed |
583 | 583 | */ |
584 | 584 | public function deleteFileByTitle( $title ) { |
585 | | - if ( $title->exists() ) { |
| 585 | + if ( $title->exists() ) { |
586 | 586 | $file = wfFindFile( $title, array( 'ignoreRedirect' => true ) ); |
587 | 587 | $noOldArchive = ""; // yes this really needs to be set this way |
588 | 588 | $comment = "removing for test"; |
— | — | @@ -593,14 +593,14 @@ |
594 | 594 | $article = new Article( $title ); |
595 | 595 | $article->doDeleteArticle( "removing for test" ); |
596 | 596 | |
597 | | - // see if it now doesn't exist; reload |
| 597 | + // see if it now doesn't exist; reload |
598 | 598 | $title = Title::newFromText( $fileName, NS_FILE ); |
599 | 599 | } |
600 | 600 | return ! ( $title && $title instanceof Title && $title->exists() ); |
601 | 601 | } |
602 | 602 | |
603 | 603 | /** |
604 | | - * Helper function -- remove files and associated articles with a particular filename |
| 604 | + * Helper function -- remove files and associated articles with a particular filename |
605 | 605 | * @param $fileName String: filename to be removed |
606 | 606 | */ |
607 | 607 | public function deleteFileByFileName( $fileName ) { |
— | — | @@ -622,10 +622,10 @@ |
623 | 623 | return $success; |
624 | 624 | } |
625 | 625 | |
626 | | - /** |
| 626 | + /** |
627 | 627 | * Fake an upload by dumping the file into temp space, and adding info to $_FILES. |
628 | 628 | * (This is what PHP would normally do). |
629 | | - * @param $fieldName String: name this would have in the upload form |
| 629 | + * @param $fieldName String: name this would have in the upload form |
630 | 630 | * @param $fileName String: name to title this |
631 | 631 | * @param $type String: mime type |
632 | 632 | * @param $filePath String: path where to find file contents |
— | — | @@ -636,7 +636,7 @@ |
637 | 637 | throw new Exception( "$filePath doesn't exist!" ); |
638 | 638 | }; |
639 | 639 | |
640 | | - if ( !copy( $filePath, $tmpName ) ) { |
| 640 | + if ( !copy( $filePath, $tmpName ) ) { |
641 | 641 | throw new Exception( "couldn't copy $filePath to $tmpName" ); |
642 | 642 | } |
643 | 643 | |
Index: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiWatchTest.php |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | $this->assertArrayHasKey( 'protecttoken', $data[0]['query']['pages'][$key] ); |
77 | 77 | } |
78 | 78 | |
79 | | - return $data; |
| 79 | + return $data; |
80 | 80 | } |
81 | 81 | |
82 | 82 | function testGetToken() { |
— | — | @@ -161,7 +161,7 @@ |
162 | 162 | if ( !Title::newFromText( 'Main Page' )->exists() ) { |
163 | 163 | $this->markTestIncomplete( "The article [[Main Page]] does not exist" ); |
164 | 164 | } |
165 | | - |
| 165 | + |
166 | 166 | $data = $this->doApiRequest( array( |
167 | 167 | 'action' => 'query', |
168 | 168 | 'prop' => 'revisions', |
— | — | @@ -172,7 +172,7 @@ |
173 | 173 | $this->assertArrayHasKey( 'pages', $data[0]['query'] ); |
174 | 174 | $keys = array_keys( $data[0]['query']['pages'] ); |
175 | 175 | $key = array_pop( $keys ); |
176 | | - |
| 176 | + |
177 | 177 | if ( isset( $data[0]['query']['pages'][$key]['missing'] ) ) { |
178 | 178 | $this->markTestIncomplete( "Target page (Main Page) doesn't exist" ); |
179 | 179 | } |
— | — | @@ -232,6 +232,6 @@ |
233 | 233 | 'action' => 'query', |
234 | 234 | 'list' => 'watchlist' ), $data ); |
235 | 235 | |
236 | | - $this->markTestIncomplete( 'This test needs to verify the deleted article was added to the users watchlist' ); |
| 236 | + $this->markTestIncomplete( 'This test needs to verify the deleted article was added to the users watchlist' ); |
237 | 237 | } |
238 | 238 | } |
Index: trunk/phase3/maintenance/tests/phpunit/includes/api/generateRandomImages.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | |
4 | 4 | require("RandomImageGenerator.php"); |
5 | 5 | |
6 | | -$getOptSpec = array( |
| 6 | +$getOptSpec = array( |
7 | 7 | 'dictionaryFile::', |
8 | 8 | 'minWidth::', |
9 | 9 | 'maxWidth::', |