Skip to content

Commit

Permalink
fix #3980 DataPersister supports called without context
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Jan 25, 2021
1 parent 4b293b0 commit 8426f0a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Expand Up @@ -73,7 +73,7 @@ private function tracePersisters($data, array $context = [])
$found = false;
foreach ($this->persisters as $persister) {
if (
($this->persistersResponse[\get_class($persister)] = $found ? false : $persister->supports($data))
($this->persistersResponse[\get_class($persister)] = $found ? false : $persister->supports($data, $context))
&&
!($persister instanceof ResumableDataPersisterInterface && $persister->resumable()) && !$found
) {
Expand Down
Expand Up @@ -60,6 +60,16 @@ public function testRemove($persister, $expected)
$this->assertSame($expected, array_values($result));
}

public function testSupports() {
$context = ['ok' => true];
$persister = $this->prophesize(DataPersisterInterface::class);
$persister->supports('', $context)->willReturn(true)->shouldBeCalled();
$chain = new ChainDataPersister([$persister->reveal()]);
$persister->persist('', $context)->shouldBeCalled();
$dataPersister = new TraceableChainDataPersister($chain);
$dataPersister->persist('',$context);
}

public function dataPersisterProvider(): iterable
{
yield [
Expand Down Expand Up @@ -163,7 +173,7 @@ public function persist($data)
public function remove($data)
{
}
},
}
]),
[true, false, true],
];
Expand Down

0 comments on commit 8426f0a

Please sign in to comment.