1616use Psr \Cache \CacheItemPoolInterface ;
1717
1818/**
19- * We should not use constants on interfaces in the tests. Tests should break if the constant is changed.
20- *
2119 * @author Tobias Nyholm <[email protected] > 2220 */
2321class PrefixedCachePoolTest extends \PHPUnit_Framework_TestCase
2422{
2523 /**
26- * @return \PHPUnit_Framework_MockObject_MockObject
24+ * @return \PHPUnit_Framework_MockObject_MockObject|CacheItemPoolInterface
2725 */
28- private function getHierarchyCacheStub ()
26+ private function getCacheStub ()
2927 {
3028 return $ this ->getMockBuilder (CacheItemPoolInterface::class)->setMethods (
3129 ['getItem ' , 'getItems ' , 'hasItem ' , 'clear ' , 'deleteItem ' , 'deleteItems ' , 'save ' , 'saveDeferred ' , 'commit ' ]
@@ -38,7 +36,7 @@ public function testGetItem()
3836 $ key = 'key ' ;
3937 $ returnValue = true ;
4038
41- $ stub = $ this ->getHierarchyCacheStub ();
39+ $ stub = $ this ->getCacheStub ();
4240 $ stub ->expects ($ this ->once ())->method ('getItem ' )->with ($ prefix .$ key )->willReturn ($ returnValue );
4341
4442 $ pool = new PrefixedCachePool ($ stub , $ prefix );
@@ -52,7 +50,7 @@ public function testGetItems()
5250 $ key1 = 'key1 ' ;
5351 $ returnValue = true ;
5452
55- $ stub = $ this ->getHierarchyCacheStub ();
53+ $ stub = $ this ->getCacheStub ();
5654 $ stub ->expects ($ this ->once ())->method ('getItems ' )->with ([$ prefix .$ key0 , $ prefix .$ key1 ])->willReturn ($ returnValue );
5755
5856 $ pool = new PrefixedCachePool ($ stub , $ prefix );
@@ -65,7 +63,7 @@ public function testHasItem()
6563 $ key = 'key ' ;
6664 $ returnValue = true ;
6765
68- $ stub = $ this ->getHierarchyCacheStub ();
66+ $ stub = $ this ->getCacheStub ();
6967 $ stub ->expects ($ this ->once ())->method ('hasItem ' )->with ($ prefix .$ key )->willReturn ($ returnValue );
7068
7169 $ pool = new PrefixedCachePool ($ stub , $ prefix );
@@ -78,11 +76,11 @@ public function testClear()
7876 $ key = 'key ' ;
7977 $ returnValue = true ;
8078
81- $ stub = $ this ->getHierarchyCacheStub ();
79+ $ stub = $ this ->getCacheStub ();
8280 $ stub ->expects ($ this ->once ())->method ('clear ' )->willReturn ($ returnValue );
8381
8482 $ pool = new PrefixedCachePool ($ stub , $ prefix );
85- $ this ->assertEquals ($ returnValue , $ pool ->clear ($ key ));
83+ $ this ->assertEquals ($ returnValue , $ pool ->clear ());
8684 }
8785
8886 public function testDeleteItem ()
@@ -91,7 +89,7 @@ public function testDeleteItem()
9189 $ key = 'key ' ;
9290 $ returnValue = true ;
9391
94- $ stub = $ this ->getHierarchyCacheStub ();
92+ $ stub = $ this ->getCacheStub ();
9593 $ stub ->expects ($ this ->once ())->method ('deleteItem ' )->with ($ prefix .$ key )->willReturn ($ returnValue );
9694
9795 $ pool = new PrefixedCachePool ($ stub , $ prefix );
@@ -105,7 +103,7 @@ public function testDeleteItems()
105103 $ key1 = 'key1 ' ;
106104 $ returnValue = true ;
107105
108- $ stub = $ this ->getHierarchyCacheStub ();
106+ $ stub = $ this ->getCacheStub ();
109107 $ stub ->expects ($ this ->once ())->method ('deleteItems ' )->with ([$ prefix .$ key0 , $ prefix .$ key1 ])->willReturn ($ returnValue );
110108
111109 $ pool = new PrefixedCachePool ($ stub , $ prefix );
@@ -114,11 +112,12 @@ public function testDeleteItems()
114112
115113 public function testSave ()
116114 {
115+ /** @type CacheItemInterface $item */
117116 $ item = $ this ->getMockBuilder (CacheItemInterface::class)->getMock ();
118117 $ prefix = 'ns ' ;
119118 $ returnValue = true ;
120119
121- $ stub = $ this ->getHierarchyCacheStub ();
120+ $ stub = $ this ->getCacheStub ();
122121 $ stub ->expects ($ this ->once ())->method ('save ' )->with ($ item )->willReturn ($ returnValue );
123122
124123 $ pool = new PrefixedCachePool ($ stub , $ prefix );
@@ -127,11 +126,12 @@ public function testSave()
127126
128127 public function testSaveDeffered ()
129128 {
129+ /** @type CacheItemInterface $item */
130130 $ item = $ this ->getMockBuilder (CacheItemInterface::class)->getMock ();
131131 $ prefix = 'ns ' ;
132132 $ returnValue = true ;
133133
134- $ stub = $ this ->getHierarchyCacheStub ();
134+ $ stub = $ this ->getCacheStub ();
135135 $ stub ->expects ($ this ->once ())->method ('saveDeferred ' )->with ($ item )->willReturn ($ returnValue );
136136
137137 $ pool = new PrefixedCachePool ($ stub , $ prefix );
@@ -143,7 +143,7 @@ public function testCommit()
143143 $ prefix = 'ns ' ;
144144 $ returnValue = true ;
145145
146- $ stub = $ this ->getHierarchyCacheStub ();
146+ $ stub = $ this ->getCacheStub ();
147147 $ stub ->expects ($ this ->once ())->method ('commit ' )->willReturn ($ returnValue );
148148
149149 $ pool = new PrefixedCachePool ($ stub , $ prefix );
0 commit comments