Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/files/engine/PhabricatorTestStorageEngine.php
12241 views
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 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
}
55
56