Page MenuHomePhabricator

FauxRequest should allow for adding fake files
Closed, ResolvedPublic


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.

Version: 1.22.0
Severity: enhancement

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:19 AM
bzimport set Reference to bz46163.
bzimport added a subscriber: Unknown Object (MLST).

Change 654332 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Create FauxRequestUpload to fake uploads in tests

Change 654332 merged by jenkins-bot:

[mediawiki/core@master] Create FauxRequestUpload to fake uploads in tests