I came across a problem when mocking Doctrine entities. All is fine until I want to assign custom Id to the entity (Id is inherited from the Identifier trait, Entity extends BaseEntity). Is there a satisfying way to do this?
Mockista doesn't seem to be able to mock __set() and __get() methods.
getId() method has to be final, because otherwise the proxy
would wrap it and even tho every proxy has always it's ID, simple call of
$entity->getId() would initialize the entity.
If you really need to mock the entity, you're better of setting the value with reflection directly to the property.
Yeah, seems like there is no other way. Thanks for the answer! :)
Actually Filip this might not be correct anymore. Doctrine now generates this code for non-final getId method: http://pastebin.com/FagykrWX