Skip to content

Commit af0f6b3

Browse files
authored
Added tests for namespace and prefixed cache pools (#58)
* Added tests for namespace and prefixd cache pools * Update medal
1 parent 7a23f83 commit af0f6b3

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
[![codecov.io](https://codecov.io/github/php-cache/adapter-bundle/coverage.svg?branch=master)](https://codecov.io/github/php-cache/adapter-bundle?branch=master)[![Build Status](https://travis-ci.org/php-cache/adapter-bundle.svg?branch=master)](https://travis-ci.org/php-cache/adapter-bundle)
44
[![Total Downloads](https://poser.pugx.org/cache/adapter-bundle/downloads)](https://packagist.org/packages/cache/adapter-bundle)
55
[![Monthly Downloads](https://poser.pugx.org/cache/adapter-bundle/d/monthly.png)](https://packagist.org/packages/cache/adapter-bundle)
6-
[![Quality Score](https://img.shields.io/scrutinizer/g/cache/adapter-bundle.svg?style=flat-square)](https://scrutinizer-ci.com/g/cache/adapter-bundle)
7-
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/21963379-2b15-4cc4-bdf6-0f98aa292f8a/mini.png)](https://insight.sensiolabs.com/projects/21963379-2b15-4cc4-bdf6-0f98aa292f8a)
6+
[![Quality Score](https://img.shields.io/scrutinizer/g/php-cache/adapter-bundle.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-cache/adapter-bundle)
7+
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/21963379-2b15-4cc4-bdf6-0f98aa292f8a/mini.png)](https://insight.sensiolabs.com/projects/21963379-2b15-4cc4-bdf6-0f98aa292f8a)
88
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
99

1010

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"cache/predis-adapter": "@stable",
4141
"cache/redis-adapter": "@stable",
4242
"cache/void-adapter": "@stable",
43+
"cache/prefixed-cache": "@stable",
4344
"doctrine/cache": "^1.6",
4445
"predis/predis": "^1.1"
4546
},

src/DependencyInjection/CacheAdapterExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private function findReferences(array $options)
7575
foreach ($options as $key => $value) {
7676
if (is_array($value)) {
7777
$options[$key] = $this->findReferences($value);
78-
} elseif (substr($key, -8) === '_service' || strpos($value, '@') === 0) {
78+
} elseif (substr($key, -8) === '_service' || strpos($value, '@') === 0 || $key === 'service') {
7979
$options[$key] = new Reference(ltrim($value, '@'));
8080
}
8181
}

tests/Functional/BundleInitializationTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
use Cache\Adapter\Redis\RedisCachePool;
2323
use Cache\Adapter\Void\VoidCachePool;
2424
use Cache\AdapterBundle\CacheAdapterBundle;
25+
use Cache\Namespaced\NamespacedCachePool;
26+
use Cache\Prefixed\PrefixedCachePool;
2527
use Nyholm\BundleTest\BaseBundleTestCase;
2628

2729
class BundleInitializationTest extends BaseBundleTestCase
@@ -52,6 +54,9 @@ public function testFactoriesWithWithDefaultConfiguration()
5254

5355
$this->assertInstanceOf(DoctrineCachePool::class, $container->get('cache.provider.doctrine_filesystem'));
5456
$this->assertInstanceOf(DoctrineCachePool::class, $container->get('cache.provider.doctrine_predis'));
57+
58+
$this->assertInstanceOf(NamespacedCachePool::class, $container->get('cache.provider.namespaced'));
59+
$this->assertInstanceOf(PrefixedCachePool::class, $container->get('cache.provider.prefixed'));
5560
}
5661

5762
public function testMemcachedWithWithDefaultConfiguration()

tests/Functional/config.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,14 @@ cache_adapter:
3838
factory: 'cache.factory.doctrine_predis'
3939
doctrine_redis:
4040
factory: 'cache.factory.doctrine_redis'
41+
42+
namespaced:
43+
factory: 'cache.factory.namespaced'
44+
options:
45+
service: 'cache.provider.void'
46+
namespace: 'foobar'
47+
prefixed:
48+
factory: 'cache.factory.prefixed'
49+
options:
50+
service: 'cache.provider.void'
51+
prefix: 'foobar'

0 commit comments

Comments
 (0)