the whole shebang
This commit is contained in:
20
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/ApcCacheTest.php
vendored
Normal file
20
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/ApcCacheTest.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\ApcCache;
|
||||
|
||||
class ApcCacheTest extends CacheTest
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if ( ! extension_loaded('apc') || false === @apc_cache_info()) {
|
||||
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of APC');
|
||||
}
|
||||
}
|
||||
|
||||
protected function _getCacheDriver()
|
||||
{
|
||||
return new ApcCache();
|
||||
}
|
||||
}
|
21
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php
vendored
Normal file
21
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\ArrayCache;
|
||||
|
||||
class ArrayCacheTest extends CacheTest
|
||||
{
|
||||
protected function _getCacheDriver()
|
||||
{
|
||||
return new ArrayCache();
|
||||
}
|
||||
|
||||
public function testGetStats()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
$stats = $cache->getStats();
|
||||
|
||||
$this->assertNull($stats);
|
||||
}
|
||||
}
|
103
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/CacheTest.php
vendored
Normal file
103
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/CacheTest.php
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
|
||||
abstract class CacheTest extends \Doctrine\Tests\DoctrineTestCase
|
||||
{
|
||||
public function testBasics()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
|
||||
// Test save
|
||||
$cache->save('test_key', 'testing this out');
|
||||
|
||||
// Test contains to test that save() worked
|
||||
$this->assertTrue($cache->contains('test_key'));
|
||||
|
||||
// Test fetch
|
||||
$this->assertEquals('testing this out', $cache->fetch('test_key'));
|
||||
|
||||
// Test delete
|
||||
$cache->save('test_key2', 'test2');
|
||||
$cache->delete('test_key2');
|
||||
$this->assertFalse($cache->contains('test_key2'));
|
||||
}
|
||||
|
||||
public function testObjects()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
|
||||
// Fetch/save test with objects (Is cache driver serializes/unserializes objects correctly ?)
|
||||
$cache->save('test_object_key', new \ArrayObject());
|
||||
$this->assertTrue($cache->fetch('test_object_key') instanceof \ArrayObject);
|
||||
}
|
||||
|
||||
public function testDeleteAll()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
$cache->save('test_key1', '1');
|
||||
$cache->save('test_key2', '2');
|
||||
$cache->deleteAll();
|
||||
|
||||
$this->assertFalse($cache->contains('test_key1'));
|
||||
$this->assertFalse($cache->contains('test_key2'));
|
||||
}
|
||||
|
||||
public function testFlushAll()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
$cache->save('test_key1', '1');
|
||||
$cache->save('test_key2', '2');
|
||||
$cache->flushAll();
|
||||
|
||||
$this->assertFalse($cache->contains('test_key1'));
|
||||
$this->assertFalse($cache->contains('test_key2'));
|
||||
}
|
||||
|
||||
public function testNamespace()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
$cache->setNamespace('test_');
|
||||
$cache->save('key1', 'test');
|
||||
|
||||
$this->assertTrue($cache->contains('key1'));
|
||||
|
||||
$cache->setNamespace('test2_');
|
||||
|
||||
$this->assertFalse($cache->contains('key1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DCOM-43
|
||||
*/
|
||||
public function testGetStats()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
$stats = $cache->getStats();
|
||||
|
||||
$this->assertArrayHasKey(Cache::STATS_HITS, $stats);
|
||||
$this->assertArrayHasKey(Cache::STATS_MISSES, $stats);
|
||||
$this->assertArrayHasKey(Cache::STATS_UPTIME, $stats);
|
||||
$this->assertArrayHasKey(Cache::STATS_MEMORY_USAGE, $stats);
|
||||
$this->assertArrayHasKey(Cache::STATS_MEMORY_AVAILABLE, $stats);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that all supported caches return "false" instead of "null" to be compatible
|
||||
* with ORM integration.
|
||||
*/
|
||||
public function testFalseOnFailedFetch()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
$result = $cache->fetch('nonexistent_key');
|
||||
$this->assertFalse($result);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\Common\Cache\CacheProvider
|
||||
*/
|
||||
abstract protected function _getCacheDriver();
|
||||
}
|
47
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/CouchbaseCacheTest.php
vendored
Normal file
47
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/CouchbaseCacheTest.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Couchbase;
|
||||
use Doctrine\Common\Cache\CouchbaseCache;
|
||||
|
||||
class CouchbaseCacheTest extends CacheTest
|
||||
{
|
||||
private $couchbase;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
if (extension_loaded('couchbase')) {
|
||||
try {
|
||||
$this->couchbase = new Couchbase('127.0.0.1', 'Administrator', 'password', 'default');
|
||||
} catch(Exception $ex) {
|
||||
$this->markTestSkipped('Could not instantiate the Couchbase cache because of: ' . $ex);
|
||||
}
|
||||
} else {
|
||||
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of the couchbase extension');
|
||||
}
|
||||
}
|
||||
|
||||
public function testNoExpire()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
$cache->save('noexpire', 'value', 0);
|
||||
sleep(1);
|
||||
$this->assertTrue($cache->contains('noexpire'), 'Couchbase provider should support no-expire');
|
||||
}
|
||||
|
||||
public function testLongLifetime()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
$cache->save('key', 'value', 30 * 24 * 3600 + 1);
|
||||
|
||||
$this->assertTrue($cache->contains('key'), 'Couchbase provider should support TTL > 30 days');
|
||||
}
|
||||
|
||||
protected function _getCacheDriver()
|
||||
{
|
||||
$driver = new CouchbaseCache();
|
||||
$driver->setCouchbase($this->couchbase);
|
||||
return $driver;
|
||||
}
|
||||
}
|
107
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/FileCacheTest.php
vendored
Normal file
107
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/FileCacheTest.php
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
/**
|
||||
* @group DCOM-101
|
||||
*/
|
||||
class FileCacheTest extends \Doctrine\Tests\DoctrineTestCase
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\Common\Cache\FileCache
|
||||
*/
|
||||
private $driver;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->driver = $this->getMock(
|
||||
'Doctrine\Common\Cache\FileCache',
|
||||
array('doFetch', 'doContains', 'doSave'),
|
||||
array(), '', false
|
||||
);
|
||||
}
|
||||
|
||||
public function getProviderFileName()
|
||||
{
|
||||
return array(
|
||||
//The characters :\/<>"*?| are not valid in Windows filenames.
|
||||
array('key:1', 'key1'),
|
||||
array('key\2', 'key2'),
|
||||
array('key/3', 'key3'),
|
||||
array('key<4', 'key4'),
|
||||
array('key>5', 'key5'),
|
||||
array('key"6', 'key6'),
|
||||
array('key*7', 'key7'),
|
||||
array('key?8', 'key8'),
|
||||
array('key|9', 'key9'),
|
||||
array('key[0]','key[0]'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getProviderFileName
|
||||
*/
|
||||
public function testInvalidFilename($key, $expected)
|
||||
{
|
||||
$cache = $this->driver;
|
||||
$method = new \ReflectionMethod($cache, 'getFilename');
|
||||
|
||||
$method->setAccessible(true);
|
||||
|
||||
$value = $method->invoke($cache, $key);
|
||||
$actual = pathinfo($value, PATHINFO_FILENAME);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
public function testFilenameCollision()
|
||||
{
|
||||
$data['key:0'] = 'key0';
|
||||
$data['key\0'] = 'key0';
|
||||
$data['key/0'] = 'key0';
|
||||
$data['key<0'] = 'key0';
|
||||
$data['key>0'] = 'key0';
|
||||
$data['key"0'] = 'key0';
|
||||
$data['key*0'] = 'key0';
|
||||
$data['key?0'] = 'key0';
|
||||
$data['key|0'] = 'key0';
|
||||
|
||||
$paths = array();
|
||||
$cache = $this->driver;
|
||||
$method = new \ReflectionMethod($cache, 'getFilename');
|
||||
|
||||
$method->setAccessible(true);
|
||||
|
||||
foreach ($data as $key => $expected) {
|
||||
$path = $method->invoke($cache, $key);
|
||||
$actual = pathinfo($path, PATHINFO_FILENAME);
|
||||
|
||||
$this->assertNotContains($path, $paths);
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$paths[] = $path;
|
||||
}
|
||||
}
|
||||
|
||||
public function testFilenameShouldCreateThePathWithFourSubDirectories()
|
||||
{
|
||||
$cache = $this->driver;
|
||||
$method = new \ReflectionMethod($cache, 'getFilename');
|
||||
$key = 'item-key';
|
||||
$expectedDir[] = '84e0e2e893febb73';
|
||||
$expectedDir[] = '7a0fee0c89d53f4b';
|
||||
$expectedDir[] = 'b7fcb44c57cdf3d3';
|
||||
$expectedDir[] = '2ce7363f5d597760';
|
||||
$expectedDir = implode(DIRECTORY_SEPARATOR, $expectedDir);
|
||||
|
||||
$method->setAccessible(true);
|
||||
|
||||
$path = $method->invoke($cache, $key);
|
||||
$filename = pathinfo($path, PATHINFO_FILENAME);
|
||||
$dirname = pathinfo($path, PATHINFO_DIRNAME);
|
||||
|
||||
$this->assertEquals('item-key', $filename);
|
||||
$this->assertEquals(DIRECTORY_SEPARATOR . $expectedDir, $dirname);
|
||||
$this->assertEquals(DIRECTORY_SEPARATOR . $expectedDir . DIRECTORY_SEPARATOR . $key, $path);
|
||||
}
|
||||
}
|
102
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/FilesystemCacheTest.php
vendored
Normal file
102
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/FilesystemCacheTest.php
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Doctrine\Common\Cache\FilesystemCache;
|
||||
|
||||
/**
|
||||
* @group DCOM-101
|
||||
*/
|
||||
class FilesystemCacheTest extends CacheTest
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\Common\Cache\FilesystemCache
|
||||
*/
|
||||
private $driver;
|
||||
|
||||
protected function _getCacheDriver()
|
||||
{
|
||||
$dir = sys_get_temp_dir() . "/doctrine_cache_". uniqid();
|
||||
$this->assertFalse(is_dir($dir));
|
||||
|
||||
$this->driver = new FilesystemCache($dir);
|
||||
$this->assertTrue(is_dir($dir));
|
||||
|
||||
return $this->driver;
|
||||
}
|
||||
|
||||
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 = (integer) $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]);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
$dir = $this->driver->getDirectory();
|
||||
$ext = $this->driver->getExtension();
|
||||
$iterator = new \RecursiveDirectoryIterator($dir);
|
||||
|
||||
foreach (new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST) as $file) {
|
||||
if ($file->isFile()) {
|
||||
@unlink($file->getRealPath());
|
||||
} else {
|
||||
@rmdir($file->getRealPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
45
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php
vendored
Normal file
45
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\MemcacheCache;
|
||||
|
||||
class MemcacheCacheTest extends CacheTest
|
||||
{
|
||||
private $_memcache;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
if (extension_loaded('memcache')) {
|
||||
$this->_memcache = new \Memcache;
|
||||
$ok = @$this->_memcache->connect('localhost', 11211);
|
||||
if (!$ok) {
|
||||
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache');
|
||||
}
|
||||
} else {
|
||||
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache');
|
||||
}
|
||||
}
|
||||
|
||||
public function testNoExpire() {
|
||||
$cache = $this->_getCacheDriver();
|
||||
$cache->save('noexpire', 'value', 0);
|
||||
sleep(1);
|
||||
$this->assertTrue($cache->contains('noexpire'), 'Memcache provider should support no-expire');
|
||||
}
|
||||
|
||||
public function testLongLifetime()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
$cache->save('key', 'value', 30 * 24 * 3600 + 1);
|
||||
$this->assertTrue($cache->contains('key'), 'Memcache provider should support TTL > 30 days');
|
||||
}
|
||||
|
||||
protected function _getCacheDriver()
|
||||
{
|
||||
$driver = new MemcacheCache();
|
||||
$driver->setMemcache($this->_memcache);
|
||||
return $driver;
|
||||
}
|
||||
|
||||
}
|
48
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php
vendored
Normal file
48
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\MemcachedCache;
|
||||
|
||||
class MemcachedCacheTest extends CacheTest
|
||||
{
|
||||
private $memcached;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
if (extension_loaded('memcached')) {
|
||||
$this->memcached = new \Memcached();
|
||||
$this->memcached->setOption(\Memcached::OPT_COMPRESSION, false);
|
||||
$this->memcached->addServer('127.0.0.1', 11211);
|
||||
|
||||
$fh = @fsockopen('127.0.0.1', 11211);
|
||||
if (!$fh) {
|
||||
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache');
|
||||
}
|
||||
} else {
|
||||
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache');
|
||||
}
|
||||
}
|
||||
|
||||
public function testNoExpire() {
|
||||
$cache = $this->_getCacheDriver();
|
||||
$cache->save('noexpire', 'value', 0);
|
||||
sleep(1);
|
||||
$this->assertTrue($cache->contains('noexpire'), 'Memcache provider should support no-expire');
|
||||
}
|
||||
|
||||
public function testLongLifetime()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
$cache->save('key', 'value', 30 * 24 * 3600 + 1);
|
||||
|
||||
$this->assertTrue($cache->contains('key'), 'Memcached provider should support TTL > 30 days');
|
||||
}
|
||||
|
||||
protected function _getCacheDriver()
|
||||
{
|
||||
$driver = new MemcachedCache();
|
||||
$driver->setMemcached($this->memcached);
|
||||
return $driver;
|
||||
}
|
||||
}
|
154
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/PhpFileCacheTest.php
vendored
Normal file
154
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/PhpFileCacheTest.php
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Doctrine\Common\Cache\PhpFileCache;
|
||||
|
||||
/**
|
||||
* @group DCOM-101
|
||||
*/
|
||||
class PhpFileCacheTest extends CacheTest
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\Common\Cache\PhpFileCache
|
||||
*/
|
||||
private $driver;
|
||||
|
||||
protected function _getCacheDriver()
|
||||
{
|
||||
$dir = sys_get_temp_dir() . "/doctrine_cache_". uniqid();
|
||||
$this->assertFalse(is_dir($dir));
|
||||
|
||||
$this->driver = new PhpFileCache($dir);
|
||||
$this->assertTrue(is_dir($dir));
|
||||
|
||||
return $this->driver;
|
||||
}
|
||||
|
||||
public function testObjects()
|
||||
{
|
||||
$this->markTestSkipped('PhpFileCache does not support saving objects that dont implement __set_state()');
|
||||
}
|
||||
|
||||
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');
|
||||
$path = $getFilename->invoke($cache, $id);
|
||||
$value = include $path;
|
||||
|
||||
// update lifetime
|
||||
$value['lifetime'] = $value['lifetime'] - 20;
|
||||
file_put_contents($path, '<?php return unserialize(' . var_export(serialize($value), true) . ');');
|
||||
|
||||
// test expired data
|
||||
$this->assertFalse($cache->contains('test_key'));
|
||||
$this->assertFalse($cache->fetch('test_key'));
|
||||
}
|
||||
|
||||
public function testImplementsSetState()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
|
||||
// Test save
|
||||
$cache->save('test_set_state', new SetStateClass(array(1,2,3)));
|
||||
|
||||
//Test __set_state call
|
||||
$this->assertCount(0, SetStateClass::$values);
|
||||
|
||||
// Test fetch
|
||||
$value = $cache->fetch('test_set_state');
|
||||
$this->assertInstanceOf('Doctrine\Tests\Common\Cache\SetStateClass', $value);
|
||||
$this->assertEquals(array(1,2,3), $value->getValue());
|
||||
|
||||
//Test __set_state call
|
||||
$this->assertCount(1, SetStateClass::$values);
|
||||
|
||||
// Test contains
|
||||
$this->assertTrue($cache->contains('test_set_state'));
|
||||
}
|
||||
|
||||
public function testNotImplementsSetState()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$cache->save('test_not_set_state', new NotSetStateClass(array(1,2,3)));
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
if (!$this->driver) {
|
||||
return;
|
||||
}
|
||||
|
||||
$dir = $this->driver->getDirectory();
|
||||
$ext = $this->driver->getExtension();
|
||||
$iterator = new \RecursiveDirectoryIterator($dir);
|
||||
|
||||
foreach (new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST) as $file) {
|
||||
if ($file->isFile()) {
|
||||
@unlink($file->getRealPath());
|
||||
} else {
|
||||
@rmdir($file->getRealPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class NotSetStateClass
|
||||
{
|
||||
private $value;
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
|
||||
class SetStateClass extends NotSetStateClass
|
||||
{
|
||||
public static $values = array();
|
||||
|
||||
public static function __set_state($data)
|
||||
{
|
||||
self::$values = $data;
|
||||
return new self($data['value']);
|
||||
}
|
||||
}
|
30
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/RedisCacheTest.php
vendored
Normal file
30
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/RedisCacheTest.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\RedisCache;
|
||||
|
||||
class RedisCacheTest extends CacheTest
|
||||
{
|
||||
private $_redis;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
if (extension_loaded('redis')) {
|
||||
$this->_redis = new \Redis();
|
||||
$ok = @$this->_redis->connect('127.0.0.1');
|
||||
if (!$ok) {
|
||||
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of redis');
|
||||
}
|
||||
} else {
|
||||
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of redis');
|
||||
}
|
||||
}
|
||||
|
||||
protected function _getCacheDriver()
|
||||
{
|
||||
$driver = new RedisCache();
|
||||
$driver->setRedis($this->_redis);
|
||||
return $driver;
|
||||
}
|
||||
}
|
64
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/RiakCacheTest.php
vendored
Normal file
64
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/RiakCacheTest.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Riak\Bucket;
|
||||
use Riak\Connection;
|
||||
use Riak\Exception;
|
||||
use Doctrine\Common\Cache\RiakCache;
|
||||
|
||||
/**
|
||||
* RiakCache test
|
||||
*
|
||||
* @group Riak
|
||||
*/
|
||||
class RiakCacheTest extends CacheTest
|
||||
{
|
||||
/**
|
||||
* @var \Riak\Connection
|
||||
*/
|
||||
private $connection;
|
||||
|
||||
/**
|
||||
* @var \Riak\Bucket
|
||||
*/
|
||||
private $bucket;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
if ( ! extension_loaded('riak')) {
|
||||
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of Riak');
|
||||
}
|
||||
|
||||
try {
|
||||
$this->connection = new Connection('127.0.0.1', 8087);
|
||||
$this->bucket = new Bucket($this->connection, 'test');
|
||||
} catch (Exception\RiakException $e) {
|
||||
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of Riak');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function testGetStats()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
$stats = $cache->getStats();
|
||||
|
||||
$this->assertNull($stats);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve RiakCache instance.
|
||||
*
|
||||
* @return \Doctrine\Common\Cache\RiakCache
|
||||
*/
|
||||
protected function _getCacheDriver()
|
||||
{
|
||||
return new RiakCache($this->bucket);
|
||||
}
|
||||
}
|
20
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/WinCacheCacheTest.php
vendored
Normal file
20
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/WinCacheCacheTest.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\WincacheCache;
|
||||
|
||||
class WincacheCacheTest extends CacheTest
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if ( ! extension_loaded('wincache') || ! function_exists('wincache_ucache_info')) {
|
||||
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of Wincache');
|
||||
}
|
||||
}
|
||||
|
||||
protected function _getCacheDriver()
|
||||
{
|
||||
return new WincacheCache();
|
||||
}
|
||||
}
|
20
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php
vendored
Normal file
20
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\XcacheCache;
|
||||
|
||||
class XcacheCacheTest extends CacheTest
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if ( ! extension_loaded('xcache')) {
|
||||
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of xcache');
|
||||
}
|
||||
}
|
||||
|
||||
protected function _getCacheDriver()
|
||||
{
|
||||
return new XcacheCache();
|
||||
}
|
||||
}
|
28
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/ZendDataCacheTest.php
vendored
Normal file
28
vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/ZendDataCacheTest.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\ZendDataCache;
|
||||
|
||||
class ZendDataCacheTest extends CacheTest
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (!function_exists('zend_shm_cache_fetch') || (php_sapi_name() != 'apache2handler')) {
|
||||
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of Zend Data Cache which only works in apache2handler SAPI');
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetStats()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
$stats = $cache->getStats();
|
||||
|
||||
$this->assertNull($stats);
|
||||
}
|
||||
|
||||
protected function _getCacheDriver()
|
||||
{
|
||||
return new ZendDataCache();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user