-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static approach makes this class unmockable #9
Comments
Hi, thanks for reaching out.
Could you provide some code example of what you are trying to do?
…On 3 July 2017 at 10:01, Lars ***@***.***> wrote:
Hey there,
I found that you class seems to be unmockable for PHPUnit, because all its
calls are static and the state is saved staticalled, too.
I could imagine, why you would have chosen this approach, but it hinders
us from mocking it away.
Do you see a way of combining a 'correct' stateful approach with your easy
accessible static one? Maybe with the singleton pattern for example?
With this approach there would be almost to none changes to your existing
public api, because you could hide the instanciating process in your class.
Or maybe something else, like a new major with a compatibility break?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#9>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAbeFSqyDFPnlCdjvd2hLUTPS-2mfX2Lks5sKJ--gaJpZM4OL87r>
.
|
Of what I am trying to test or how I would imagine your class in the non-static approach? |
Of what are you not being able to test properly
…On 3 July 2017 at 11:54, Lars ***@***.***> wrote:
Of what I am trying to test or how I would imagine your class in the
non-static approach?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#9 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAbeFUF1gQQ6SRdsnAccVRcpHliaDuo4ks5sKLprgaJpZM4OL87r>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey there,
I found that you class seems to be unmockable for PHPUnit, because all its calls are static and the state is saved staticalled, too.
I could imagine, why you would have chosen this approach, but it hinders us from mocking it away.
Do you see a way of combining a 'correct' stateful approach with your easy accessible static one? Maybe with the singleton pattern for example?
With this approach there would be almost to none changes to your existing public api, because you could hide the instanciating process in your class.
Or maybe something else, like a new major with a compatibility break?
The text was updated successfully, but these errors were encountered: