FriendsOfSymfony/FOSOAuthServerBundle — pull request #175 by elmariachi111 (2013-08-26 15:45:44+00:00)
Title: Patch 1

I'm currently writing unit tests for controllers that are protected by an OAuth firewall. I mocked the client's entity manager using the `Doctrine\ORM\Decorator\EntityManagerDecorator` helper class. Unfortunately that class derives from `ObjectManager` in the class hierarchy. Changing the constructor signature to accept an `EntityManagerInterface` that's implemented by each and every Doctrine\ORM\EntityManager is helping out since I can use my EntityManagerDecorators to mock and test entity serialization. The reason why this affects the OAuthBundle is that the firewall depends on a valid instance of an EntityManager. I can't mock a complete EntityManager (returning user objects and tokens) so easily so I'm using a best-of-both-worlds approach: decorate the Entitymanager and mock its `persist` method -> OAuth classes work as expected (when no data is written), my Entities are persisted through overridden methods.