Skip to content

Commit

Permalink
Implement isUninitializedObject() in ObjectManagerDecorator
Browse files Browse the repository at this point in the history
That method will be part of the ObjectManager interface in 4.0.x.
  • Loading branch information
greg0ire committed May 22, 2024
1 parent bea01f5 commit d600776
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Persistence/ObjectManagerDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ public function initializeObject(object $obj)
$this->wrapped->initializeObject($obj);
}

/** @param mixed $value */
public function isUninitializedObject($value): bool
{
return $this->wrapped->isUninitializedObject($value);
}

/**
* {@inheritDoc}
*/
Expand Down
20 changes: 20 additions & 0 deletions tests/Persistence/ObjectManagerDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,26 @@ public function testContains(): void

self::assertTrue($this->decorated->contains($object));
}

/** @requires PHP 8.0 */
public function testIsUninitializedObject(): void
{
$object = new TestObject();

$wrapped = $this->createMock(ObjectManagerV4::class);
$decorated = new NullObjectManagerDecorator($wrapped);
$wrapped->expects(self::once())
->method('isUninitializedObject')
->with($object)
->willReturn(false);

self::assertFalse($decorated->isUninitializedObject($object));
}
}

interface ObjectManagerV4 extends ObjectManager
{
public function isUninitializedObject(mixed $object): bool;
}

/** @extends ObjectManagerDecorator<ObjectManager&MockObject> */
Expand Down

0 comments on commit d600776

Please sign in to comment.