-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from kschroeder/develop
Testing the cache factory with the Redis and Filesystsem adapters
- Loading branch information
Showing
2 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace Magium\Configuration\Tests\Manager; | ||
|
||
use Magium\Configuration\Manager\CacheFactory; | ||
use PHPUnit\Framework\TestCase; | ||
use Zend\Cache\Storage\Adapter\Filesystem; | ||
use Zend\Cache\Storage\Adapter\Redis; | ||
|
||
class CacheFactoryTest extends TestCase | ||
{ | ||
|
||
public function testBasicCacheConfiguration() | ||
{ | ||
$simpleXml = simplexml_load_string( | ||
<<<XML | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<magium xmlns="http://www.magiumlib.com/BaseConfiguration"> | ||
<persistenceConfiguration> | ||
<driver></driver> | ||
<database></database> | ||
</persistenceConfiguration> | ||
<contextConfigurationFile file="asd" type="xml"/> | ||
<cache> | ||
<adapter>filesystem</adapter> | ||
</cache> | ||
</magium> | ||
XML | ||
); | ||
|
||
$cacheFactory = new CacheFactory(); | ||
$cache = $cacheFactory->getCache($simpleXml->cache); | ||
self::assertInstanceOf(Filesystem::class, $cache); | ||
} | ||
public function testCacheConfigurationWithRecursiveOptions() | ||
{ | ||
$redis = extension_loaded('redis'); | ||
if (!$redis) { | ||
self::markTestSkipped('Redis extension is not loaded'); | ||
} | ||
$simpleXml = simplexml_load_string( | ||
<<<XML | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<magium xmlns="http://www.magiumlib.com/BaseConfiguration"> | ||
<persistenceConfiguration> | ||
<driver></driver> | ||
<database></database> | ||
</persistenceConfiguration> | ||
<contextConfigurationFile file="asd" type="xml"/> | ||
<cache> | ||
<adapter>redis</adapter> | ||
<options> | ||
<server>localhost:6379</server> | ||
</options> | ||
</cache> | ||
</magium> | ||
XML | ||
); | ||
|
||
$cacheFactory = new CacheFactory(); | ||
$methods = get_class_methods(new Redis()); | ||
$cache = $cacheFactory->getCache($simpleXml->cache); | ||
self::assertInstanceOf(Redis::class, $cache); | ||
} | ||
|
||
} |