Skip to content

Commit 84b9cf5

Browse files
author
Rodrigue Villetard
committed
fix skipped data persisters on persist
1 parent 3b5d77f commit 84b9cf5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/DataPersister/ChainDataPersister.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ public function persist($data)
5151
{
5252
foreach ($this->persisters as $persister) {
5353
if ($persister->supports($data)) {
54-
return $persister->persist($data) ?? $data;
54+
$data = $persister->persist($data) ?? $data;
5555
}
5656
}
57+
58+
return $data;
5759
}
5860

5961
/**

tests/DataPersister/ChainDataPersisterTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,15 @@ 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+
$bazPersisterProphecy = $this->prophesize(DataPersisterInterface::class);
64+
$bazPersisterProphecy->supports($dummy)->willReturn(true)->shouldBeCalled();
65+
$bazPersisterProphecy->persist($dummy)->shouldBeCalled();
66+
67+
(new ChainDataPersister([
68+
$fooPersisterProphecy->reveal(),
69+
$barPersisterProphecy->reveal(),
70+
$bazPersisterProphecy->reveal(),
71+
]))->persist($dummy);
6472
}
6573

6674
public function testRemove()

0 commit comments

Comments
 (0)