Skip to content

refactor(tests): apply selected rector rules to tests - #14234

Draft
ChristophWurst wants to merge 6 commits into
mainfrom
refactor/rector-test-classes
Draft

ChristophWurst wants to merge 6 commits into
mainfrom
refactor/rector-test-classes

Conversation

@ChristophWurst

Copy link
Copy Markdown
Member

Context

Part of cleaning up the tests with Rector, split out of #14207 so each change can be reviewed and tested on its own. No ticket.

Approach

Each Rector rule gets its own commit, and the next one is only added once CI is green for the previous one:

  1. Make test classes final (this commit)
  2. Add : void to test methods
  3. Declare strict types in tests
  4. Turn data providers into generators

Deliberately left out: the rest of the Rector output from #14207. Rules that rewrote tests incorrectly (callbacks, removed properties, withConsecutive, self:: to $this->) are skipped there and not applied here.

Testing

CI only. The commits only touch tests/.

AI assistance

Assisted by ClaudeCode:claude-sonnet-5-5

Assisted by ClaudeCode:claude-sonnet-5-5

Test classes are not meant to be extended, so `final` states that and
stops accidental inheritance between tests. Result of Rector's
FinalizeTestCaseClassRector, which skips classes that have children.

Assisted-by: ClaudeCode:claude-sonnet-5-5
Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
@ChristophWurst ChristophWurst self-assigned this Nov 18, 2026
@nextcloud-command nextcloud-command added the AI assisted This PR contains AI-assisted commits label Nov 18, 2026
Test methods return nothing, so declare it. Result of Rector's
AddTestsVoidReturnTypeWhereNoReturnRector.

Assisted-by: ClaudeCode:claude-sonnet-5-5
Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
Test files without strict_types silently coerce scalar arguments, which
can hide type errors in the code under test. Result of Rector's
DeclareStrictTypesTestsRector on the 51 test files that lacked it.

Assisted-by: ClaudeCode:claude-sonnet-5-5
Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
Assisted-by: ClaudeCode:claude-sonnet-5-5
Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
Data providers that return a large literal array build every row up
front. Yielding them keeps one row per `yield` line and lets PHPUnit
stream the data sets. Result of Rector's YieldDataProviderRector,
followed by cs:fix.

Assisted-by: ClaudeCode:claude-sonnet-5-5
Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
…classes

Assisted-by: ClaudeCode:claude-sonnet-5-5
Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>

This branch has not been deployed

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

Labels

2. developing AI assisted This PR contains AI-assisted commits

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants