@@ -113,6 +113,14 @@ public function testPuttingMultipleItemsInCache()
113113 $ repo ->put (['foo ' => 'bar ' , 'bar ' => 'baz ' ], 1 );
114114 }
115115
116+ public function testSettingMultipleItemsInCache ()
117+ {
118+ // Alias of PuttingMultiple
119+ $ repo = $ this ->getRepository ();
120+ $ repo ->getStore ()->shouldReceive ('putMany ' )->once ()->with (['foo ' => 'bar ' , 'bar ' => 'baz ' ], 1 );
121+ $ repo ->setMultiple (['foo ' => 'bar ' , 'bar ' => 'baz ' ], 1 );
122+ }
123+
116124 public function testPutWithDatetimeInPastOrZeroSecondsDoesntSaveItem ()
117125 {
118126 $ repo = $ this ->getRepository ();
@@ -174,6 +182,53 @@ public function testRegisterMacroWithNonStaticCall()
174182 $ this ->assertEquals ($ repo ->{__CLASS__ }(), 'Taylor ' );
175183 }
176184
185+ public function testForgettingCacheKey ()
186+ {
187+ $ repo = $ this ->getRepository ();
188+ $ repo ->getStore ()->shouldReceive ('forget ' )->once ()->with ('a-key ' )->andReturn (true );
189+ $ repo ->forget ('a-key ' );
190+ }
191+
192+ public function testRemovingCacheKey ()
193+ {
194+ // Alias of Forget
195+ $ repo = $ this ->getRepository ();
196+ $ repo ->getStore ()->shouldReceive ('forget ' )->once ()->with ('a-key ' )->andReturn (true );
197+ $ repo ->delete ('a-key ' );
198+ }
199+
200+ public function testSettingCache ()
201+ {
202+ $ repo = $ this ->getRepository ();
203+ $ repo ->getStore ()->shouldReceive ('put ' )->with ($ key = 'foo ' , $ value = 'bar ' , 1 );
204+ $ repo ->set ($ key , $ value , 1 );
205+ }
206+
207+ public function testClearingWholeCache ()
208+ {
209+ $ repo = $ this ->getRepository ();
210+ $ repo ->getStore ()->shouldReceive ('flush ' )->andReturn (true );
211+ $ repo ->clear ();
212+ }
213+
214+ public function testGettingMultipleValuesFromCache ()
215+ {
216+ $ keys = ['key1 ' , 'key2 ' , 'key3 ' ];
217+ $ default = ['key2 ' => 5 ];
218+
219+ $ repo = $ this ->getRepository ();
220+ $ repo ->getStore ()->shouldReceive ('many ' )->once ()->with (['key2 ' , 'key1 ' , 'key3 ' ])->andReturn (['key1 ' => 1 , 'key2 ' => null , 'key3 ' => null ]);
221+ $ this ->assertEquals (['key1 ' => 1 , 'key2 ' => 5 , 'key3 ' => null ], $ repo ->getMultiple ($ keys , $ default ));
222+ }
223+
224+ public function testRemovingMultipleKeys ()
225+ {
226+ $ repo = $ this ->getRepository ();
227+ $ repo ->getStore ()->shouldReceive ('forget ' )->once ()->with ('a-key ' )->andReturn (true );
228+ $ repo ->getStore ()->shouldReceive ('forget ' )->once ()->with ('a-second-key ' )->andReturn (true );
229+ $ repo ->deleteMultiple (['a-key ' , 'a-second-key ' ]);
230+ }
231+
177232 protected function getRepository ()
178233 {
179234 $ dispatcher = new \Illuminate \Events \Dispatcher (m::mock ('Illuminate\Container\Container ' ));
0 commit comments