Last modified: 2014-02-12 23:35:54 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T48163, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 46163 - FauxRequest should allow for adding fake files
FauxRequest should allow for adding fake files
Status: NEW
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.22.0
All All
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-15 17:29 UTC by Brion Vibber
Modified: 2014-02-12 23:35 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Brion Vibber 2013-03-15 17:29:23 UTC
Would occasionally be useful to use FauxRequest for internal API stuff with files.

Something like this maybe?


class FauxWebRequestUpload extends WebRequestUpload {
  public function __construct($request, $filedata) {
    $tmp = tempnam(sys_get_temp_dir(), 'fakeupload');
    file_put_contents($tmp, $filedata);
    $this->doesExist = true;
    $this->fileInfo = array(
      'name' => $tmp,
      'type' => 'application/octet-stream',
      'size' => strlen($filedata),
      'tmp_name' => $tmp
    );
  }
}

class FauxRequest {
...
  function addUpload( $name, $filedata ) {
    $this->uploads[$name] = new FauxWebRequestUpload($this, $filedata);
  }
...
  function getUpload( $name ) {
    return $this->uploads[$name];
  }
...
}

Or possibly allow passing FauxWebRequestUploads directly into the parameters.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links