Core's method names begin with a verb. Grepping every method in the module and excluding the names that are somebody else's contract, being interface and abstract declarations in the module and in core, route callbacks named in a routing.yml, and methods carrying a Hook attribute, leaves 866 verbless method names, and 752 of them are in tests.

It is a test-fixture problem

The production side is 114 occurrences across 101 names, and a good part of that is the detector's own crude verb list rather than a real defect: respond(), export(), repair(), discard(), compose() and plan() are verbs, and were only reported because the list did not contain them. What is left in production is a handful, led by options() in 4 classes and seconds() and values() in 2 each.

The test side is the real body of work: fixture builders named for what they return rather than for what they do. slot() in 22 classes, resource() in 19, tariff() in 14, freshSlotTariff() in 8, resolver() in 8, channel() in 7, preset() in 6, booking() and allotment() in 5 each.

Why it is worth doing rather than tolerating

A verbless fixture reads as a value in the test that calls it. $this->slot() looks like an accessor and is a save; $this->resource() looks like a property and writes an entity.

And because each is private to its class, the next sibling test writes its own, which is how #3619693: Retire every duplicated method body, in tests as well as production came to find 55 groups of byte-identical method bodies. The two problems share a cause.

Proposed

Rename to core's construction prefix, which is create* in 205 places in core's lib alone: createSlot(), createResource(), createTariff().

Do it alongside #3619693: Retire every duplicated method body, in tests as well as production where a builder is being moved to a shared trait anyway, since that touches every call site regardless and the name is about to become shared vocabulary rather than one class's private helper. Sweep the rest afterwards, one class at a time, so a rename that breaks a fixture is easy to see.

Not in scope

Interface and abstract methods, route callbacks and hook implementations, which cannot be renamed here and which core itself names for the thing rather than for the verb. Test method names, which are sentences by Drupal convention. Data providers.

The detector's verb list needs extending as it goes, and the count re-taken afterwards: a pattern reported as fixed while it is still standing is what let this accumulate.

AI-Generated: Yes (Claude Code took the measurements above and wrote this summary. The exclusions are listed so that the count can be reproduced or disputed.)

Issue fork yoyaku-3619712

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mably created an issue. See original summary.

mably’s picture

Status: Active » Needs review

  • mably committed d17a4cde on 1.x
    task: #3619712 Give every test fixture builder a verb, the way core...
mably’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.