You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PHP 8.2 deprecated the use of dynamic properties. This impacts the use of Mockery when using anonymous mocks or mocks for classes which are not available.
I'll be the first to admit I'm no Mockery expert, so I've been experimenting with how to work round the deprecation and so far I've not had much luck finding elegant solutions.
Now of course, one shouldn't mock what you do not own, but there are test situations where certain external dependencies (framework) may not be available during testing, so there's not much which can done about that.
Findings so far:
Making the mock extendstdClass doesn't seem to work as this seems to run into trouble when the method under test has a class based parameter type declaration.
Using Mockery::namedMock() and having the named mock extend stdClass, works for the first test case, but that's it. (also noted as such in the documentation).
Re-using the mock object isn't really an option as the object won't be "clean" anymore if properties are being assigned from the tests.
Along the same lines, using alias: mocks would require most tests to run in a separate process, which makes the test suite a lot slower as well as less stable.
Suggestions and "recipes" to solve this very welcome!
The text was updated successfully, but these errors were encountered:
PHP 8.2 deprecated the use of dynamic properties. This impacts the use of Mockery when using anonymous mocks or mocks for classes which are not available.
The remaining 11 test failures for Mockery itself on PHP 8.2 are all related to this.
I'll be the first to admit I'm no Mockery expert, so I've been experimenting with how to work round the deprecation and so far I've not had much luck finding elegant solutions.
Now of course, one shouldn't mock what you do not own, but there are test situations where certain external dependencies (framework) may not be available during testing, so there's not much which can done about that.
Findings so far:
extend
stdClass
doesn't seem to work as this seems to run into trouble when the method under test has a class based parameter type declaration.Mockery::namedMock()
and having the named mock extendstdClass
, works for the first test case, but that's it. (also noted as such in the documentation).Re-using the mock object isn't really an option as the object won't be "clean" anymore if properties are being assigned from the tests.
alias:
mocks would require most tests to run in a separate process, which makes the test suite a lot slower as well as less stable.Suggestions and "recipes" to solve this very welcome!
The text was updated successfully, but these errors were encountered: