MediaWiki  master
ApiUploadTestCase Class Reference

Abstract class to support upload tests. More...

Inheritance diagram for ApiUploadTestCase:
Collaboration diagram for ApiUploadTestCase:

Public Member Functions

 clearFakeUploads ()
 Remove traces of previous fake uploads. More...
 
 deleteFileByContent ( $filePath)
 Helper function – given a file on the filesystem, find matching content in the db (and associated articles) and remove them. More...
 
 deleteFileByFileName ( $fileName)
 Helper function – remove files and associated articles with a particular filename. More...
 
 deleteFileByTitle ( $title)
 Helper function – remove files and associated articles by Title. More...
 
 fakeUploadChunk ( $fieldName, $fileName, $type, & $chunkData)
 
 fakeUploadFile ( $fieldName, $fileName, $type, $filePath)
 Fake an upload by dumping the file into temp space, and adding info to $_FILES. More...
 
- Public Member Functions inherited from ApiTestCase
 testApiTestGroup ()
 

Protected Member Functions

 setUp ()
 Fixture – run before every test. More...
 
- Protected Member Functions inherited from ApiTestCase
 doApiRequest (array $params, array $session=null, $appendModule=false, User $user=null, $tokenType=null)
 Does the API request and returns the result. More...
 
 doApiRequestWithToken (array $params, array $session=null, User $user=null, $tokenType='auto')
 Convenience function to access the token parameter of doApiRequest() more succinctly. More...
 
 doLogin ( $testUser=null)
 Previously this would do API requests to log in, as well as setting $wgUser and the request context's user. More...
 
 getTokenList (TestUser $user, $session=null)
 
 setExpectedApiException ( $msg, $code=null, array $data=null, $httpCode=0)
 Expect an ApiUsageException to be thrown with the given parameters, which are the same as ApiUsageException::newWithMessage()'s parameters. More...
 
 setUp ()
 
 tearDown ()
 
- Protected Member Functions inherited from MediaWikiLangTestCase
 setUp ()
 

Additional Inherited Members

- Static Public Member Functions inherited from ApiTestCase
static apiExceptionHasCode (ApiUsageException $ex, $code)
 
- Static Protected Member Functions inherited from ApiTestCase
static getErrorFormatter ()
 
- Protected Attributes inherited from ApiTestCase
ApiTestContext $apiContext
 
- Static Protected Attributes inherited from ApiTestCase
static $apiUrl
 
static $errorFormatter = null
 

Detailed Description

Abstract class to support upload tests.

Definition at line 6 of file ApiUploadTestCase.php.

Member Function Documentation

◆ clearFakeUploads()

ApiUploadTestCase::clearFakeUploads ( )

Remove traces of previous fake uploads.

Definition at line 149 of file ApiUploadTestCase.php.

Referenced by setUp(), ApiUploadTest\testUploadChunks(), and ApiUploadTest\testUploadStash().

◆ deleteFileByContent()

ApiUploadTestCase::deleteFileByContent (   $filePath)

Helper function – given a file on the filesystem, find matching content in the db (and associated articles) and remove them.

Parameters
string$filePathPath to file on the filesystem
Returns
bool

Definition at line 74 of file ApiUploadTestCase.php.

References $success, as, deleteFileByTitle(), FSFile\getSha1Base36FromPath(), and RepoGroup\singleton().

Referenced by ApiUploadTest\testUpload(), ApiUploadTest\testUploadChunks(), ApiUploadTest\testUploadSameContent(), and ApiUploadTest\testUploadStash().

◆ deleteFileByFileName()

ApiUploadTestCase::deleteFileByFileName (   $fileName)

Helper function – remove files and associated articles with a particular filename.

Parameters
string$fileNameFilename to be removed
Returns
bool

Definition at line 62 of file ApiUploadTestCase.php.

References deleteFileByTitle(), Title\newFromText(), and NS_FILE.

Referenced by ApiUploadTest\testUpload(), ApiUploadTest\testUploadChunks(), ApiUploadTest\testUploadSameContent(), ApiUploadTest\testUploadSameFileName(), ApiUploadTest\testUploadStash(), and ApiUploadTest\testUploadZeroLength().

◆ deleteFileByTitle()

ApiUploadTestCase::deleteFileByTitle (   $title)

Helper function – remove files and associated articles by Title.

Parameters
Title$titleTitle to be removed
Returns
bool

Definition at line 27 of file ApiUploadTestCase.php.

References $file, $title, FileDeleteForm\doDelete(), WikiPage\factory(), Title\newFromText(), NS_FILE, and wfFindFile().

Referenced by deleteFileByContent(), and deleteFileByFileName().

◆ fakeUploadChunk()

ApiUploadTestCase::fakeUploadChunk (   $fieldName,
  $fileName,
  $type,
$chunkData 
)

Definition at line 124 of file ApiUploadTestCase.php.

References $type, and null.

Referenced by ApiUploadTest\testUploadChunks().

◆ fakeUploadFile()

ApiUploadTestCase::fakeUploadFile (   $fieldName,
  $fileName,
  $type,
  $filePath 
)

Fake an upload by dumping the file into temp space, and adding info to $_FILES.

(This is what PHP would normally do).

Parameters
string$fieldNameName this would have in the upload form
string$fileNameName to title this
string$typeMIME type
string$filePathPath where to find file contents
Exceptions
Exception
Returns
bool

Definition at line 97 of file ApiUploadTestCase.php.

References $type, copy, and null.

Referenced by ApiUploadTest\testUpload(), ApiUploadTest\testUploadSameContent(), ApiUploadTest\testUploadSameFileName(), ApiUploadTest\testUploadStash(), and ApiUploadTest\testUploadZeroLength().

◆ setUp()

ApiUploadTestCase::setUp ( )
protected

Fixture – run before every test.

Definition at line 10 of file ApiUploadTestCase.php.

References clearFakeUploads().


The documentation for this class was generated from the following file: