Generate file attachment transactions for explicit Remarkup attachments on common...
[phabricator.git] / src / applications / cache / __tests__ / PhabricatorCachesTestCase.php
blob7cfa713ead2c3ebe9d942cc8adab01c7e8ff700f
1 <?php
3 final class PhabricatorCachesTestCase
4 extends PhabricatorTestCase {
6 public function testRequestCache() {
7 $cache = PhabricatorCaches::getRequestCache();
9 $test_key = 'unit.'.Filesystem::readRandomCharacters(8);
11 $default_value = pht('Default');
12 $new_value = pht('New Value');
14 $this->assertEqual(
15 $default_value,
16 $cache->getKey($test_key, $default_value));
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));
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));
31 // Destroy the cache.
32 PhabricatorCaches::destroyRequestCache();
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));