[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/files/engine/ -> PhabricatorTestStorageEngine.php (source)

   1  <?php
   2  
   3  /**
   4   * Test storage engine. Does not actually store files. Used for unit tests.
   5   */
   6  final 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 writeFile($data, array $params) {
  17      AphrontWriteGuard::willWrite();
  18      self::$storage[self::$nextHandle] = $data;
  19      return (string)self::$nextHandle++;
  20    }
  21  
  22    public function readFile($handle) {
  23      if (isset(self::$storage[$handle])) {
  24        return self::$storage[$handle];
  25      }
  26      throw new Exception("No such file with handle '{$handle}'!");
  27    }
  28  
  29    public function deleteFile($handle) {
  30      AphrontWriteGuard::willWrite();
  31      unset(self::$storage[$handle]);
  32    }
  33  
  34  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1