mirror of
https://0xacab.org/radar/radar-wp.git
synced 2025-06-09 21:26:27 +02:00
Initial import.
This commit is contained in:
commit
86383280c9
428 changed files with 68738 additions and 0 deletions
20
vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/ApcCacheTest.php
vendored
Normal file
20
vendor/doctrine/common/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/common/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php
vendored
Normal file
21
vendor/doctrine/common/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);
|
||||
}
|
||||
}
|
91
vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/CacheTest.php
vendored
Normal file
91
vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/CacheTest.php
vendored
Normal file
|
@ -0,0 +1,91 @@
|
|||
<?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_AVAILIABLE, $stats);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Doctrine\Common\Cache\CacheProvider
|
||||
*/
|
||||
abstract protected function _getCacheDriver();
|
||||
}
|
97
vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/FilesystemCacheTest.php
vendored
Normal file
97
vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/FilesystemCacheTest.php
vendored
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\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);
|
||||
}
|
||||
|
||||
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/common/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php
vendored
Normal file
45
vendor/doctrine/common/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/common/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php
vendored
Normal file
48
vendor/doctrine/common/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;
|
||||
}
|
||||
}
|
149
vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/PhpFileCacheTest.php
vendored
Normal file
149
vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/PhpFileCacheTest.php
vendored
Normal file
|
@ -0,0 +1,149 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\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);
|
||||
}
|
||||
|
||||
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/common/tests/Doctrine/Tests/Common/Cache/RedisCacheTest.php
vendored
Normal file
30
vendor/doctrine/common/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;
|
||||
}
|
||||
}
|
20
vendor/doctrine/common/tests/Doctrine/Tests/Common/Cache/WinCacheCacheTest.php
vendored
Normal file
20
vendor/doctrine/common/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/common/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php
vendored
Normal file
20
vendor/doctrine/common/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/common/tests/Doctrine/Tests/Common/Cache/ZendDataCacheTest.php
vendored
Normal file
28
vendor/doctrine/common/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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue