Update to drupal-org-drupal 8.0.0-rc2. For more information, see https://www.drupal.org/node/2598668
This commit is contained in:
parent
f32e58e4b1
commit
8e18df8c36
3062 changed files with 15044 additions and 172506 deletions
|
@ -1,20 +0,0 @@
|
|||
<?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();
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
<?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;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
<?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;
|
||||
}
|
||||
}
|
|
@ -1,373 +0,0 @@
|
|||
<?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 testFetchMulti()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
|
||||
$cache->deleteAll();
|
||||
|
||||
// Test saving some values, checking if it exists, and fetching it back with multiGet
|
||||
$this->assertTrue($cache->save('key1', 'value1'));
|
||||
$this->assertTrue($cache->save('key2', 'value2'));
|
||||
|
||||
$this->assertEquals(
|
||||
array('key1' => 'value1', 'key2' => 'value2'),
|
||||
$cache->fetchMultiple(array('key1', 'key2'))
|
||||
);
|
||||
$this->assertEquals(
|
||||
array('key1' => 'value1', 'key2' => 'value2'),
|
||||
$cache->fetchMultiple(array('key1', 'key3', 'key2'))
|
||||
);
|
||||
$this->assertEquals(
|
||||
array('key1' => 'value1', 'key2' => 'value2'),
|
||||
$cache->fetchMultiple(array('key1', 'key2', 'key3'))
|
||||
);
|
||||
}
|
||||
|
||||
public function testFetchMultiWillFilterNonRequestedKeys()
|
||||
{
|
||||
/* @var $cache \Doctrine\Common\Cache\CacheProvider|\PHPUnit_Framework_MockObject_MockObject */
|
||||
$cache = $this->getMockForAbstractClass(
|
||||
'Doctrine\Common\Cache\CacheProvider',
|
||||
array(),
|
||||
'',
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
array('doFetchMultiple')
|
||||
);
|
||||
|
||||
$cache
|
||||
->expects($this->once())
|
||||
->method('doFetchMultiple')
|
||||
->will($this->returnValue(array(
|
||||
'[foo][]' => 'bar',
|
||||
'[bar][]' => 'baz',
|
||||
'[baz][]' => 'tab',
|
||||
)));
|
||||
|
||||
$this->assertEquals(
|
||||
array('foo' => 'bar', 'bar' => 'baz'),
|
||||
$cache->fetchMultiple(array('foo', 'bar'))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @dataProvider falseCastedValuesProvider
|
||||
*/
|
||||
public function testFalseCastedValues($value)
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
|
||||
$this->assertTrue($cache->save('key', $value));
|
||||
$this->assertTrue($cache->contains('key'));
|
||||
$this->assertEquals($value, $cache->fetch('key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* The following values get converted to FALSE if you cast them to a boolean.
|
||||
* @see http://php.net/manual/en/types.comparisons.php
|
||||
*/
|
||||
public function falseCastedValuesProvider()
|
||||
{
|
||||
return array(
|
||||
array(false),
|
||||
array(null),
|
||||
array(array()),
|
||||
array('0'),
|
||||
array(0),
|
||||
array(0.0),
|
||||
array('')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see that objects are correctly serialized and unserialized by the cache
|
||||
* provider.
|
||||
*/
|
||||
public function testCachedObject()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
$cache->deleteAll();
|
||||
$obj = new \stdClass();
|
||||
$obj->foo = "bar";
|
||||
$obj2 = new \stdClass();
|
||||
$obj2->bar = "foo";
|
||||
$obj2->obj = $obj;
|
||||
$obj->obj2 = $obj2;
|
||||
$cache->save("obj", $obj);
|
||||
|
||||
$fetched = $cache->fetch("obj");
|
||||
|
||||
$this->assertInstanceOf("stdClass", $obj);
|
||||
$this->assertInstanceOf("stdClass", $obj->obj2);
|
||||
$this->assertInstanceOf("stdClass", $obj->obj2->obj);
|
||||
$this->assertEquals("bar", $fetched->foo);
|
||||
$this->assertEquals("foo", $fetched->obj2->bar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see that objects fetched via fetchMultiple are properly unserialized
|
||||
*/
|
||||
public function testFetchMultipleObjects()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
$cache->deleteAll();
|
||||
$obj1 = new \stdClass();
|
||||
$obj1->foo = "bar";
|
||||
$cache->save("obj1", $obj1);
|
||||
$obj2 = new \stdClass();
|
||||
$obj2->bar = "baz";
|
||||
$cache->save("obj2", $obj2);
|
||||
|
||||
$fetched = $cache->fetchMultiple(array("obj1", "obj2"));
|
||||
$this->assertInstanceOf("stdClass", $fetched["obj1"]);
|
||||
$this->assertInstanceOf("stdClass", $fetched["obj2"]);
|
||||
$this->assertEquals("bar", $fetched["obj1"]->foo);
|
||||
$this->assertEquals("baz", $fetched["obj2"]->bar);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\ApcCache;
|
||||
use Doctrine\Common\Cache\ArrayCache;
|
||||
use Doctrine\Common\Cache\ChainCache;
|
||||
|
||||
class ChainCacheTest extends CacheTest
|
||||
{
|
||||
protected function _getCacheDriver()
|
||||
{
|
||||
return new ChainCache(array(new ArrayCache()));
|
||||
}
|
||||
|
||||
public function testGetStats()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
$stats = $cache->getStats();
|
||||
|
||||
$this->assertInternalType('array', $stats);
|
||||
}
|
||||
|
||||
public function testOnlyFetchFirstOne()
|
||||
{
|
||||
$cache1 = new ArrayCache();
|
||||
$cache2 = $this->getMockForAbstractClass('Doctrine\Common\Cache\CacheProvider');
|
||||
|
||||
$cache2->expects($this->never())->method('doFetch');
|
||||
|
||||
$chainCache = new ChainCache(array($cache1, $cache2));
|
||||
$chainCache->save('id', 'bar');
|
||||
|
||||
$this->assertEquals('bar', $chainCache->fetch('id'));
|
||||
}
|
||||
|
||||
public function testFetchPropagateToFastestCache()
|
||||
{
|
||||
$cache1 = new ArrayCache();
|
||||
$cache2 = new ArrayCache();
|
||||
|
||||
$cache2->save('bar', 'value');
|
||||
|
||||
$chainCache = new ChainCache(array($cache1, $cache2));
|
||||
|
||||
$this->assertFalse($cache1->contains('bar'));
|
||||
|
||||
$result = $chainCache->fetch('bar');
|
||||
|
||||
$this->assertEquals('value', $result);
|
||||
$this->assertTrue($cache2->contains('bar'));
|
||||
}
|
||||
|
||||
public function testNamespaceIsPropagatedToAllProviders()
|
||||
{
|
||||
$cache1 = new ArrayCache();
|
||||
$cache2 = new ArrayCache();
|
||||
|
||||
$chainCache = new ChainCache(array($cache1, $cache2));
|
||||
$chainCache->setNamespace('bar');
|
||||
|
||||
$this->assertEquals('bar', $cache1->getNamespace());
|
||||
$this->assertEquals('bar', $cache2->getNamespace());
|
||||
}
|
||||
|
||||
public function testDeleteToAllProviders()
|
||||
{
|
||||
$cache1 = $this->getMockForAbstractClass('Doctrine\Common\Cache\CacheProvider');
|
||||
$cache2 = $this->getMockForAbstractClass('Doctrine\Common\Cache\CacheProvider');
|
||||
|
||||
$cache1->expects($this->once())->method('doDelete');
|
||||
$cache2->expects($this->once())->method('doDelete');
|
||||
|
||||
$chainCache = new ChainCache(array($cache1, $cache2));
|
||||
$chainCache->delete('bar');
|
||||
}
|
||||
|
||||
public function testFlushToAllProviders()
|
||||
{
|
||||
$cache1 = $this->getMockForAbstractClass('Doctrine\Common\Cache\CacheProvider');
|
||||
$cache2 = $this->getMockForAbstractClass('Doctrine\Common\Cache\CacheProvider');
|
||||
|
||||
$cache1->expects($this->once())->method('doFlush');
|
||||
$cache2->expects($this->once())->method('doFlush');
|
||||
|
||||
$chainCache = new ChainCache(array($cache1, $cache2));
|
||||
$chainCache->flushAll();
|
||||
}
|
||||
|
||||
protected function isSharedStorage()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
<?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;
|
||||
}
|
||||
}
|
|
@ -1,161 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\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', 'key-1'),
|
||||
array('key\2', 'key-2'),
|
||||
array('key/3', 'key-3'),
|
||||
array('key<4', 'key-4'),
|
||||
array('key>5', 'key-5'),
|
||||
array('key"6', 'key-6'),
|
||||
array('key*7', 'key-7'),
|
||||
array('key?8', 'key-8'),
|
||||
array('key|9', 'key-9'),
|
||||
array('key[10]', 'key[10]'),
|
||||
array('keyä11', 'key--11'),
|
||||
array('../key12', '---key12'),
|
||||
array('key-13', 'key__13'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 = array(
|
||||
'key:0' => 'key-0',
|
||||
'key\0' => 'key-0',
|
||||
'key/0' => 'key-0',
|
||||
'key<0' => 'key-0',
|
||||
'key>0' => 'key-0',
|
||||
'key"0' => 'key-0',
|
||||
'key*0' => 'key-0',
|
||||
'key?0' => 'key-0',
|
||||
'key|0' => 'key-0',
|
||||
'key-0' => 'key__0',
|
||||
'keyä0' => 'key--0',
|
||||
);
|
||||
|
||||
$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 = array(
|
||||
'84', 'e0', 'e2', 'e8', '93', 'fe', 'bb', '73', '7a', '0f', 'ee',
|
||||
'0c', '89', 'd5', '3f', '4b', 'b7', 'fc', 'b4', '4c', '57', 'cd',
|
||||
'f3', 'd3', '2c', 'e7', '36', '3f', '5d', '59', '77', '60'
|
||||
);
|
||||
$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 . 'item__key', $path);
|
||||
}
|
||||
|
||||
public function testFileExtensionCorrectlyEscaped()
|
||||
{
|
||||
$driver1 = $this->getMock(
|
||||
'Doctrine\Common\Cache\FileCache',
|
||||
array('doFetch', 'doContains', 'doSave'),
|
||||
array(__DIR__, '.*')
|
||||
);
|
||||
$driver2 = $this->getMock(
|
||||
'Doctrine\Common\Cache\FileCache',
|
||||
array('doFetch', 'doContains', 'doSave'),
|
||||
array(__DIR__, '.php')
|
||||
);
|
||||
|
||||
$doGetStats = new \ReflectionMethod($driver1, 'doGetStats');
|
||||
|
||||
$doGetStats->setAccessible(true);
|
||||
|
||||
$stats1 = $doGetStats->invoke($driver1);
|
||||
$stats2 = $doGetStats->invoke($driver2);
|
||||
|
||||
$this->assertSame(0, $stats1[Cache::STATS_MEMORY_USAGE]);
|
||||
$this->assertGreaterThan(0, $stats2[Cache::STATS_MEMORY_USAGE]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DCOM-266
|
||||
*/
|
||||
public function testFileExtensionSlashCorrectlyEscaped()
|
||||
{
|
||||
$driver = $this->getMock(
|
||||
'Doctrine\Common\Cache\FileCache',
|
||||
array('doFetch', 'doContains', 'doSave'),
|
||||
array(__DIR__ . '/../', '/' . basename(__FILE__))
|
||||
);
|
||||
|
||||
$doGetStats = new \ReflectionMethod($driver, 'doGetStats');
|
||||
|
||||
$doGetStats->setAccessible(true);
|
||||
|
||||
$stats = $doGetStats->invoke($driver);
|
||||
|
||||
$this->assertGreaterThan(0, $stats[Cache::STATS_MEMORY_USAGE]);
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
<?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);
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
<?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;
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
<?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;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @dataProvider falseCastedValuesProvider
|
||||
*/
|
||||
public function testFalseCastedValues($value)
|
||||
{
|
||||
if (false === $value) {
|
||||
$this->markTestIncomplete('Memcached currently doesn\'t support saving `false` values. ');
|
||||
}
|
||||
|
||||
parent::testFalseCastedValues($value);
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
<?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);
|
||||
}
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
<?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]);
|
||||
}
|
||||
|
||||
public function testCachedObject()
|
||||
{
|
||||
$this->markTestSkipped("PhpFileCache cannot handle objects that don't implement __set_state.");
|
||||
}
|
||||
|
||||
public function testFetchMultipleObjects()
|
||||
{
|
||||
$this->markTestSkipped("PhpFileCache cannot handle objects that don't implement __set_state.");
|
||||
}
|
||||
|
||||
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']);
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Doctrine\Common\Cache\PredisCache;
|
||||
use Predis\Client;
|
||||
use Predis\Connection\ConnectionException;
|
||||
|
||||
class PredisCacheTest extends CacheTest
|
||||
{
|
||||
private $client;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
if (!class_exists('Predis\Client')) {
|
||||
$this->markTestSkipped('Predis\Client is missing. Make sure to "composer install" to have all dev dependencies.');
|
||||
}
|
||||
|
||||
$this->client = new Client();
|
||||
|
||||
try {
|
||||
$this->client->connect();
|
||||
} catch (ConnectionException $e) {
|
||||
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of redis');
|
||||
}
|
||||
}
|
||||
|
||||
public function testHitMissesStatsAreProvided()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
$stats = $cache->getStats();
|
||||
|
||||
$this->assertNotNull($stats[Cache::STATS_HITS]);
|
||||
$this->assertNotNull($stats[Cache::STATS_MISSES]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PredisCache
|
||||
*/
|
||||
protected function _getCacheDriver()
|
||||
{
|
||||
return new PredisCache($this->client);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @dataProvider falseCastedValuesProvider
|
||||
*/
|
||||
public function testFalseCastedValues($value)
|
||||
{
|
||||
if (array() === $value) {
|
||||
$this->markTestIncomplete(
|
||||
'Predis currently doesn\'t support saving empty array values. '
|
||||
. 'See https://github.com/nrk/predis/issues/241'
|
||||
);
|
||||
}
|
||||
|
||||
parent::testFalseCastedValues($value);
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\RedisCache;
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
public function testHitMissesStatsAreProvided()
|
||||
{
|
||||
$cache = $this->_getCacheDriver();
|
||||
$stats = $cache->getStats();
|
||||
|
||||
$this->assertNotNull($stats[Cache::STATS_HITS]);
|
||||
$this->assertNotNull($stats[Cache::STATS_MISSES]);
|
||||
}
|
||||
|
||||
protected function _getCacheDriver()
|
||||
{
|
||||
$driver = new RedisCache();
|
||||
$driver->setRedis($this->_redis);
|
||||
return $driver;
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
<?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);
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Doctrine\Common\Cache\SQLite3Cache;
|
||||
use SQLite3;
|
||||
|
||||
class SQLite3Test extends CacheTest
|
||||
{
|
||||
/**
|
||||
* @var SQLite3
|
||||
*/
|
||||
private $file, $sqlite;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->file = tempnam(null, 'doctrine-cache-test-');
|
||||
unlink($this->file);
|
||||
$this->sqlite = new SQLite3($this->file);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->sqlite = null; // DB must be closed before
|
||||
unlink($this->file);
|
||||
}
|
||||
|
||||
public function testGetStats()
|
||||
{
|
||||
$this->assertNull($this->_getCacheDriver()->getStats());
|
||||
}
|
||||
|
||||
public function testFetchSingle()
|
||||
{
|
||||
$id = uniqid('sqlite3_id_');
|
||||
$data = "\0"; // produces null bytes in serialized format
|
||||
|
||||
$this->_getCacheDriver()->save($id, $data, 30);
|
||||
|
||||
$this->assertEquals($data, $this->_getCacheDriver()->fetch($id));
|
||||
}
|
||||
|
||||
protected function _getCacheDriver()
|
||||
{
|
||||
return new SQLite3Cache($this->sqlite, 'test_table');
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Common\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\VoidCache;
|
||||
|
||||
/**
|
||||
* @covers \Doctrine\Common\Cache\VoidCache
|
||||
*/
|
||||
class VoidCacheTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testShouldAlwaysReturnFalseOnContains()
|
||||
{
|
||||
$cache = new VoidCache();
|
||||
|
||||
$this->assertFalse($cache->contains('foo'));
|
||||
$this->assertFalse($cache->contains('bar'));
|
||||
}
|
||||
|
||||
public function testShouldAlwaysReturnFalseOnFetch()
|
||||
{
|
||||
$cache = new VoidCache();
|
||||
|
||||
$this->assertFalse($cache->fetch('foo'));
|
||||
$this->assertFalse($cache->fetch('bar'));
|
||||
}
|
||||
|
||||
public function testShouldAlwaysReturnTrueOnSaveButNotStoreAnything()
|
||||
{
|
||||
$cache = new VoidCache();
|
||||
|
||||
$this->assertTrue($cache->save('foo', 'fooVal'));
|
||||
|
||||
$this->assertFalse($cache->contains('foo'));
|
||||
$this->assertFalse($cache->fetch('foo'));
|
||||
}
|
||||
|
||||
public function testShouldAlwaysReturnTrueOnDelete()
|
||||
{
|
||||
$cache = new VoidCache();
|
||||
|
||||
$this->assertTrue($cache->delete('foo'));
|
||||
}
|
||||
|
||||
public function testShouldAlwaysReturnNullOnGetStatus()
|
||||
{
|
||||
$cache = new VoidCache();
|
||||
|
||||
$this->assertNull($cache->getStats());
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?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();
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?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();
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
<?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();
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Tests;
|
||||
|
||||
/**
|
||||
* Base testcase class for all Doctrine testcases.
|
||||
*/
|
||||
abstract class DoctrineTestCase extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
<?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);
|
7
vendor/doctrine/cache/tests/travis/php.ini
vendored
7
vendor/doctrine/cache/tests/travis/php.ini
vendored
|
@ -1,7 +0,0 @@
|
|||
extension="mongo.so"
|
||||
extension="memcache.so"
|
||||
extension="memcached.so"
|
||||
extension="redis.so"
|
||||
|
||||
apc.enabled=1
|
||||
apc.enable_cli=1
|
|
@ -1,35 +0,0 @@
|
|||
<?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>
|
Reference in a new issue