Repository navigation
[#899] Enforced sorted imports with 'AlphabeticallySortedUses' and finished the backend rename in test names and 'MIGRATION.md'. - #903
Conversation
…he 16 files it flagged.
…emplate, the nested-run context heredoc and the 'docs/usage.md' example.
…_test' and dropped the 3.x 'DrupalDriver' from the nested-run timeout comment.
…ietly, and how to find them.
|
Warning Review limit reached
This review includes 24 billable files and costs up to $6.00.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 24 minutes for your next included review. View limit detailsLimit details: You’ve used the included review currently available. Your 91 included PR review attempts over the past 7 days set your current allowance at 1 review per hour. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (24)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.x #903 +/- ##
=======================================
Coverage 95.96% 95.96%
=======================================
Files 164 164
Lines 8401 8401
=======================================
Hits 8062 8062
Misses 339 339 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #899
Summary
ahoy lintnow fails on out-of-orderusestatements:phpcs.xmlenablesSlevomatCodingStandard.Namespaces.AlphabeticallySortedUses, which compares namespaces segment by segment, case-insensitively, andahoy lint-fixsorts whatever it flags. Alongside that, the "Drupal, Drush and Blackbox are backends, not drivers" section ofMIGRATION.mdnow says which oldbehat_steps.driver*container names fail quietly and how to find them, andCoreCacheMethodsKernelTestkeys its cache entriesdrupal_backend_test*instead ofdrupal_driver_test*.Nothing checked import order, so when #896 renamed
DrivertoBackendeach moved import had to be re-sorted by hand: 16 files had drifted, 6 of them from the rename, plus the nested-run context heredoc inBehatCliTrait.phpand thebehat --inittemplate inClassGenerator.php, which no sniff can read. TheMIGRATION.mdsection also claimed "nothing keeps running against the old names by accident", yet an extension that sets abehat_steps.driver*parameter, tags its backendbehat_steps.driverwithout listing it underbackends, or guards an old service id withhasDefinition()gets no error at all.After merge, an unsorted import fails
ahoy lintwithAlphabeticallySortedUses.IncorrectlyOrderedUses, andbehat --initwrites its context with sorted imports. No runtime code path changes:SubDriverFinderInterfacestays removed, nothing rejects an old container name at build time, andrector.phpand the before/after import pair inMIGRATION.mdkeep their order.Before / After
Changes
1.
SubDriverFinderInterfacestays removedNothing in
src/ortests/still referencesSubDriverFinderInterface,getSubDriverPaths()or aSubBackend*name. The replacementMIGRATION.mdgives type-checks:backendFor(CoreCapabilityInterface::class)returns aCoreCapabilityInterface, whosegetCore()returns aCoreInterfacedeclaringgetExtensionPathList(). No change.2. Test-only names follow the vocabulary
They stay renamed. A sweep of
tests/, both fixture sites,scripts/,docs.php,behat*.php, the tool configs and the CI workflow found 2 spots #896 missed:CoreCacheMethodsKernelTestkeyed its cache entries and static asdrupal_driver_test:sentinel,drupal_driver_test_counteranddrupal_driver_test:memory. They'redrupal_backend_test*now, matchingdriver_field_testbecomingbackend_field_test.BehatCliContext.phpsaid "the 3.x DrupalDriver bootstraps Drupal in-process before any step runs". In 4.x the Drupal backend does the bootstrapping, and it happens when a capability first resolves to it, so the comment now names the backend and drops "before any step runs".Every other "driver" left under
tests/is Mink's browser driver, or a test of thedriverskey and@driver:tag rejections.3. Old container names are documented, not rejected
There's no compiler pass. None of the
behat_steps.driver*names ever shipped in a tagged release (git grepon3.14.3finds none), and a GitHub code search forbehat_steps.driverfinds no public consumer, so the issue's condition for adding one doesn't hold.That makes
MIGRATION.mdthe guard, and it needed fixing to do the job:behat_steps.driverisn't registered, and the guide never said so. Abackendslist naming it fails the build with "which is not registered". Without a list, the backend is simply missing from the scenario's order, so each step resolves the first remaining backend that provides its capability. Both cases are written down now.@argument or agetDefinition()call, and quietly behind ahasDefinition()check or as a service defined under the old id. The guide now says which is which.grepthat matches every old container name: parameters, service ids and tags.Each of those claims was checked against a real container build, not just read off the code.
4. Import order is linted
phpcs.xmlenablesSlevomatCodingStandard.Namespaces.AlphabeticallySortedUsesat its defaults: segment by segment, case-insensitive, classes before functions before constants. That's the order most files already followed, so it flagged only 16 of the 456 files phpcs checks. The sniff ships withdrupal/coder, which already enables 3 other Slevomat namespace sniffs.ahoy lint-fixsorted all 16, and that commit movesuselines and nothing else.The sniff only reads real
usestatements, so every PHP string, Gherkin PyString, Markdown code fence and unlinted PHP file was scanned for embedded import blocks. The out-of-order ones were sorted by hand:tests/behat/bootstrap/BehatCliTrait.phpheredocsrc/Behat/Generator/ClassGenerator.phptemplatebehat --initwrites into a consumer's projecttests/phpunit/src/Unit/Behat/Generator/ClassGeneratorTest.phpdocs/usage.md2 are left alone on purpose. The "After" half of a before/after pair in
MIGRATION.mdkeeps its lines mapped 1-to-1 onto the "Before" half, andrector.phpsits outside phpcs's file list.Worth a second look
behat --inittemplate wasn't on the issue's list. Sorting it changes the import order of every contextbehat --initgenerates from now on, and nothing else.BehatCliContext.phpcomment changed what it claims, not just a name: it no longer says Drupal bootstraps before any step runs.Testing
ahoy lintandahoy lint-docspass.ahoy test-unitpasses: 4,096 tests.ahoy test-kernelpasses: 125 tests.ahoy test-bddpasses for the 3 features that cover the nested-run harness:behatcli.feature(9 scenarios),behatcli_steps.feature(4 scenarios) anddrupal_watchdog.feature(21 scenarios). The last one runs a teardown hook that callsbackendFor(CoreCapabilityInterface::class)from the context the re-sorted heredoc writes. The full suite runs in CI.