@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
1<?php
2
3final class PhabricatorCachesTestCase
4 extends PhabricatorTestCase {
5
6 public function testRequestCache() {
7 $cache = PhabricatorCaches::getRequestCache();
8
9 $test_key = 'unit.'.Filesystem::readRandomCharacters(8);
10
11 $default_value = pht('Default');
12 $new_value = pht('New Value');
13
14 $this->assertEqual(
15 $default_value,
16 $cache->getKey($test_key, $default_value));
17
18 // Set a key, verify it persists.
19 $cache = PhabricatorCaches::getRequestCache();
20 $cache->setKey($test_key, $new_value);
21 $this->assertEqual(
22 $new_value,
23 $cache->getKey($test_key, $default_value));
24
25 // Refetch the cache, verify it's really a cache.
26 $cache = PhabricatorCaches::getRequestCache();
27 $this->assertEqual(
28 $new_value,
29 $cache->getKey($test_key, $default_value));
30
31 // Destroy the cache.
32 PhabricatorCaches::destroyRequestCache();
33
34 // Now, the value should be missing again.
35 $cache = PhabricatorCaches::getRequestCache();
36 $this->assertEqual(
37 $default_value,
38 $cache->getKey($test_key, $default_value));
39 }
40
41}