-
Notifications
You must be signed in to change notification settings - Fork 461
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
How to mock protected properties? #1142
Comments
Alright, here is the correct answer - it is possible with a custom trait 😁 (Laravel 10+, PHP 8.1+; source) but with limitations:
$mock = Mockery::mock(A::class, MockProperties::class);
$mock
->shouldUseProperty('b')
->value(
Mockery::mock(B::class), // or just `new B()`.
);
$mock->a(); Implementation is pretty simple but relies on internals :( Would be nice if Mockery will support something similar out of the box ( |
Does mockery support mock protected properties? What should I do if I can?
The text was updated successfully, but these errors were encountered: