Skip to content

feat: Add rector rule to automatically migrate to the new createInstanceWithMocks - #106

Open
come-nc wants to merge 6 commits into
mainfrom
feat/add-automock-rector
Open

come-nc wants to merge 6 commits into
mainfrom
feat/add-automock-rector

Conversation

@come-nc

@come-nc come-nc commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Migrate test classes to the new method createInstanceWithMocks.

Motivation and context

See nextcloud/server#64736

How has this been tested?

Unit test included, was also used on server code base with success.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

PR checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING.md document.
  • I have added tests to cover my changes.

@come-nc come-nc self-assigned this Sep 25, 2026
@come-nc
come-nc force-pushed the feat/add-automock-rector branch from 02e5239 to 86104b7 Compare September 25, 2026 13:08
…nceWithMocks

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
The order might be important when mocks are used in the constructor.
This is quite common for IConfig for instance.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc
come-nc force-pushed the feat/add-automock-rector branch from 1e77fe4 to 0523943 Compare October 14, 2026 15:01
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc
come-nc marked this pull request as ready for review October 14, 2026 15:33
@nickvergessen

Copy link
Copy Markdown
Contributor

Is that related to the warning PHPUnit 12 is giving? Or are we migrating to something that then even more disallows us to move forward?
TLDR of the warning is "anything that is a mock and not used should be a stub" or something a like

OCA\Notifications\Tests\Unit\WebPushClientTest::testConstructRegeneratesVapidKeysWhenDecryptionFails
No expectations were configured for the mock object for OCP\Http\Client\IClientService. Consider refactoring your test code to use a test stub instead. The #[AllowMockObjectsWithoutExpectations] attribute can be used to opt out of this check.

/home/nickv/Nextcloud/36/server/appsbabies/notifications/tests/Unit/WebPushClientTest.php:49

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants