@@ -207,6 +207,13 @@ public function testCommit()
207207 $ this ->assertNotEmpty ($ prop ->getValue ($ this ->pool ));
208208 $ this ->assertTrue ($ this ->pool ->commit ());
209209 $ this ->assertEmpty ($ prop ->getValue ($ this ->pool ));
210+ }
211+
212+ public function testCommitBadItems ()
213+ {
214+ $ ref = new \ReflectionObject ($ this ->pool );
215+ $ prop = $ ref ->getProperty ('deferred ' );
216+ $ prop ->setAccessible (true );
210217
211218 $ badItem = m::mock (CacheItemInterface::class);
212219 $ badItem ->shouldReceive ('getKey ' )->once ()->andReturn ('bad_key ' );
@@ -218,4 +225,25 @@ public function testCommit()
218225 $ this ->assertFalse ($ this ->pool ->commit ());
219226 $ this ->assertEmpty ($ prop ->getValue ($ this ->pool ));
220227 }
228+
229+ public function testCommitMultipleItems ()
230+ {
231+ $ ref = new \ReflectionObject ($ this ->pool );
232+ $ prop = $ ref ->getProperty ('deferred ' );
233+ $ prop ->setAccessible (true );
234+
235+ // the middle object is bad
236+ $ this ->mockDoctrine ->shouldReceive ('save ' )->andReturn (true , false , true );
237+
238+ for ($ i = 0 ; $ i < 3 ; $ i ++) {
239+ $ item = m::mock (CacheItemInterface::class);
240+ $ item ->shouldReceive ('getKey ' )->andReturn ('key_ ' .$ i );
241+ $ this ->pool ->saveDeferred ($ item );
242+ }
243+
244+ $ this ->assertNotEmpty ($ prop ->getValue ($ this ->pool ));
245+
246+ $ this ->assertFalse ($ this ->pool ->commit ());
247+ $ this ->assertEmpty ($ prop ->getValue ($ this ->pool ));
248+ }
221249}
0 commit comments