Answer the question
In order to leave comments, you need to log in
PHPUnit: Is it possible to lock in both a class and an interface at the same time?
Disclaimer: I understand that there are workarounds for this problem, but I'm interested in the most native way of implementation.
We have an interface that we want to catch via try catch. There are no real classes that implement this interface yet, we do this catch only in case the library in which this interface is implemented receives new exception classes with this interface. In the code that works around this try catch, this exception uses the getMessage() method.
Accordingly, we need to get a mock interface, which will have a getMessage () method. It is impossible to simply take and specify this method via setMethods() - PHPUnit will check if such a method exists in the interface and will generate an error. And in the end, we need to get an interface mod with an additional method.
Question: can we take a real-life Exception class, indicate in some way that it should implement our interface, and get such a mock? Or is this task not solved by native means of PHPUnit?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question