|
29 | 29 | use Doctrine\ORM\UnitOfWork;
|
30 | 30 | use PHPUnit\Framework\TestCase;
|
31 | 31 | use Prophecy\Argument;
|
| 32 | +use Symfony\Component\PropertyAccess\PropertyAccessorInterface; |
32 | 33 |
|
33 | 34 | /**
|
34 | 35 | * @author Kévin Dunglas <[email protected]>
|
@@ -78,11 +79,22 @@ public function testOnFlush()
|
78 | 79 |
|
79 | 80 | $emProphecy = $this->prophesize(EntityManagerInterface::class);
|
80 | 81 | $emProphecy->getUnitOfWork()->willReturn($uowProphecy->reveal())->shouldBeCalled();
|
81 |
| - $emProphecy->getClassMetadata(Dummy::class)->willReturn(new ClassMetadata(Dummy::class))->shouldBeCalled(); |
| 82 | + $dummyClassMetadata = new ClassMetadata(Dummy::class); |
| 83 | + $dummyClassMetadata->associationMappings = [ |
| 84 | + 'relatedDummy' => [], |
| 85 | + 'relatedOwningDummy' => [], |
| 86 | + ]; |
| 87 | + $emProphecy->getClassMetadata(Dummy::class)->willReturn($dummyClassMetadata)->shouldBeCalled(); |
82 | 88 | $emProphecy->getClassMetadata(DummyNoGetOperation::class)->willReturn(new ClassMetadata(DummyNoGetOperation::class))->shouldBeCalled();
|
83 | 89 | $eventArgs = new OnFlushEventArgs($emProphecy->reveal());
|
84 | 90 |
|
85 |
| - $listener = new PurgeHttpCacheListener($purgerProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal()); |
| 91 | + $propertyAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class); |
| 92 | + $propertyAccessorProphecy->isReadable(Argument::type(Dummy::class), 'relatedDummy')->willReturn(true); |
| 93 | + $propertyAccessorProphecy->isReadable(Argument::type(Dummy::class), 'relatedOwningDummy')->willReturn(false); |
| 94 | + $propertyAccessorProphecy->getValue(Argument::type(Dummy::class), 'relatedDummy')->shouldBeCalled(); |
| 95 | + $propertyAccessorProphecy->getValue(Argument::type(Dummy::class), 'relatedOwningDummy')->shouldNotBeCalled(); |
| 96 | + |
| 97 | + $listener = new PurgeHttpCacheListener($purgerProphecy->reveal(), $iriConverterProphecy->reveal(), $resourceClassResolverProphecy->reveal(), $propertyAccessorProphecy->reveal()); |
86 | 98 | $listener->onFlush($eventArgs);
|
87 | 99 | $listener->postFlush();
|
88 | 100 | }
|
|
0 commit comments