@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at upstream/main 54 lines 1.2 kB view raw
1<?php 2 3/** 4 * Test storage engine. Does not actually store files. Used for unit tests. 5 */ 6final class PhabricatorTestStorageEngine 7 extends PhabricatorFileStorageEngine { 8 9 private static $storage = array(); 10 private static $nextHandle = 1; 11 12 public function getEngineIdentifier() { 13 return 'unit-test'; 14 } 15 16 public function getEnginePriority() { 17 return 1000; 18 } 19 20 public function isTestEngine() { 21 return true; 22 } 23 24 public function canWriteFiles() { 25 return true; 26 } 27 28 public function hasFilesizeLimit() { 29 return false; 30 } 31 32 public function writeFile($data, array $params) { 33 AphrontWriteGuard::willWrite(); 34 self::$storage[self::$nextHandle] = $data; 35 return (string)self::$nextHandle++; 36 } 37 38 public function readFile($handle) { 39 if (isset(self::$storage[$handle])) { 40 return self::$storage[$handle]; 41 } 42 throw new Exception(pht("No such file with handle '%s'!", $handle)); 43 } 44 45 public function deleteFile($handle) { 46 AphrontWriteGuard::willWrite(); 47 unset(self::$storage[$handle]); 48 } 49 50 public function tamperWithFile($handle, $data) { 51 self::$storage[$handle] = $data; 52 } 53 54}