Skip to content

[PHPUnit120] Skip mocks with expectations in AllowMockObjectsForDataProviderRector - #857

Closed
sanketpatel32 wants to merge 3 commits into
rectorphp:mainfrom
sanketpatel32:devin/1796244990-allow-mock-expectations-detection
Closed

sanketpatel32 wants to merge 3 commits into
rectorphp:mainfrom
sanketpatel32:devin/1796244990-allow-mock-expectations-detection

Conversation

@sanketpatel32

Copy link
Copy Markdown
Contributor

Summary

  • compare direct method() calls with expects() calls on the same mock receiver before treating the mock as expectationless
  • add a regression fixture for a data-provider test that mixes expects()->method()->with() and plain method()->willReturn() on one mock
  • add coverage that a separate mock without expectations still triggers the attribute

Fixes rectorphp/rector#9984

Fixes #9984

Tests

  • vendor/bin/phpunit rules-tests/PHPUnit120/Rector/Class_/AllowMockObjectsForDataProviderRector/AllowMockObjectsForDataProviderRectorTest.php
  • vendor/bin/phpstan analyse --ansi --no-progress
  • vendor/bin/ecs check --ansi

@TomasVotruba

Copy link
Copy Markdown
Member

Thank you for the fix! Continued in #859, which includes your commits plus a few more cases (parameters rules, re-assigned mocks, expects() in setUp()).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Rector adds attribute AllowMockObjectsWithoutExpectations when it's not needed

2 participants