@@ -151,6 +151,68 @@ public function testFlushesCached()
151
151
$ this ->assertTrue ($ result );
152
152
}
153
153
154
+ #[DataProvider('resolveKeyNameDataProvider ' )]
155
+ public function testCanGetWithEnum (mixed $ key , string $ expected )
156
+ {
157
+ $ apc = $ this ->getMockBuilder (ApcWrapper::class)->onlyMethods (['get ' ])->getMock ();
158
+ $ apc ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ($ expected ))->willReturn ('bar ' );
159
+ $ store = new ApcStore ($ apc );
160
+ $ this ->assertSame ('bar ' , $ store ->get ($ key ));
161
+ }
162
+
163
+ #[DataProvider('resolveKeyNameDataProvider ' )]
164
+ public function testCanPutWithEnum (mixed $ key , string $ expected )
165
+ {
166
+ $ apc = $ this ->getMockBuilder (ApcWrapper::class)->onlyMethods (['put ' ])->getMock ();
167
+ $ apc ->expects ($ this ->once ())
168
+ ->method ('put ' )->with ($ this ->equalTo ($ expected ), $ this ->equalTo ('bar ' ), $ this ->equalTo (60 ))
169
+ ->willReturn (true );
170
+ $ store = new ApcStore ($ apc );
171
+ $ result = $ store ->put ($ key , 'bar ' , 60 );
172
+ $ this ->assertTrue ($ result );
173
+ }
174
+
175
+ #[DataProvider('resolveKeyNameDataProvider ' )]
176
+ public function testCanIncrementWithEnum (mixed $ key , string $ expected )
177
+ {
178
+ $ apc = $ this ->getMockBuilder (ApcWrapper::class)->onlyMethods (['increment ' ])->getMock ();
179
+ $ apc ->expects ($ this ->once ())->method ('increment ' )->with ($ this ->equalTo ($ expected ), $ this ->equalTo (5 ));
180
+ $ store = new ApcStore ($ apc );
181
+ $ store ->increment ($ key , 5 );
182
+ }
183
+
184
+ #[DataProvider('resolveKeyNameDataProvider ' )]
185
+ public function testCanDecrementWithEnum (mixed $ key , string $ expected )
186
+ {
187
+ $ apc = $ this ->getMockBuilder (ApcWrapper::class)->onlyMethods (['decrement ' ])->getMock ();
188
+ $ apc ->expects ($ this ->once ())->method ('decrement ' )->with ($ this ->equalTo ($ expected ), $ this ->equalTo (5 ));
189
+ $ store = new ApcStore ($ apc );
190
+ $ store ->decrement ($ key , 5 );
191
+ }
192
+
193
+ #[DataProvider('resolveKeyNameDataProvider ' )]
194
+ public function testCanStoreItemForeverWithEnum (mixed $ key , string $ expected )
195
+ {
196
+ $ apc = $ this ->getMockBuilder (ApcWrapper::class)->onlyMethods (['put ' ])->getMock ();
197
+ $ apc ->expects ($ this ->once ())
198
+ ->method ('put ' )->with ($ this ->equalTo ($ expected ), $ this ->equalTo ('bar ' ), $ this ->equalTo (0 ))
199
+ ->willReturn (true );
200
+ $ store = new ApcStore ($ apc );
201
+ $ result = $ store ->forever ($ key , 'bar ' );
202
+ $ this ->assertTrue ($ result );
203
+ }
204
+
205
+ #[DataProvider('resolveKeyNameDataProvider ' )]
206
+ public function testCanForgetItemWithEnum (mixed $ key , string $ expected )
207
+ {
208
+ $ apc = $ this ->getMockBuilder (ApcWrapper::class)->onlyMethods (['delete ' ])->getMock ();
209
+ $ apc ->expects ($ this ->once ())->method ('delete ' )->with ($ this ->equalTo ($ expected ))->willReturn (true );
210
+ $ store = new ApcStore ($ apc );
211
+ $ result = $ store ->forget ($ key );
212
+ $ this ->assertTrue ($ result );
213
+ }
214
+ }
215
+
154
216
enum UnitCacheKey
155
217
{
156
218
case Foo;
0 commit comments