1 | <?php |
||
51 | |||
52 | self::assertInstanceOf(GhostObjectInterface::class, $emAware); |
||
53 | self::assertInstanceOf(DDC2231EntityManagerAwareEntity::class, $emAware); |
||
54 | self::assertInstanceOf(EntityManagerAware::class, $emAware); |
||
55 | self::assertFalse($emAware->isProxyInitialized()); |
||
|
|||
56 | self::assertSame($this->em, $emAware->em); |
||
57 | |||
58 | $emAware->initializeProxy(); |
||
59 | |||
60 | self::assertSame($this->em, $emAware->em); |
||
61 | } |
||
62 | |||
63 | public function testInjectEntityManagerInFetchedInstance() : void |
||
64 | { |
||
65 | /* @var $emAware DDC2231EntityManagerAwareEntity */ |
||
66 | $emAware = $this->em->find( |
||
67 | DDC2231EntityManagerAwareEntity::class, |
||
68 | $this->persistedEntityManagerAwareEntity->id |
||
69 | ); |
||
70 | |||
71 | self::assertInstanceOf(DDC2231EntityManagerAwareEntity::class, $emAware); |
||
72 | self::assertInstanceOf(EntityManagerAware::class, $emAware); |
||
73 | self::assertNotInstanceOf(GhostObjectInterface::class, $emAware); |
||
74 | self::assertSame($this->em, $emAware->em); |
||
92 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: