Problem/Motivation
As we add more stuff into Drupal\TestTools namespace, more scripts that rely on classes under it need to add it to the classloader in their code.
Proposed resolution
Just add the namespace in the "autoloader-dev" section of the composer.json file, and let composer manage it for dev environments.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3614056
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
Comment #3
mondrakeComment #4
mondrakeComment #5
smustgrave commentedMakes sense could we add a CR for others to use? Imagine it'll be basic.
Comment #6
mondrakeNot sure #5 really benefits anyone apart from a small group of people working on test tooling, but added a draft CR anyway.
Comment #7
smustgrave commentedBetter safe then sorry suppose.
But LGTM thanks!
Comment #8
longwaveWhat about contrib or custom tests that use
\Drupal\TestTools\Random?KTB also refers to
\Drupal\TestTools\Extension\SchemaInspector- will this break when used outside of core tests?Comment #9
longwaveActually why isn't it enough to add it to
core/tests/bootstrap.phpalone?Comment #10
mondrake#8 I do not think so - if you build a dev codebase with Composer both would still be accessible from the Composer autoloader no? This issue only really benefits additional scripts that will not rely on core/tests/bootstrap.php. For instance, run-tests.sh (that currently adds the namespace to the classloader); in the future #3523614: [CI] Collect and report deprecation statistics and details could need a cli script to consolidate/report deprecation statistics accessing classes i n this namespace, #3595595: Convert run-tests.sh to a set of dr commands may add to the dr script command defined in this namespace, etc etc
Comment #11
longwaveMaybe I'm missing something here but
autoload-devis marked root-only: https://getcomposer.org/doc/04-schema.md#autoload-devThis means that it only takes effect for users working from a checkout of the Drupal core repo, and if it was in
core/composer.jsonthen it wouldn't work for those users either (because they aren't using it at the root level).Where does
Drupal\TestToolsget added to the autoloader for users outside of thedrupal/drupaldevelopment repo?Comment #12
mstrelan commented#11 I think it needs to go in autoload of
drupal/core-devComment #13
smustgrave commentedSo what’s next steps for this one?
Comment #14
smustgrave commentedSo is this a won't fix or different change needed? Should it be NW?
Comment #15
mstrelan commentedI asked Claude about this. #11 is correct, so setting NW to figure this out. #12 won't work because drupal/core-dev is a metapackage and autoload doesn't apply there. We would need a real package (drupal/core-test-tools?), but not sure we really want to do that.