I think you cannot have that method be private
, because the very time you enter the code of your real object, any call to $this->buildPaymentURL
MUST end up in that real private method.
Make it protected. That way, the mock can extend your class and overwrite the function.
On the other hand, I always have a bit of a bad feeling if there is a need for such partial mocks. They are most likely a sign of bad design. It seems that this private method should rather be contained in an object of its own that is dealing with URL creation exclusively (and can be tested seperately), and this class you are testing now should only get a complete mock of that new class injected.