1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65:
<?php
namespace Guzzle\Tests\Cache;
use Guzzle\Cache\CacheAdapterFactory;
use Guzzle\Cache\DoctrineCacheAdapter;
use Doctrine\Common\Cache\ArrayCache;
use Zend\Cache\StorageFactory;
class CacheAdapterFactoryTest extends \Guzzle\Tests\GuzzleTestCase
{
private $cache;
private $adapter;
protected function setup()
{
parent::setUp();
$this->cache = new ArrayCache();
$this->adapter = new DoctrineCacheAdapter($this->cache);
}
public function testEnsuresConfigIsObject()
{
CacheAdapterFactory::fromCache(array());
}
public function testEnsuresKnownType()
{
CacheAdapterFactory::fromCache(new \stdClass());
}
public function cacheProvider()
{
return array(
array(new DoctrineCacheAdapter(new ArrayCache()), 'Guzzle\Cache\DoctrineCacheAdapter'),
array(new ArrayCache(), 'Guzzle\Cache\DoctrineCacheAdapter'),
array(StorageFactory::factory(array('adapter' => 'memory')), 'Guzzle\Cache\Zf2CacheAdapter'),
);
}
public function testCreatesNullCacheAdapterByDefault($cache, $type)
{
$adapter = CacheAdapterFactory::fromCache($cache);
$this->assertInstanceOf($type, $adapter);
}
}