Skip to content

Commit 0f341bf

Browse files
authored
Updated tests and collector (#70)
* Updated tests * Updated FixedTaggingCachePool * Using new collector * Fixes * Updating to nicer profiler page * Minor * cs * Make sure we support sf < 3.3 * minor * Bugfix and more tests * Namespace update * Remove support for PHP 5.5 * Minor * Added change log * Do not require old phpunit versions
1 parent fd54c07 commit 0f341bf

20 files changed

+448
-416
lines changed

.travis.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ php:
55
- 7.1
66
- 7.0
77
- 5.6
8-
- 5.5
98
- hhvm
109

1110
env:
@@ -16,6 +15,7 @@ env:
1615
matrix:
1716
- SYMFONY_VERSION=2.7.*
1817
- SYMFONY_VERSION=2.8.*
18+
- SYMFONY_VERSION=3.1.*
1919
- SYMFONY_VERSION=3.2.*
2020

2121
branches:
@@ -26,7 +26,7 @@ branches:
2626
matrix:
2727
fast_finish: true
2828
include:
29-
- php: 5.5
29+
- php: 5.6
3030
env: COMPOSER_COMMAND="composer update --prefer-lowest --prefer-stable" COVERAGE=true TEST_COMMAND="php -dzend_extension=xdebug.so vendor/bin/phpunit --coverage-clover=coverage.xml" SYMFONY_VERSION=2.7.*
3131

3232
cache:
@@ -36,7 +36,6 @@ cache:
3636
before_install:
3737
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' ]]; then phpenv config-rm xdebug.ini; fi;
3838
- pip install --user codecov
39-
- composer self-update
4039
- composer require symfony/symfony:${SYMFONY_VERSION} --no-update
4140

4241
install:

Changelog.md

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
44

55
## UNRELEASED
66

7+
## 0.5.0
8+
9+
### Changed
10+
11+
- Using cache/session-handler: ^0.2. **This will break all cached sessions**
12+
- Using cache/taggable-cache: ^0.5 to support the latest versions of the adapters.
13+
14+
## 0.4.4
15+
16+
### Fixed
17+
18+
- Make sure RecordingPool does not change the type of pool.
19+
720
## 0.4.3
821

922
### Fixed

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
}
2525
],
2626
"require": {
27-
"php": "^5.5 || ^7.0",
27+
"php": "^5.6 || ^7.0",
2828
"symfony/framework-bundle": "^2.7 || ^3.0",
2929
"cache/taggable-cache": "^0.5",
3030
"cache/session-handler": "^0.2"
3131
},
3232
"require-dev": {
33-
"phpunit/phpunit": "^5.1 || ^4.0",
33+
"phpunit/phpunit": "^5.7.17",
3434
"symfony/symfony": "^2.7 || ^3.0",
35-
"cache/psr-6-doctrine-bridge": "^2.0",
35+
"cache/psr-6-doctrine-bridge": "^3.0",
3636
"cache/array-adapter": "^0.5",
3737
"nyholm/symfony-bundle-test": "^1.0.1",
3838
"matthiasnoback/symfony-dependency-injection-test": "^1.0"

src/Cache/FixedTaggingCachePool.php

+31-20
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,20 @@
1111

1212
namespace Cache\CacheBundle\Cache;
1313

14-
use Cache\Taggable\TaggableItemInterface;
15-
use Cache\Taggable\TaggablePoolInterface;
14+
use Cache\TagInterop\TaggableCacheItemInterface;
15+
use Cache\TagInterop\TaggableCacheItemPoolInterface;
1616
use Psr\Cache\CacheItemInterface;
17-
use Psr\Cache\CacheItemPoolInterface;
17+
use Psr\Cache\InvalidArgumentException;
1818

1919
/**
20-
* This class is a decorator for a TaggablePoolInterface. It tags everything with predefined tags.
21-
* Use this class with the DoctrineBridge.
20+
* This class is a decorator for a TaggableCacheItemPoolInterface. It tags everything with predefined tags.
2221
*
2322
* @author Tobias Nyholm <[email protected]>
2423
*/
25-
class FixedTaggingCachePool implements CacheItemPoolInterface
24+
class FixedTaggingCachePool implements TaggableCacheItemPoolInterface
2625
{
2726
/**
28-
* @type CacheItemPoolInterface|TaggablePoolInterface
27+
* @type TaggableCacheItemPoolInterface
2928
*/
3029
private $cache;
3130

@@ -35,10 +34,10 @@ class FixedTaggingCachePool implements CacheItemPoolInterface
3534
private $tags;
3635

3736
/**
38-
* @param TaggablePoolInterface $cache
39-
* @param array $tags
37+
* @param TaggableCacheItemPoolInterface $cache
38+
* @param array $tags
4039
*/
41-
public function __construct(TaggablePoolInterface $cache, array $tags)
40+
public function __construct(TaggableCacheItemPoolInterface $cache, array $tags)
4241
{
4342
$this->cache = $cache;
4443
$this->tags = $tags;
@@ -97,10 +96,12 @@ public function deleteItems(array $keys)
9796
*/
9897
public function save(CacheItemInterface $item)
9998
{
100-
if ($item instanceof TaggableItemInterface) {
101-
$this->addTags($item);
99+
if (!$item instanceof TaggableCacheItemInterface) {
100+
throw new InvalidArgumentException('Cache items are not transferable between pools. Item MUST implement TaggableCacheItemInterface.');
102101
}
103102

103+
$item->setTags($this->tags);
104+
104105
return $this->cache->save($item);
105106
}
106107

@@ -109,26 +110,36 @@ public function save(CacheItemInterface $item)
109110
*/
110111
public function saveDeferred(CacheItemInterface $item)
111112
{
112-
$this->addTags($item);
113+
if (!$item instanceof TaggableCacheItemInterface) {
114+
throw new InvalidArgumentException('Cache items are not transferable between pools. Item MUST implement TaggableCacheItemInterface.');
115+
}
116+
117+
$item->setTags($this->tags);
113118

114119
return $this->cache->saveDeferred($item);
115120
}
116121

117122
/**
118-
* @param TaggableItemInterface $item
123+
* {@inheritdoc}
119124
*/
120-
private function addTags(TaggableItemInterface $item)
125+
public function commit()
121126
{
122-
foreach ($this->tags as $tag) {
123-
$item->addTag($tag);
124-
}
127+
return $this->cache->commit();
125128
}
126129

127130
/**
128131
* {@inheritdoc}
129132
*/
130-
public function commit()
133+
public function invalidateTag($tag)
131134
{
132-
return $this->cache->commit();
135+
return $this->invalidateTag($tag);
136+
}
137+
138+
/**
139+
* {@inheritdoc}
140+
*/
141+
public function invalidateTags(array $tags)
142+
{
143+
return $this->cache - $this->invalidateTags($tags);
133144
}
134145
}

0 commit comments

Comments
 (0)