class FilesystemCacheTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/FilesystemCacheTest.php \Doctrine\Tests\Common\Cache\FilesystemCacheTest
@group DCOM-101
Hierarchy
- class \Doctrine\Tests\Common\Cache\CacheTest extends \Doctrine\Tests\DoctrineTestCase
- class \Doctrine\Tests\Common\Cache\BaseFileCacheTest
- class \Doctrine\Tests\Common\Cache\FilesystemCacheTest
- class \Doctrine\Tests\Common\Cache\BaseFileCacheTest
Expanded class hierarchy of FilesystemCacheTest
File
- vendor/
doctrine/ cache/ tests/ Doctrine/ Tests/ Common/ Cache/ FilesystemCacheTest.php, line 11
Namespace
Doctrine\Tests\Common\CacheView source
class FilesystemCacheTest extends BaseFileCacheTest {
public function testLifetime() {
$cache = $this
->_getCacheDriver();
// Test save
$cache
->save('test_key', 'testing this out', 10);
// Test contains to test that save() worked
$this
->assertTrue($cache
->contains('test_key'));
// Test fetch
$this
->assertEquals('testing this out', $cache
->fetch('test_key'));
// access private methods
$getFilename = new \ReflectionMethod($cache, 'getFilename');
$getNamespacedId = new \ReflectionMethod($cache, 'getNamespacedId');
$getFilename
->setAccessible(true);
$getNamespacedId
->setAccessible(true);
$id = $getNamespacedId
->invoke($cache, 'test_key');
$filename = $getFilename
->invoke($cache, $id);
$data = '';
$lifetime = 0;
$resource = fopen($filename, "r");
if (false !== ($line = fgets($resource))) {
$lifetime = (int) $line;
}
while (false !== ($line = fgets($resource))) {
$data .= $line;
}
$this
->assertNotEquals(0, $lifetime, "previous lifetime could not be loaded");
// update lifetime
$lifetime = $lifetime - 20;
file_put_contents($filename, $lifetime . PHP_EOL . $data);
// test expired data
$this
->assertFalse($cache
->contains('test_key'));
$this
->assertFalse($cache
->fetch('test_key'));
}
public function testGetStats() {
$cache = $this
->_getCacheDriver();
$stats = $cache
->getStats();
$this
->assertNull($stats[Cache::STATS_HITS]);
$this
->assertNull($stats[Cache::STATS_MISSES]);
$this
->assertNull($stats[Cache::STATS_UPTIME]);
$this
->assertEquals(0, $stats[Cache::STATS_MEMORY_USAGE]);
$this
->assertGreaterThan(0, $stats[Cache::STATS_MEMORY_AVAILABLE]);
}
protected function _getCacheDriver() {
return new FilesystemCache($this->directory);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BaseFileCacheTest:: |
protected | property | ||
BaseFileCacheTest:: |
protected | function |
Return whether multiple cache providers share the same storage. Overrides CacheTest:: |
|
BaseFileCacheTest:: |
public | function | ||
BaseFileCacheTest:: |
public | function | ||
CacheTest:: |
public | function | The following values get converted to FALSE if you cast them to a boolean. | |
CacheTest:: |
public | function | ||
CacheTest:: |
public | function | @dataProvider provideCrudValues | |
CacheTest:: |
public | function | Check to see that objects are correctly serialized and unserialized by the cache provider. | 1 |
CacheTest:: |
public | function | ||
CacheTest:: |
public | function | ||
CacheTest:: |
public | function | ||
CacheTest:: |
public | function | Check to see that, even if the user saves a value that can be interpreted as false, the cache adapter will still recognize its existence there. | 2 |
CacheTest:: |
public | function | ||
CacheTest:: |
public | function | ||
CacheTest:: |
public | function | Check to see that objects fetched via fetchMultiple are properly unserialized | 1 |
CacheTest:: |
public | function | ||
CacheTest:: |
public | function | ||
CacheTest:: |
public | function | ||
CacheTest:: |
public | function | ||
FilesystemCacheTest:: |
public | function |
@group DCOM-43 Overrides CacheTest:: |
|
FilesystemCacheTest:: |
public | function | ||
FilesystemCacheTest:: |
protected | function |
Overrides CacheTest:: |