Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #98 from marc-mabe/fix97
Browse files Browse the repository at this point in the history
fixed #97 by adding underline names to plugin manager
  • Loading branch information
weierophinney committed May 12, 2016
2 parents 2461937 + fd0d002 commit 8f27bf6
Show file tree
Hide file tree
Showing 30 changed files with 367 additions and 53 deletions.
87 changes: 49 additions & 38 deletions src/Storage/AdapterPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,55 @@
class AdapterPluginManager extends AbstractPluginManager
{
protected $aliases = [
'apc' => Adapter\Apc::class,
'Apc' => Adapter\Apc::class,
'apcu' => Adapter\Apcu::class,
'ApcU' => Adapter\Apcu::class,
'Apcu' => Adapter\Apcu::class,
'APCu' => Adapter\Apcu::class,
'blackhole' => Adapter\BlackHole::class,
'blackHole' => Adapter\BlackHole::class,
'BlackHole' => Adapter\BlackHole::class,
'dba' => Adapter\Dba::class,
'Dba' => Adapter\Dba::class,
'filesystem' => Adapter\Filesystem::class,
'Filesystem' => Adapter\Filesystem::class,
'memcache' => Adapter\Memcache::class,
'Memcache' => Adapter\Memcache::class,
'memcached' => Adapter\Memcached::class,
'Memcached' => Adapter\Memcached::class,
'memory' => Adapter\Memory::class,
'Memory' => Adapter\Memory::class,
'mongodb' => Adapter\MongoDb::class,
'mongoDb' => Adapter\MongoDb::class,
'MongoDb' => Adapter\MongoDb::class,
'redis' => Adapter\Redis::class,
'Redis' => Adapter\Redis::class,
'session' => Adapter\Session::class,
'Session' => Adapter\Session::class,
'xcache' => Adapter\XCache::class,
'xCache' => Adapter\XCache::class,
'XCache' => Adapter\XCache::class,
'wincache' => Adapter\WinCache::class,
'winCache' => Adapter\WinCache::class,
'WinCache' => Adapter\WinCache::class,
'zendserverdisk' => Adapter\ZendServerDisk::class,
'zendServerDisk' => Adapter\ZendServerDisk::class,
'ZendServerDisk' => Adapter\ZendServerDisk::class,
'zendservershm' => Adapter\ZendServerShm::class,
'zendServerShm' => Adapter\ZendServerShm::class,
'ZendServerShm' => Adapter\ZendServerShm::class,
'apc' => Adapter\Apc::class,
'Apc' => Adapter\Apc::class,
'APC' => Adapter\Apc::class,
'apcu' => Adapter\Apcu::class,
'ApcU' => Adapter\Apcu::class,
'Apcu' => Adapter\Apcu::class,
'APCu' => Adapter\Apcu::class,
'black_hole' => Adapter\BlackHole::class,
'blackhole' => Adapter\BlackHole::class,
'blackHole' => Adapter\BlackHole::class,
'BlackHole' => Adapter\BlackHole::class,
'dba' => Adapter\Dba::class,
'Dba' => Adapter\Dba::class,
'DBA' => Adapter\Dba::class,
'filesystem' => Adapter\Filesystem::class,
'Filesystem' => Adapter\Filesystem::class,
'memcache' => Adapter\Memcache::class,
'Memcache' => Adapter\Memcache::class,
'memcached' => Adapter\Memcached::class,
'Memcached' => Adapter\Memcached::class,
'memory' => Adapter\Memory::class,
'Memory' => Adapter\Memory::class,
'mongo_db' => Adapter\MongoDb::class,
'mongodb' => Adapter\MongoDb::class,
'MongoDb' => Adapter\MongoDb::class,
'MongoDB' => Adapter\MongoDb::class,
'mongoDb' => Adapter\MongoDb::class,
'mongoDB' => Adapter\MongoDb::class,
'redis' => Adapter\Redis::class,
'Redis' => Adapter\Redis::class,
'session' => Adapter\Session::class,
'Session' => Adapter\Session::class,
'xcache' => Adapter\XCache::class,
'xCache' => Adapter\XCache::class,
'XCache' => Adapter\XCache::class,
'win_cache' => Adapter\WinCache::class,
'wincache' => Adapter\WinCache::class,
'winCache' => Adapter\WinCache::class,
'WinCache' => Adapter\WinCache::class,
'zend_server_disk' => Adapter\ZendServerDisk::class,
'zendserverdisk' => Adapter\ZendServerDisk::class,
'zendServerDisk' => Adapter\ZendServerDisk::class,
'ZendServerDisk' => Adapter\ZendServerDisk::class,
'zend_server_shm' => Adapter\ZendServerShm::class,
'zendservershm' => Adapter\ZendServerShm::class,
'zendServerShm' => Adapter\ZendServerShm::class,
'zendServerSHM' => Adapter\ZendServerShm::class,
'ZendServerShm' => Adapter\ZendServerShm::class,
'ZendServerSHM' => Adapter\ZendServerShm::class,
];

protected $factories = [
Expand Down
32 changes: 18 additions & 14 deletions src/Storage/PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,24 @@
class PluginManager extends AbstractPluginManager
{
protected $aliases = [
'clearexpiredbyfactor' => Plugin\ClearExpiredByFactor::class,
'clearExpiredByFactor' => Plugin\ClearExpiredByFactor::class,
'ClearExpiredByFactor' => Plugin\ClearExpiredByFactor::class,
'exceptionhandler' => Plugin\ExceptionHandler::class,
'exceptionHandler' => Plugin\ExceptionHandler::class,
'ExceptionHandler' => Plugin\ExceptionHandler::class,
'ignoreuserabort' => Plugin\IgnoreUserAbort::class,
'ignoreUserAbort' => Plugin\IgnoreUserAbort::class,
'IgnoreUserAbort' => Plugin\IgnoreUserAbort::class,
'optimizebyfactor' => Plugin\OptimizeByFactor::class,
'optimizeByFactor' => Plugin\OptimizeByFactor::class,
'OptimizeByFactor' => Plugin\OptimizeByFactor::class,
'serializer' => Plugin\Serializer::class,
'Serializer' => Plugin\Serializer::class
'clear_expired_by_factor' => Plugin\ClearExpiredByFactor::class,
'clearexpiredbyfactor' => Plugin\ClearExpiredByFactor::class,
'clearExpiredByFactor' => Plugin\ClearExpiredByFactor::class,
'ClearExpiredByFactor' => Plugin\ClearExpiredByFactor::class,
'exception_handler' => Plugin\ExceptionHandler::class,
'exceptionhandler' => Plugin\ExceptionHandler::class,
'exceptionHandler' => Plugin\ExceptionHandler::class,
'ExceptionHandler' => Plugin\ExceptionHandler::class,
'ignore_user_abort' => Plugin\IgnoreUserAbort::class,
'ignoreuserabort' => Plugin\IgnoreUserAbort::class,
'ignoreUserAbort' => Plugin\IgnoreUserAbort::class,
'IgnoreUserAbort' => Plugin\IgnoreUserAbort::class,
'optimize_by_factor' => Plugin\OptimizeByFactor::class,
'optimizebyfactor' => Plugin\OptimizeByFactor::class,
'optimizeByFactor' => Plugin\OptimizeByFactor::class,
'OptimizeByFactor' => Plugin\OptimizeByFactor::class,
'serializer' => Plugin\Serializer::class,
'Serializer' => Plugin\Serializer::class
];

protected $factories = [
Expand Down
8 changes: 8 additions & 0 deletions test/Pattern/CallbackCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ public function tearDown()
parent::tearDown();
}

public function getCommonPatternNamesProvider()
{
return [
['callback'],
['Callback'],
];
}

public function testCallEnabledCacheOutputByDefault()
{
$this->_testCall(
Expand Down
8 changes: 8 additions & 0 deletions test/Pattern/CaptureCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ protected function _removeRecursive($dir)
}
}

public function getCommonPatternNamesProvider()
{
return [
['capture'],
['Capture'],
];
}

public function testSetThrowsLogicExceptionOnMissingPublicDir()
{
$captureCache = new Cache\Pattern\CaptureCache();
Expand Down
8 changes: 8 additions & 0 deletions test/Pattern/ClassCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ public function tearDown()
parent::tearDown();
}

public function getCommonPatternNamesProvider()
{
return [
['class'],
['Class'],
];
}

public function testCallEnabledCacheOutputByDefault()
{
$this->_testCall(
Expand Down
20 changes: 20 additions & 0 deletions test/Pattern/CommonPatternTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace ZendTest\Cache\Pattern;

use Zend\ServiceManager\ServiceManager;
use Zend\Cache\PatternPluginManager;

/**
* @group Zend_Cache
* @covers Zend\Cache\Pattern\PatternOptions<extended>
Expand All @@ -34,6 +37,23 @@ public function tearDown()
unset($this->_pattern);
}

/**
* A data provider for common pattern names
*/
abstract public function getCommonPatternNamesProvider();

/**
* @dataProvider getCommonPatternNamesProvider
*/
public function testPatternPluginManagerWithCommonNames($commonPatternName)
{
$pluginManager = new PatternPluginManager(new ServiceManager);
$this->assertTrue(
$pluginManager->has($commonPatternName),
"Pattern name '{$commonPatternName}' not found in PatternPluginManager"
);
}

public function testOptionNamesValid()
{
$options = $this->_pattern->getOptions();
Expand Down
8 changes: 8 additions & 0 deletions test/Pattern/ObjectCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ public function tearDown()
parent::tearDown();
}

public function getCommonPatternNamesProvider()
{
return [
['object'],
['Object'],
];
}

public function testCallEnabledCacheOutputByDefault()
{
$this->_testCall(
Expand Down
8 changes: 8 additions & 0 deletions test/Pattern/OutputCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ public function tearDown()
parent::tearDown();
}

public function getCommonPatternNamesProvider()
{
return [
['output'],
['Output'],
];
}

public function testStartEndCacheMiss()
{
$output = 'foobar';
Expand Down
9 changes: 9 additions & 0 deletions test/Storage/Adapter/AbstractDbaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,13 @@ public function tearDown()

parent::tearDown();
}

public function getCommonAdapterNamesProvider()
{
return [
['dba'],
['Dba'],
['DBA'],
];
}
}
8 changes: 8 additions & 0 deletions test/Storage/Adapter/ApcTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,12 @@ public function tearDown()

parent::tearDown();
}

public function getCommonAdapterNamesProvider()
{
return [
['apc'],
['Apc'],
];
}
}
10 changes: 10 additions & 0 deletions test/Storage/Adapter/ApcuTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,14 @@ public function tearDown()

parent::tearDown();
}

public function getCommonAdapterNamesProvider()
{
return [
['apcu'],
['Apcu'],
['ApcU'],
['APCu'],
];
}
}
27 changes: 27 additions & 0 deletions test/Storage/Adapter/BlackHoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

namespace ZendTest\Cache\Storage\Adapter;

use Zend\Cache\Storage\AdapterPluginManager;
use Zend\Cache\Storage\Adapter\BlackHole;
use Zend\Cache\StorageFactory;
use Zend\ServiceManager\ServiceManager;

/**
* PHPUnit test case
Expand All @@ -38,6 +40,31 @@ public function setUp()
$this->storage = StorageFactory::adapterFactory('BlackHole');
}

/**
* A data provider for common storage adapter names
*/
public function getCommonAdapterNamesProvider()
{
return [
['black_hole'],
['blackhole'],
['blackHole'],
['BlackHole'],
];
}

/**
* @dataProvider getCommonAdapterNamesProvider
*/
public function testAdapterPluginManagerWithCommonNames($commonAdapterName)
{
$pluginManager = new AdapterPluginManager(new ServiceManager);
$this->assertTrue(
$pluginManager->has($commonAdapterName),
"Storage adapter name '{$commonAdapterName}' not found in storage adapter plugin manager"
);
}

public function testGetOptions()
{
$options = $this->storage->getOptions();
Expand Down
19 changes: 19 additions & 0 deletions test/Storage/Adapter/CommonAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace ZendTest\Cache\Storage\Adapter;

use Zend\Cache\Storage\AdapterPluginManager;
use Zend\Cache\Storage\AvailableSpaceCapableInterface;
use Zend\Cache\Storage\IterableInterface;
use Zend\Cache\Storage\IteratorInterface;
Expand All @@ -20,6 +21,7 @@
use Zend\Cache\Storage\OptimizableInterface;
use Zend\Cache\Storage\TaggableInterface;
use Zend\Cache\Storage\TotalSpaceCapableInterface;
use Zend\ServiceManager\ServiceManager;
use Zend\Stdlib\ErrorHandler;

/**
Expand Down Expand Up @@ -76,6 +78,23 @@ public function tearDown()
}
}

/**
* A data provider for common storage adapter names
*/
abstract public function getCommonAdapterNamesProvider();

/**
* @dataProvider getCommonAdapterNamesProvider
*/
public function testAdapterPluginManagerWithCommonNames($commonAdapterName)
{
$pluginManager = new AdapterPluginManager(new ServiceManager);
$this->assertTrue(
$pluginManager->has($commonAdapterName),
"Storage adapter name '{$commonAdapterName}' not found in storage adapter plugin manager"
);
}

public function testOptionNamesValid()
{
$options = $this->_storage->getOptions()->toArray();
Expand Down
8 changes: 8 additions & 0 deletions test/Storage/Adapter/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ protected function _removeRecursive($dir)
}
}

public function getCommonAdapterNamesProvider()
{
return [
['filesystem'],
['Filesystem'],
];
}

public function testNormalizeCacheDir()
{
$cacheDir = $cacheDirExpected = realpath(sys_get_temp_dir());
Expand Down
8 changes: 8 additions & 0 deletions test/Storage/Adapter/MemcacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ public function setUp()
parent::setUp();
}

public function getCommonAdapterNamesProvider()
{
return [
['memcache'],
['Memcache'],
];
}

/**
* Data provider to test valid server info
*
Expand Down
Loading

0 comments on commit 8f27bf6

Please sign in to comment.