Skip to content

Commit c3385d2

Browse files
authored
Support psr/cache 2 and 3 (#4117)
1 parent b65938c commit c3385d2

File tree

7 files changed

+13
-19
lines changed

7 files changed

+13
-19
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"php": ">=7.1",
1717
"doctrine/inflector": "^1.0 || ^2.0",
1818
"fig/link-util": "^1.0",
19-
"psr/cache": "^1.0",
19+
"psr/cache": "^1.0 || ^2.0 || ^3.0",
2020
"psr/container": "^1.0",
2121
"symfony/http-foundation": "^4.4 || ^5.1",
2222
"symfony/http-kernel": "^4.4 || ^5.1",

tests/Bridge/Symfony/Routing/CachedRouteNameResolverTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,10 @@ public function testGetRouteNameForCollectionRouteOnCacheHit()
162162

163163
public function testGetRouteNameWithCacheItemThrowsCacheException()
164164
{
165-
$cacheException = $this->prophesize(\Exception::class);
166-
$cacheException->willImplement(CacheException::class);
165+
$cacheException = new class() extends \Exception implements CacheException {};
167166

168167
$cacheItemPool = $this->prophesize(CacheItemPoolInterface::class);
169-
$cacheItemPool->getItem(Argument::type('string'))->shouldBeCalledTimes(1)->willThrow($cacheException->reveal());
168+
$cacheItemPool->getItem(Argument::type('string'))->shouldBeCalledTimes(1)->willThrow($cacheException);
170169

171170
$decoratedProphecy = $this->prophesize(RouteNameResolverInterface::class);
172171
$decoratedProphecy->getRouteName('AppBundle\Entity\User', OperationType::ITEM, [])->willReturn('some_item_route')->shouldBeCalledTimes(1);

tests/Metadata/Property/Factory/CachedPropertyMetadataFactoryTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,10 @@ public function testCreateWithGetCacheItemThrowsCacheException()
7777
$decoratedPropertyMetadataFactory = $this->prophesize(PropertyMetadataFactoryInterface::class);
7878
$decoratedPropertyMetadataFactory->create(Dummy::class, 'dummy', [])->willReturn(new PropertyMetadata(null, 'A dummy', true, true, null, null, false, false))->shouldBeCalled();
7979

80-
$cacheException = $this->prophesize(\Exception::class);
81-
$cacheException->willImplement(CacheException::class);
80+
$cacheException = new class() extends \Exception implements CacheException {};
8281

8382
$cacheItemPool = $this->prophesize(CacheItemPoolInterface::class);
84-
$cacheItemPool->getItem($this->generateCacheKey())->willThrow($cacheException->reveal())->shouldBeCalled();
83+
$cacheItemPool->getItem($this->generateCacheKey())->willThrow($cacheException)->shouldBeCalled();
8584

8685
$cachedPropertyMetadataFactory = new CachedPropertyMetadataFactory($cacheItemPool->reveal(), $decoratedPropertyMetadataFactory->reveal());
8786
$resultedPropertyMetadata = $cachedPropertyMetadataFactory->create(Dummy::class, 'dummy');

tests/Metadata/Property/Factory/CachedPropertyNameCollectionFactoryTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,10 @@ public function testCreateWithGetCacheItemThrowsCacheException()
7777
$decoratedPropertyNameCollectionFactory = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
7878
$decoratedPropertyNameCollectionFactory->create(Dummy::class, [])->willReturn(new PropertyNameCollection(['id', 'name', 'description', 'dummy']))->shouldBeCalled();
7979

80-
$cacheException = $this->prophesize(\Exception::class);
81-
$cacheException->willImplement(CacheException::class);
80+
$cacheException = new class() extends \Exception implements CacheException {};
8281

8382
$cacheItemPool = $this->prophesize(CacheItemPoolInterface::class);
84-
$cacheItemPool->getItem($this->generateCacheKey())->willThrow($cacheException->reveal())->shouldBeCalled();
83+
$cacheItemPool->getItem($this->generateCacheKey())->willThrow($cacheException)->shouldBeCalled();
8584

8685
$cachedPropertyNameCollectionFactory = new CachedPropertyNameCollectionFactory($cacheItemPool->reveal(), $decoratedPropertyNameCollectionFactory->reveal());
8786
$resultedPropertyNameCollection = $cachedPropertyNameCollectionFactory->create(Dummy::class);

tests/Metadata/Resource/Factory/CachedResourceMetadataFactoryTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,10 @@ public function testCreateWithGetCacheItemThrowsCacheException()
7575
$decoratedResourceMetadataFactory = $this->prophesize(ResourceMetadataFactoryInterface::class);
7676
$decoratedResourceMetadataFactory->create(Dummy::class)->willReturn(new ResourceMetadata(null, 'Dummy.'))->shouldBeCalled();
7777

78-
$cacheException = $this->prophesize(\Exception::class);
79-
$cacheException->willImplement(CacheException::class);
78+
$cacheException = new class() extends \Exception implements CacheException {};
8079

8180
$cacheItemPool = $this->prophesize(CacheItemPoolInterface::class);
82-
$cacheItemPool->getItem($this->generateCacheKey())->willThrow($cacheException->reveal())->shouldBeCalled();
81+
$cacheItemPool->getItem($this->generateCacheKey())->willThrow($cacheException)->shouldBeCalled();
8382

8483
$cachedResourceMetadataFactory = new CachedResourceMetadataFactory($cacheItemPool->reveal(), $decoratedResourceMetadataFactory->reveal());
8584
$resultedResourceMetadata = $cachedResourceMetadataFactory->create(Dummy::class);

tests/Metadata/Resource/Factory/CachedResourceNameCollectionFactoryTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,10 @@ public function testCreateWithGetCacheItemThrowsCacheException()
7777
$decoratedResourceNameCollectionFactory = $this->prophesize(ResourceNameCollectionFactoryInterface::class);
7878
$decoratedResourceNameCollectionFactory->create()->willReturn(new ResourceNameCollection([Dummy::class]))->shouldBeCalled();
7979

80-
$cacheException = $this->prophesize(\Exception::class);
81-
$cacheException->willImplement(CacheException::class);
80+
$cacheException = new class() extends \Exception implements CacheException {};
8281

8382
$cacheItemPool = $this->prophesize(CacheItemPoolInterface::class);
84-
$cacheItemPool->getItem(CachedResourceNameCollectionFactory::CACHE_KEY)->willThrow($cacheException->reveal())->shouldBeCalled();
83+
$cacheItemPool->getItem(CachedResourceNameCollectionFactory::CACHE_KEY)->willThrow($cacheException)->shouldBeCalled();
8584

8685
$cachedResourceNameCollectionFactory = new CachedResourceNameCollectionFactory($cacheItemPool->reveal(), $decoratedResourceNameCollectionFactory->reveal());
8786
$resultedResourceNameCollection = $cachedResourceNameCollectionFactory->create();

tests/Operation/Factory/CachedSubresourceOperationFactoryTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,10 @@ public function testCreateWithItemNotHit()
7070

7171
public function testCreateWithGetCacheItemThrowsCacheException()
7272
{
73-
$cacheException = $this->prophesize(\Exception::class);
74-
$cacheException->willImplement(CacheException::class);
73+
$cacheException = new class() extends \Exception implements CacheException {};
7574

7675
$cacheItemPool = $this->prophesize(CacheItemPoolInterface::class);
77-
$cacheItemPool->getItem($this->generateCacheKey())->willThrow($cacheException->reveal())->shouldBeCalledTimes(1);
76+
$cacheItemPool->getItem($this->generateCacheKey())->willThrow($cacheException)->shouldBeCalledTimes(1);
7877

7978
$decoratedSubresourceOperationFactory = $this->prophesize(SubresourceOperationFactoryInterface::class);
8079
$decoratedSubresourceOperationFactory->create(Dummy::class)->shouldBeCalledTimes(1)->willReturn(['foo' => 'bar']);

0 commit comments

Comments
 (0)