Do not ignore constructor arguments based on type being mocked#3694
Do not ignore constructor arguments based on type being mocked#3694sebastianbergmann merged 1 commit intosebastianbergmann:7.5from morozov:throwable-ctr-args
Conversation
Codecov Report
@@ Coverage Diff @@
## 7.5 #3694 +/- ##
============================================
- Coverage 83.37% 83.36% -0.01%
+ Complexity 3647 3645 -2
============================================
Files 143 143
Lines 9713 9711 -2
============================================
- Hits 8098 8096 -2
Misses 1615 1615
Continue to review full report at Codecov.
|
1. Got rid of hard-coded exception mocks in favor of PHPUnit-generated ones. 2. Reworked AbstractDriverTest::testConvertsException() to use a data provider to make testing all types of exceptions independent. 3. Updated PHPUnit since the reworked code relies on sebastianbergmann/phpunit#3604 and sebastianbergmann/phpunit#3694.
1. Got rid of hard-coded exception mocks in favor of PHPUnit-generated ones. 2. Reworked AbstractDriverTest::testConvertsException() to use a data provider to make testing all types of exceptions independent. 3. Updated PHPUnit since the reworked code relies on sebastianbergmann/phpunit#3604 and sebastianbergmann/phpunit#3694.
|
Just curious: in what scenario does stubbing/mocking |
|
In doctrine/dbal, we have some logic of handling/generalizing driver exceptions based on their properties. We do not mock |
|
Can you point me to a test that does this? Thanks! |
|
See |
Currently, it is impossible to mock the message or code on a
Throwable. On the one hand,getMessage()andgetCode()arefinalinException, on the other, the mock generator ignores constructor arguments if the type being mocked is an interface.The existing behavior doesn't seem correct because on the one hand, PHP currently allows passing more arguments than the method expects (including class constructors). On the other, if it stops doing so at some point later, it should be a test error, not the PHPUnit's call to ignore the arguments.