@@ -251,24 +251,30 @@ public function testFilter()
251251 );
252252
253253 self ::assertInstanceOf (PorterRecords::class, $ records );
254- self ::assertInstanceOf (FilteredRecords::class, $ records ->getPreviousCollection ());
255254 self ::assertSame ([1 , 3 , 5 , 7 , 9 ], iterator_to_array ($ records ));
255+
256+ /** @var FilteredRecords $previous */
257+ self ::assertInstanceOf (FilteredRecords::class, $ previous = $ records ->getPreviousCollection ());
258+ self ::assertNotSame ($ previous ->getFilter (), $ this ->specification ->getFilter (), 'Filter was not cloned. ' );
256259 }
257260
258261 public function testMap ()
259262 {
260263 $ records = $ this ->porter ->setMapper (
261264 \Mockery::mock (CollectionMapper::class)
262265 ->shouldReceive ('mapCollection ' )
263- ->with (\Mockery::type (\Iterator::class), \Mockery::type (Mapping::class), \Mockery::any ())
266+ ->with (\Mockery::type (\Iterator::class), $ mapping = \Mockery::type (Mapping::class), \Mockery::any ())
264267 ->once ()
265268 ->andReturn (new \ArrayIterator ($ result = ['foo ' => 'bar ' ]))
266269 ->getMock ()
267270 )->import ($ this ->specification ->setMapping (\Mockery::mock (Mapping::class)));
268271
269272 self ::assertInstanceOf (PorterRecords::class, $ records );
270- self ::assertInstanceOf (MappedRecords::class, $ records ->getPreviousCollection ());
271273 self ::assertSame ($ result , iterator_to_array ($ records ));
274+
275+ /** @var MappedRecords $previous */
276+ self ::assertInstanceOf (MappedRecords::class, $ previous = $ records ->getPreviousCollection ());
277+ self ::assertNotSame ($ mapping , $ previous ->getMapping (), 'Mapping was not cloned. ' );
272278 }
273279
274280 public function testApplyCacheAdvice ()
0 commit comments