Skip to content

Commit

Permalink
Merge pull request #10 from elliotchance/adapter-bug
Browse files Browse the repository at this point in the history
Added custom adapters
  • Loading branch information
elliotchance committed Apr 29, 2014
2 parents 247d839 + b7a8fd1 commit 232ce01
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Hoard/CacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public static function getPool($poolName, array $config = array())

// create adapter
$adapterClass = '\Hoard\Adapter\Memcached';
if(array_key_exists('adapter', $config)) {
$adapterClass = $config['adapter'];
}
$adapter = new $adapterClass($config);

// create pool
Expand Down
19 changes: 19 additions & 0 deletions test/Hoard/CacheManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,28 @@ public function log($level, $message, array $context = array())

}

class DummyAdapter extends \Hoard\Adapter\Memcached
{
}

class CacheManagerTest extends \PHPUnit_Framework_TestCase
{

public function testWillUseMemcacheAdapterIfNotProvided()
{
$pool = CacheManager::getPool('test.simple');
$this->assertInstanceOf('\Hoard\Adapter\Memcached', $pool->getAdapter());
}

public function testWillUseAdapterIfProvided()
{
$config = array(
'adapter' => '\Hoard\DummyAdapter'
);
$pool = CacheManager::getPool('test.simple', $config);
$this->assertInstanceOf('\Hoard\DummyAdapter', $pool->getAdapter());
}

public function testWillSetAdapterOptionsWhenCreatingThePool()
{
$pool = CacheManager::getPool('test.simple');
Expand Down

0 comments on commit 232ce01

Please sign in to comment.