conditionally mock methods

These methods / classes do not exist on all versions of doctrine.
This change makes the test suite green again for 2.2 and 2.3, while
keeping the exact same tests for 2.4.