MediaWiki  1.23.8
ApiUploadTest.php
Go to the documentation of this file.
1 <?php
2 
14 // Note for reviewers: this intentionally duplicates functionality already in "ApiSetup" and so on.
15 // This framework works better IMO and has less strangeness (such as test cases inheriting from "ApiSetup"...)
16 // (and in the case of the other Upload tests, this flat out just actually works... )
17 
18 // TODO: port the other Upload tests, and other API tests to this framework
19 
20 require_once 'ApiTestCaseUpload.php';
21 
35  public function testLogin() {
36  $user = self::$users['uploader'];
37 
38  $params = array(
39  'action' => 'login',
40  'lgname' => $user->username,
41  'lgpassword' => $user->password
42  );
43  list( $result, , $session ) = $this->doApiRequest( $params );
44  $this->assertArrayHasKey( "login", $result );
45  $this->assertArrayHasKey( "result", $result['login'] );
46  $this->assertEquals( "NeedToken", $result['login']['result'] );
47  $token = $result['login']['token'];
48 
49  $params = array(
50  'action' => 'login',
51  'lgtoken' => $token,
52  'lgname' => $user->username,
53  'lgpassword' => $user->password
54  );
55  list( $result, , $session ) = $this->doApiRequest( $params, $session );
56  $this->assertArrayHasKey( "login", $result );
57  $this->assertArrayHasKey( "result", $result['login'] );
58  $this->assertEquals( "Success", $result['login']['result'] );
59  $this->assertArrayHasKey( 'lgtoken', $result['login'] );
60 
61  $this->assertNotEmpty( $session, 'API Login must return a session' );
62 
63  return $session;
64  }
65 
69  public function testUploadRequiresToken( $session ) {
70  $exception = false;
71  try {
72  $this->doApiRequest( array(
73  'action' => 'upload'
74  ) );
75  } catch ( UsageException $e ) {
76  $exception = true;
77  $this->assertEquals( "The token parameter must be set", $e->getMessage() );
78  }
79  $this->assertTrue( $exception, "Got exception" );
80  }
81 
85  public function testUploadMissingParams( $session ) {
86  $exception = false;
87  try {
89  'action' => 'upload',
90  ), $session, self::$users['uploader']->user );
91  } catch ( UsageException $e ) {
92  $exception = true;
93  $this->assertEquals( "One of the parameters filekey, file, url, statuskey is required",
94  $e->getMessage() );
95  }
96  $this->assertTrue( $exception, "Got exception" );
97  }
98 
102  public function testUpload( $session ) {
103  $extension = 'png';
104  $mimeType = 'image/png';
105 
106  try {
107  $randomImageGenerator = new RandomImageGenerator();
108  $filePaths = $randomImageGenerator->writeImages( 1, $extension, wfTempDir() );
109  } catch ( Exception $e ) {
110  $this->markTestIncomplete( $e->getMessage() );
111  }
112 
114  $filePath = $filePaths[0];
115  $fileSize = filesize( $filePath );
116  $fileName = basename( $filePath );
117 
118  $this->deleteFileByFileName( $fileName );
119  $this->deleteFileByContent( $filePath );
120 
121  if ( !$this->fakeUploadFile( 'file', $fileName, $mimeType, $filePath ) ) {
122  $this->markTestIncomplete( "Couldn't upload file!\n" );
123  }
124 
125  $params = array(
126  'action' => 'upload',
127  'filename' => $fileName,
128  'file' => 'dummy content',
129  'comment' => 'dummy comment',
130  'text' => "This is the page text for $fileName",
131  );
132 
133  $exception = false;
134  try {
135  list( $result, , ) = $this->doApiRequestWithToken( $params, $session,
136  self::$users['uploader']->user );
137  } catch ( UsageException $e ) {
138  $exception = true;
139  }
140  $this->assertTrue( isset( $result['upload'] ) );
141  $this->assertEquals( 'Success', $result['upload']['result'] );
142  $this->assertEquals( $fileSize, (int)$result['upload']['imageinfo']['size'] );
143  $this->assertEquals( $mimeType, $result['upload']['imageinfo']['mime'] );
144  $this->assertFalse( $exception );
145 
146  // clean up
147  $this->deleteFileByFilename( $fileName );
148  unlink( $filePath );
149  }
150 
154  public function testUploadZeroLength( $session ) {
155  $mimeType = 'image/png';
156 
157  $filePath = tempnam( wfTempDir(), "" );
158  $fileName = "apiTestUploadZeroLength.png";
159 
160  $this->deleteFileByFileName( $fileName );
161 
162  if ( !$this->fakeUploadFile( 'file', $fileName, $mimeType, $filePath ) ) {
163  $this->markTestIncomplete( "Couldn't upload file!\n" );
164  }
165 
166  $params = array(
167  'action' => 'upload',
168  'filename' => $fileName,
169  'file' => 'dummy content',
170  'comment' => 'dummy comment',
171  'text' => "This is the page text for $fileName",
172  );
173 
174  $exception = false;
175  try {
176  $this->doApiRequestWithToken( $params, $session, self::$users['uploader']->user );
177  } catch ( UsageException $e ) {
178  $this->assertContains( 'The file you submitted was empty', $e->getMessage() );
179  $exception = true;
180  }
181  $this->assertTrue( $exception );
182 
183  // clean up
184  $this->deleteFileByFilename( $fileName );
185  unlink( $filePath );
186  }
187 
191  public function testUploadSameFileName( $session ) {
192  $extension = 'png';
193  $mimeType = 'image/png';
194 
195  try {
196  $randomImageGenerator = new RandomImageGenerator();
197  $filePaths = $randomImageGenerator->writeImages( 2, $extension, wfTempDir() );
198  } catch ( Exception $e ) {
199  $this->markTestIncomplete( $e->getMessage() );
200  }
201 
202  // we'll reuse this filename
204  $fileName = basename( $filePaths[0] );
205 
206  // clear any other files with the same name
207  $this->deleteFileByFileName( $fileName );
208 
209  // we reuse these params
210  $params = array(
211  'action' => 'upload',
212  'filename' => $fileName,
213  'file' => 'dummy content',
214  'comment' => 'dummy comment',
215  'text' => "This is the page text for $fileName",
216  );
217 
218  // first upload .... should succeed
219 
220  if ( !$this->fakeUploadFile( 'file', $fileName, $mimeType, $filePaths[0] ) ) {
221  $this->markTestIncomplete( "Couldn't upload file!\n" );
222  }
223 
224  $exception = false;
225  try {
226  list( $result, , $session ) = $this->doApiRequestWithToken( $params, $session,
227  self::$users['uploader']->user );
228  } catch ( UsageException $e ) {
229  $exception = true;
230  }
231  $this->assertTrue( isset( $result['upload'] ) );
232  $this->assertEquals( 'Success', $result['upload']['result'] );
233  $this->assertFalse( $exception );
234 
235  // second upload with the same name (but different content)
236 
237  if ( !$this->fakeUploadFile( 'file', $fileName, $mimeType, $filePaths[1] ) ) {
238  $this->markTestIncomplete( "Couldn't upload file!\n" );
239  }
240 
241  $exception = false;
242  try {
243  list( $result, , ) = $this->doApiRequestWithToken( $params, $session,
244  self::$users['uploader']->user ); // FIXME: leaks a temporary file
245  } catch ( UsageException $e ) {
246  $exception = true;
247  }
248  $this->assertTrue( isset( $result['upload'] ) );
249  $this->assertEquals( 'Warning', $result['upload']['result'] );
250  $this->assertTrue( isset( $result['upload']['warnings'] ) );
251  $this->assertTrue( isset( $result['upload']['warnings']['exists'] ) );
252  $this->assertFalse( $exception );
253 
254  // clean up
255  $this->deleteFileByFilename( $fileName );
256  unlink( $filePaths[0] );
257  unlink( $filePaths[1] );
258  }
259 
263  public function testUploadSameContent( $session ) {
264  $extension = 'png';
265  $mimeType = 'image/png';
266 
267  try {
268  $randomImageGenerator = new RandomImageGenerator();
269  $filePaths = $randomImageGenerator->writeImages( 1, $extension, wfTempDir() );
270  } catch ( Exception $e ) {
271  $this->markTestIncomplete( $e->getMessage() );
272  }
273 
275  $fileNames[0] = basename( $filePaths[0] );
276  $fileNames[1] = "SameContentAs" . $fileNames[0];
277 
278  // clear any other files with the same name or content
279  $this->deleteFileByContent( $filePaths[0] );
280  $this->deleteFileByFileName( $fileNames[0] );
281  $this->deleteFileByFileName( $fileNames[1] );
282 
283  // first upload .... should succeed
284 
285  $params = array(
286  'action' => 'upload',
287  'filename' => $fileNames[0],
288  'file' => 'dummy content',
289  'comment' => 'dummy comment',
290  'text' => "This is the page text for " . $fileNames[0],
291  );
292 
293  if ( !$this->fakeUploadFile( 'file', $fileNames[0], $mimeType, $filePaths[0] ) ) {
294  $this->markTestIncomplete( "Couldn't upload file!\n" );
295  }
296 
297  $exception = false;
298  try {
299  list( $result, , $session ) = $this->doApiRequestWithToken( $params, $session,
300  self::$users['uploader']->user );
301  } catch ( UsageException $e ) {
302  $exception = true;
303  }
304  $this->assertTrue( isset( $result['upload'] ) );
305  $this->assertEquals( 'Success', $result['upload']['result'] );
306  $this->assertFalse( $exception );
307 
308  // second upload with the same content (but different name)
309 
310  if ( !$this->fakeUploadFile( 'file', $fileNames[1], $mimeType, $filePaths[0] ) ) {
311  $this->markTestIncomplete( "Couldn't upload file!\n" );
312  }
313 
314  $params = array(
315  'action' => 'upload',
316  'filename' => $fileNames[1],
317  'file' => 'dummy content',
318  'comment' => 'dummy comment',
319  'text' => "This is the page text for " . $fileNames[1],
320  );
321 
322  $exception = false;
323  try {
324  list( $result ) = $this->doApiRequestWithToken( $params, $session,
325  self::$users['uploader']->user ); // FIXME: leaks a temporary file
326  } catch ( UsageException $e ) {
327  $exception = true;
328  }
329  $this->assertTrue( isset( $result['upload'] ) );
330  $this->assertEquals( 'Warning', $result['upload']['result'] );
331  $this->assertTrue( isset( $result['upload']['warnings'] ) );
332  $this->assertTrue( isset( $result['upload']['warnings']['duplicate'] ) );
333  $this->assertFalse( $exception );
334 
335  // clean up
336  $this->deleteFileByFilename( $fileNames[0] );
337  $this->deleteFileByFilename( $fileNames[1] );
338  unlink( $filePaths[0] );
339  }
340 
344  public function testUploadStash( $session ) {
345  $this->setMwGlobals( array(
346  'wgUser' => self::$users['uploader']->user, // @todo FIXME: still used somewhere
347  ) );
348 
349  $extension = 'png';
350  $mimeType = 'image/png';
351 
352  try {
353  $randomImageGenerator = new RandomImageGenerator();
354  $filePaths = $randomImageGenerator->writeImages( 1, $extension, wfTempDir() );
355  } catch ( Exception $e ) {
356  $this->markTestIncomplete( $e->getMessage() );
357  }
358 
360  $filePath = $filePaths[0];
361  $fileSize = filesize( $filePath );
362  $fileName = basename( $filePath );
363 
364  $this->deleteFileByFileName( $fileName );
365  $this->deleteFileByContent( $filePath );
366 
367  if ( !$this->fakeUploadFile( 'file', $fileName, $mimeType, $filePath ) ) {
368  $this->markTestIncomplete( "Couldn't upload file!\n" );
369  }
370 
371  $params = array(
372  'action' => 'upload',
373  'stash' => 1,
374  'filename' => $fileName,
375  'file' => 'dummy content',
376  'comment' => 'dummy comment',
377  'text' => "This is the page text for $fileName",
378  );
379 
380  $exception = false;
381  try {
382  list( $result, , $session ) = $this->doApiRequestWithToken( $params, $session,
383  self::$users['uploader']->user ); // FIXME: leaks a temporary file
384  } catch ( UsageException $e ) {
385  $exception = true;
386  }
387  $this->assertFalse( $exception );
388  $this->assertTrue( isset( $result['upload'] ) );
389  $this->assertEquals( 'Success', $result['upload']['result'] );
390  $this->assertEquals( $fileSize, (int)$result['upload']['imageinfo']['size'] );
391  $this->assertEquals( $mimeType, $result['upload']['imageinfo']['mime'] );
392  $this->assertTrue( isset( $result['upload']['filekey'] ) );
393  $this->assertEquals( $result['upload']['sessionkey'], $result['upload']['filekey'] );
394  $filekey = $result['upload']['filekey'];
395 
396  // it should be visible from Special:UploadStash
397  // XXX ...but how to test this, with a fake WebRequest with the session?
398 
399  // now we should try to release the file from stash
400  $params = array(
401  'action' => 'upload',
402  'filekey' => $filekey,
403  'filename' => $fileName,
404  'comment' => 'dummy comment',
405  'text' => "This is the page text for $fileName, altered",
406  );
407 
408  $this->clearFakeUploads();
409  $exception = false;
410  try {
411  list( $result ) = $this->doApiRequestWithToken( $params, $session,
412  self::$users['uploader']->user );
413  } catch ( UsageException $e ) {
414  $exception = true;
415  }
416  $this->assertTrue( isset( $result['upload'] ) );
417  $this->assertEquals( 'Success', $result['upload']['result'] );
418  $this->assertFalse( $exception, "No UsageException exception." );
419 
420  // clean up
421  $this->deleteFileByFilename( $fileName );
422  unlink( $filePath );
423  }
424 
428  public function testUploadChunks( $session ) {
429  $this->setMwGlobals( array(
430  'wgUser' => self::$users['uploader']->user, // @todo FIXME: still used somewhere
431  ) );
432 
433  $chunkSize = 1048576;
434  // Download a large image file
435  // ( using RandomImageGenerator for large files is not stable )
436  $mimeType = 'image/jpeg';
437  $url = 'http://upload.wikimedia.org/wikipedia/commons/e/ed/Oberaargletscher_from_Oberaar%2C_2010_07.JPG';
438  $filePath = wfTempDir() . '/Oberaargletscher_from_Oberaar.jpg';
439  try {
440  // Only download if the file is not avaliable in the temp location:
441  if ( !is_file( $filePath ) ) {
442  copy( $url, $filePath );
443  }
444  } catch ( Exception $e ) {
445  $this->markTestIncomplete( $e->getMessage() );
446  }
447 
448  $fileSize = filesize( $filePath );
449  $fileName = basename( $filePath );
450 
451  $this->deleteFileByFileName( $fileName );
452  $this->deleteFileByContent( $filePath );
453 
454  // Base upload params:
455  $params = array(
456  'action' => 'upload',
457  'stash' => 1,
458  'filename' => $fileName,
459  'filesize' => $fileSize,
460  'offset' => 0,
461  );
462 
463  // Upload chunks
464  $chunkSessionKey = false;
465  $resultOffset = 0;
466  // Open the file:
467  $handle = @fopen( $filePath, "r" );
468  if ( $handle === false ) {
469  $this->markTestIncomplete( "could not open file: $filePath" );
470  }
471  while ( !feof( $handle ) ) {
472  // Get the current chunk
473  $chunkData = @fread( $handle, $chunkSize );
474 
475  // Upload the current chunk into the $_FILE object:
476  $this->fakeUploadChunk( 'chunk', 'blob', $mimeType, $chunkData );
477 
478  // Check for chunkSessionKey
479  if ( !$chunkSessionKey ) {
480  // Upload fist chunk ( and get the session key )
481  try {
482  list( $result, , $session ) = $this->doApiRequestWithToken( $params, $session,
483  self::$users['uploader']->user );
484  } catch ( UsageException $e ) {
485  $this->markTestIncomplete( $e->getMessage() );
486  }
487  // Make sure we got a valid chunk continue:
488  $this->assertTrue( isset( $result['upload'] ) );
489  $this->assertTrue( isset( $result['upload']['filekey'] ) );
490  // If we don't get a session key mark test incomplete.
491  if ( !isset( $result['upload']['filekey'] ) ) {
492  $this->markTestIncomplete( "no filekey provided" );
493  }
494  $chunkSessionKey = $result['upload']['filekey'];
495  $this->assertEquals( 'Continue', $result['upload']['result'] );
496  // First chunk should have chunkSize == offset
497  $this->assertEquals( $chunkSize, $result['upload']['offset'] );
498  $resultOffset = $result['upload']['offset'];
499  continue;
500  }
501  // Filekey set to chunk session
502  $params['filekey'] = $chunkSessionKey;
503  // Update the offset ( always add chunkSize for subquent chunks should be in-sync with $result['upload']['offset'] )
504  $params['offset'] += $chunkSize;
505  // Make sure param offset is insync with resultOffset:
506  $this->assertEquals( $resultOffset, $params['offset'] );
507  // Upload current chunk
508  try {
509  list( $result, , $session ) = $this->doApiRequestWithToken( $params, $session,
510  self::$users['uploader']->user );
511  } catch ( UsageException $e ) {
512  $this->markTestIncomplete( $e->getMessage() );
513  }
514  // Make sure we got a valid chunk continue:
515  $this->assertTrue( isset( $result['upload'] ) );
516  $this->assertTrue( isset( $result['upload']['filekey'] ) );
517 
518  // Check if we were on the last chunk:
519  if ( $params['offset'] + $chunkSize >= $fileSize ) {
520  $this->assertEquals( 'Success', $result['upload']['result'] );
521  break;
522  } else {
523  $this->assertEquals( 'Continue', $result['upload']['result'] );
524  // update $resultOffset
525  $resultOffset = $result['upload']['offset'];
526  }
527  }
528  fclose( $handle );
529 
530  // Check that we got a valid file result:
531  wfDebug( __METHOD__ . " hohoh filesize {$fileSize} info {$result['upload']['imageinfo']['size']}\n\n" );
532  $this->assertEquals( $fileSize, $result['upload']['imageinfo']['size'] );
533  $this->assertEquals( $mimeType, $result['upload']['imageinfo']['mime'] );
534  $this->assertTrue( isset( $result['upload']['filekey'] ) );
535  $filekey = $result['upload']['filekey'];
536 
537  // Now we should try to release the file from stash
538  $params = array(
539  'action' => 'upload',
540  'filekey' => $filekey,
541  'filename' => $fileName,
542  'comment' => 'dummy comment',
543  'text' => "This is the page text for $fileName, altered",
544  );
545  $this->clearFakeUploads();
546  $exception = false;
547  try {
548  list( $result ) = $this->doApiRequestWithToken( $params, $session,
549  self::$users['uploader']->user );
550  } catch ( UsageException $e ) {
551  $exception = true;
552  }
553  $this->assertTrue( isset( $result['upload'] ) );
554  $this->assertEquals( 'Success', $result['upload']['result'] );
555  $this->assertFalse( $exception );
556 
557  // clean up
558  $this->deleteFileByFilename( $fileName );
559  // don't remove downloaded temporary file for fast subquent tests.
560  //unlink( $filePath );
561  }
562 }
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1528
ApiUploadTest\testUploadMissingParams
testUploadMissingParams( $session)
@depends testLogin
Definition: ApiUploadTest.php:85
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
ApiUploadTest\testUploadStash
testUploadStash( $session)
@depends testLogin
Definition: ApiUploadTest.php:344
ApiUploadTest\testUploadChunks
testUploadChunks( $session)
@depends testLogin
Definition: ApiUploadTest.php:428
$params
$params
Definition: styleTest.css.php:40
ApiUploadTest\testLogin
testLogin()
Testing login XXX this is a funny way of getting session context.
Definition: ApiUploadTest.php:35
ApiTestCaseUpload\deleteFileByContent
deleteFileByContent( $filePath)
Helper function – given a file on the filesystem, find matching content in the db (and associated art...
Definition: ApiTestCaseUpload.php:75
RandomImageGenerator
RandomImageGenerator: does what it says on the tin.
Definition: RandomImageGenerator.php:27
UsageException
This exception will be thrown when dieUsage is called to stop module execution.
Definition: ApiMain.php:1406
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Definition: MediaWikiTestCase.php:302
ApiTestCaseUpload\clearFakeUploads
clearFakeUploads()
Remove traces of previous fake uploads.
Definition: ApiTestCaseUpload.php:159
ApiTestCaseUpload\fakeUploadFile
fakeUploadFile( $fieldName, $fileName, $type, $filePath)
Fake an upload by dumping the file into temp space, and adding info to $_FILES.
Definition: ApiTestCaseUpload.php:98
ApiUploadTest\testUploadRequiresToken
testUploadRequiresToken( $session)
@depends testLogin
Definition: ApiUploadTest.php:69
ApiTestCaseUpload\fakeUploadChunk
fakeUploadChunk( $fieldName, $fileName, $type, & $chunkData)
Definition: ApiTestCaseUpload.php:125
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
ApiUploadTest\testUploadSameContent
testUploadSameContent( $session)
@depends testLogin
Definition: ApiUploadTest.php:263
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
ApiTestCaseUpload\deleteFileByFileName
deleteFileByFileName( $fileName)
Helper function – remove files and associated articles with a particular filename.
Definition: ApiTestCaseUpload.php:64
wfDebug
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:933
ApiUploadTest\testUploadSameFileName
testUploadSameFileName( $session)
@depends testLogin
Definition: ApiUploadTest.php:191
user
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Definition: distributors.txt:9
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:237
ApiUploadTest
@group API @group Database @group medium
Definition: ApiUploadTest.php:30
ApiTestCase\doApiRequest
doApiRequest(array $params, array $session=null, $appendModule=false, User $user=null)
Does the API request and returns the result.
Definition: ApiTestCase.php:74
wfTempDir
wfTempDir()
Tries to get the system directory for temporary files.
Definition: GlobalFunctions.php:2564
ApiTestCaseUpload
Definition: ApiTestCaseUpload.php:7
ApiUploadTest\testUploadZeroLength
testUploadZeroLength( $session)
@depends testLogin
Definition: ApiUploadTest.php:154
ApiUploadTest\testUpload
testUpload( $session)
@depends testLogin
Definition: ApiUploadTest.php:102
ApiTestCase\doApiRequestWithToken
doApiRequestWithToken(array $params, array $session=null, User $user=null)
Add an edit token to the API request This is cheating a bit – we grab a token in the correct format a...
Definition: ApiTestCase.php:122
$e
if( $useReadline) $e
Definition: eval.php:66