There should be a UserFactory service for constructing users
In the initial stage, it can just proxy the existing User::newFrom* methods, similar to the existing TitleFactory, which was created in https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/95586dd93721d17135cd4d0dea53f62bd7b781f5
Makes it possible to mock static Title methods in tests, where they are one of the more common reasons for not being able to use MediaWikiUnitTestCase.
Actually introducing dependency injection to Title is left for the future.
Subsequently, it will be converted to an actual factory, replacing (check mark means the logic is now in the factory)
- User::newFromName - inject UserNameUtils
- User::newFromConfirmationCode - inject LoadBalancer
This will be another step in splitting up the User "god object"