Skip to content

Commit 8a8eab4

Browse files
committed
Fix data persister remove stops after 1st match
1 parent 8e9fc9b commit 8a8eab4

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/DataPersister/ChainDataPersister.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function remove($data)
6363
{
6464
foreach ($this->persisters as $persister) {
6565
if ($persister->supports($data)) {
66-
$persister->remove($data);
66+
return $persister->remove($data);
6767
}
6868
}
6969
}

tests/DataPersister/ChainDataPersisterTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ public function testPersist()
6060
$barPersisterProphecy->supports($dummy)->willReturn(true)->shouldBeCalled();
6161
$barPersisterProphecy->persist($dummy)->shouldBeCalled();
6262

63-
(new ChainDataPersister([$fooPersisterProphecy->reveal(), $barPersisterProphecy->reveal()]))->persist($dummy);
63+
$foobarPersisterProphecy = $this->prophesize(DataPersisterInterface::class);
64+
$foobarPersisterProphecy->supports($dummy)->shouldNotBeCalled();
65+
$foobarPersisterProphecy->persist($dummy)->shouldNotBeCalled();
66+
67+
(new ChainDataPersister([$fooPersisterProphecy->reveal(), $barPersisterProphecy->reveal(), $foobarPersisterProphecy->reveal()]))->persist($dummy);
6468
}
6569

6670
public function testRemove()
@@ -75,6 +79,10 @@ public function testRemove()
7579
$barPersisterProphecy->supports($dummy)->willReturn(true)->shouldBeCalled();
7680
$barPersisterProphecy->remove($dummy)->shouldBeCalled();
7781

78-
(new ChainDataPersister([$fooPersisterProphecy->reveal(), $barPersisterProphecy->reveal()]))->remove($dummy);
82+
$foobarPersisterProphecy = $this->prophesize(DataPersisterInterface::class);
83+
$foobarPersisterProphecy->supports($dummy)->shouldNotBeCalled();
84+
$foobarPersisterProphecy->remove($dummy)->shouldNotBeCalled();
85+
86+
(new ChainDataPersister([$fooPersisterProphecy->reveal(), $barPersisterProphecy->reveal(), $foobarPersisterProphecy->reveal()]))->remove($dummy);
7987
}
8088
}

0 commit comments

Comments
 (0)