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