Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176

This commit is contained in:
Pantheon Automation 2015-08-17 17:00:26 -07:00 committed by Greg Anderson
commit 9921556621
13277 changed files with 1459781 additions and 0 deletions

View 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();
}
}

View file

@ -0,0 +1,26 @@
<?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);
}
protected function isSharedStorage()
{
return false;
}
}

View file

@ -0,0 +1,40 @@
<?php
namespace Doctrine\Tests\Common\Cache;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
abstract class BaseFileCacheTest extends CacheTest
{
protected $directory;
public function setUp()
{
do {
$this->directory = sys_get_temp_dir() . '/doctrine_cache_'. uniqid();
} while (file_exists($this->directory));
}
public function tearDown()
{
if ( ! is_dir($this->directory)) {
return;
}
$iterator = new RecursiveDirectoryIterator($this->directory);
foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) {
if ($file->isFile()) {
@unlink($file->getRealPath());
} elseif ($file->isDir()) {
@rmdir($file->getRealPath());
}
}
}
protected function isSharedStorage()
{
return false;
}
}

View file

@ -0,0 +1,242 @@
<?php
namespace Doctrine\Tests\Common\Cache;
use Doctrine\Common\Cache\Cache;
use ArrayObject;
abstract class CacheTest extends \Doctrine\Tests\DoctrineTestCase
{
/**
* @dataProvider provideCrudValues
*/
public function testBasicCrudOperations($value)
{
$cache = $this->_getCacheDriver();
// Test saving a value, checking if it exists, and fetching it back
$this->assertTrue($cache->save('key', 'value'));
$this->assertTrue($cache->contains('key'));
$this->assertEquals('value', $cache->fetch('key'));
// Test updating the value of a cache entry
$this->assertTrue($cache->save('key', 'value-changed'));
$this->assertTrue($cache->contains('key'));
$this->assertEquals('value-changed', $cache->fetch('key'));
// Test deleting a value
$this->assertTrue($cache->delete('key'));
$this->assertFalse($cache->contains('key'));
}
public function provideCrudValues()
{
return array(
'array' => array(array('one', 2, 3.0)),
'string' => array('value'),
'integer' => array(1),
'float' => array(1.5),
'object' => array(new ArrayObject()),
'null' => array(null),
);
}
public function testDeleteAll()
{
$cache = $this->_getCacheDriver();
$this->assertTrue($cache->save('key1', 1));
$this->assertTrue($cache->save('key2', 2));
$this->assertTrue($cache->deleteAll());
$this->assertFalse($cache->contains('key1'));
$this->assertFalse($cache->contains('key2'));
}
public function testDeleteAllAndNamespaceVersioningBetweenCaches()
{
if ( ! $this->isSharedStorage()) {
$this->markTestSkipped('The ' . __CLASS__ .' does not use shared storage');
}
$cache1 = $this->_getCacheDriver();
$cache2 = $this->_getCacheDriver();
$this->assertTrue($cache1->save('key1', 1));
$this->assertTrue($cache2->save('key2', 2));
/* Both providers are initialized with the same namespace version, so
* they can see entries set by each other.
*/
$this->assertTrue($cache1->contains('key1'));
$this->assertTrue($cache1->contains('key2'));
$this->assertTrue($cache2->contains('key1'));
$this->assertTrue($cache2->contains('key2'));
/* Deleting all entries through one provider will only increment the
* namespace version on that object (and in the cache itself, which new
* instances will use to initialize). The second provider will retain
* its original version and still see stale data.
*/
$this->assertTrue($cache1->deleteAll());
$this->assertFalse($cache1->contains('key1'));
$this->assertFalse($cache1->contains('key2'));
$this->assertTrue($cache2->contains('key1'));
$this->assertTrue($cache2->contains('key2'));
/* A new cache provider should not see the deleted entries, since its
* namespace version will be initialized.
*/
$cache3 = $this->_getCacheDriver();
$this->assertFalse($cache3->contains('key1'));
$this->assertFalse($cache3->contains('key2'));
}
public function testFlushAll()
{
$cache = $this->_getCacheDriver();
$this->assertTrue($cache->save('key1', 1));
$this->assertTrue($cache->save('key2', 2));
$this->assertTrue($cache->flushAll());
$this->assertFalse($cache->contains('key1'));
$this->assertFalse($cache->contains('key2'));
}
public function testFlushAllAndNamespaceVersioningBetweenCaches()
{
if ( ! $this->isSharedStorage()) {
$this->markTestSkipped('The ' . __CLASS__ .' does not use shared storage');
}
$cache1 = $this->_getCacheDriver();
$cache2 = $this->_getCacheDriver();
/* Deleting all elements from the first provider should increment its
* namespace version before saving the first entry.
*/
$cache1->deleteAll();
$this->assertTrue($cache1->save('key1', 1));
/* The second provider will be initialized with the same namespace
* version upon its first save operation.
*/
$this->assertTrue($cache2->save('key2', 2));
/* Both providers have the same namespace version and can see entires
* set by each other.
*/
$this->assertTrue($cache1->contains('key1'));
$this->assertTrue($cache1->contains('key2'));
$this->assertTrue($cache2->contains('key1'));
$this->assertTrue($cache2->contains('key2'));
/* Flushing all entries through one cache will remove all entries from
* the cache but leave their namespace version as-is.
*/
$this->assertTrue($cache1->flushAll());
$this->assertFalse($cache1->contains('key1'));
$this->assertFalse($cache1->contains('key2'));
$this->assertFalse($cache2->contains('key1'));
$this->assertFalse($cache2->contains('key2'));
/* Inserting a new entry will use the same, incremented namespace
* version, and it will be visible to both providers.
*/
$this->assertTrue($cache1->save('key1', 1));
$this->assertTrue($cache1->contains('key1'));
$this->assertTrue($cache2->contains('key1'));
/* A new cache provider will be initialized with the original namespace
* version and not share any visibility with the first two providers.
*/
$cache3 = $this->_getCacheDriver();
$this->assertFalse($cache3->contains('key1'));
$this->assertFalse($cache3->contains('key2'));
$this->assertTrue($cache3->save('key3', 3));
$this->assertTrue($cache3->contains('key3'));
}
public function testNamespace()
{
$cache = $this->_getCacheDriver();
$cache->setNamespace('ns1_');
$this->assertTrue($cache->save('key1', 1));
$this->assertTrue($cache->contains('key1'));
$cache->setNamespace('ns2_');
$this->assertFalse($cache->contains('key1'));
}
public function testDeleteAllNamespace()
{
$cache = $this->_getCacheDriver();
$cache->setNamespace('ns1');
$this->assertFalse($cache->contains('key1'));
$cache->save('key1', 'test');
$this->assertTrue($cache->contains('key1'));
$cache->setNamespace('ns2');
$this->assertFalse($cache->contains('key1'));
$cache->save('key1', 'test');
$this->assertTrue($cache->contains('key1'));
$cache->setNamespace('ns1');
$this->assertTrue($cache->contains('key1'));
$cache->deleteAll();
$this->assertFalse($cache->contains('key1'));
$cache->setNamespace('ns2');
$this->assertTrue($cache->contains('key1'));
$cache->deleteAll();
$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);
}
public function testFetchMissShouldReturnFalse()
{
$cache = $this->_getCacheDriver();
/* Ensure that caches return boolean false instead of null on a fetch
* miss to be compatible with ORM integration.
*/
$result = $cache->fetch('nonexistent_key');
$this->assertFalse($result);
$this->assertNotNull($result);
}
/**
* Return whether multiple cache providers share the same storage.
*
* This is used for skipping certain tests for shared storage behavior.
*
* @return boolean
*/
protected function isSharedStorage()
{
return true;
}
/**
* @return \Doctrine\Common\Cache\CacheProvider
*/
abstract protected function _getCacheDriver();
}

View 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;
}
}

View 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);
}
}

View file

@ -0,0 +1,75 @@
<?php
namespace Doctrine\Tests\Common\Cache;
use Doctrine\Common\Cache\Cache;
use Doctrine\Common\Cache\FilesystemCache;
/**
* @group DCOM-101
*/
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 = (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]);
}
protected function _getCacheDriver()
{
return new FilesystemCache($this->directory);
}
}

View file

@ -0,0 +1,54 @@
<?php
namespace Doctrine\Tests\Common\Cache;
use Doctrine\Common\Cache\MemcacheCache;
use Memcache;
class MemcacheCacheTest extends CacheTest
{
private $memcache;
public function setUp()
{
if ( ! extension_loaded('memcache')) {
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache');
}
$this->memcache = new Memcache();
if (@$this->memcache->connect('localhost', 11211) === false) {
unset($this->memcache);
$this->markTestSkipped('The ' . __CLASS__ .' cannot connect to memcache');
}
}
public function tearDown()
{
if ($this->memcache instanceof Memcache) {
$this->memcache->flush();
}
}
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;
}
}

View file

@ -0,0 +1,56 @@
<?php
namespace Doctrine\Tests\Common\Cache;
use Doctrine\Common\Cache\MemcachedCache;
use Memcached;
class MemcachedCacheTest extends CacheTest
{
private $memcached;
public function setUp()
{
if ( ! extension_loaded('memcached')) {
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcached');
}
$this->memcached = new Memcached();
$this->memcached->setOption(Memcached::OPT_COMPRESSION, false);
$this->memcached->addServer('127.0.0.1', 11211);
if (@fsockopen('127.0.0.1', 11211) === false) {
unset($this->memcached);
$this->markTestSkipped('The ' . __CLASS__ .' cannot connect to memcache');
}
}
public function tearDown()
{
if ($this->memcached instanceof Memcached) {
$this->memcached->flush();
}
}
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 MemcachedCache();
$driver->setMemcached($this->memcached);
return $driver;
}
}

View file

@ -0,0 +1,61 @@
<?php
namespace Doctrine\Tests\Common\Cache;
use Doctrine\Common\Cache\Cache;
use Doctrine\Common\Cache\MongoDBCache;
use MongoClient;
use MongoCollection;
class MongoDBCacheTest extends CacheTest
{
/**
* @var MongoCollection
*/
private $collection;
public function setUp()
{
if ( ! version_compare(phpversion('mongo'), '1.3.0', '>=')) {
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of mongo >= 1.3.0');
}
$mongo = new MongoClient();
$this->collection = $mongo->selectCollection('doctrine_common_cache', 'test');
}
public function tearDown()
{
if ($this->collection instanceof MongoCollection) {
$this->collection->drop();
}
}
public function testSaveWithNonUtf8String()
{
// Invalid 2-octet sequence
$data = "\xc3\x28";
$cache = $this->_getCacheDriver();
$this->assertTrue($cache->save('key', $data));
$this->assertEquals($data, $cache->fetch('key'));
}
public function testGetStats()
{
$cache = $this->_getCacheDriver();
$stats = $cache->getStats();
$this->assertNull($stats[Cache::STATS_HITS]);
$this->assertNull($stats[Cache::STATS_MISSES]);
$this->assertGreaterThan(0, $stats[Cache::STATS_UPTIME]);
$this->assertEquals(0, $stats[Cache::STATS_MEMORY_USAGE]);
$this->assertNull($stats[Cache::STATS_MEMORY_AVAILABLE]);
}
protected function _getCacheDriver()
{
return new MongoDBCache($this->collection);
}
}

View file

@ -0,0 +1,118 @@
<?php
namespace Doctrine\Tests\Common\Cache;
use Doctrine\Common\Cache\Cache;
use Doctrine\Common\Cache\PhpFileCache;
/**
* @group DCOM-101
*/
class PhpFileCacheTest 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');
$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]);
}
protected function _getCacheDriver()
{
return new PhpFileCache($this->directory);
}
}
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']);
}
}

View 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;
}
}

View 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);
}
}

View 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();
}
}

View 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();
}
}

View 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();
}
}

View file

@ -0,0 +1,10 @@
<?php
namespace Doctrine\Tests;
/**
* Base testcase class for all Doctrine testcases.
*/
abstract class DoctrineTestCase extends \PHPUnit_Framework_TestCase
{
}

View file

@ -0,0 +1,19 @@
<?php
/*
* This file bootstraps the test environment.
*/
error_reporting(E_ALL | E_STRICT);
if (file_exists(__DIR__ . '/../../../vendor/autoload.php')) {
// dependencies were installed via composer - this is the main project
$classLoader = require __DIR__ . '/../../../vendor/autoload.php';
} elseif (file_exists(__DIR__ . '/../../../../../autoload.php')) {
// installed as a dependency in `vendor`
$classLoader = require __DIR__ . '/../../../../../autoload.php';
} else {
throw new Exception('Can\'t find autoload.php. Did you install dependencies via Composer?');
}
/* @var $classLoader \Composer\Autoload\ClassLoader */
$classLoader->add('Doctrine\\Tests\\', __DIR__ . '/../../');
unset($classLoader);

View file

@ -0,0 +1,6 @@
extension="mongo.so"
extension="memcache.so"
extension="memcached.so"
apc.enabled=1
apc.enable_cli=1

View file

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="../Doctrine/Tests/TestInit.php"
convertWarningsToExceptions="true"
convertNoticesToExceptions="true"
convertErrorsToExceptions="true"
backupStaticAttributes="false"
processIsolation="false"
stopOnFailure="false"
backupGlobals="false"
syntaxCheck="false"
colors="true">
<logging>
<log type="coverage-clover" target="../../build/logs/clover.xml"/>
</logging>
<testsuites>
<testsuite name="Doctrine Cache Test Suite">
<directory>../Doctrine/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>../../lib/Doctrine/</directory>
</whitelist>
</filter>
<groups>
<exclude>
<group>performance</group>
</exclude>
</groups>
</phpunit>