The remaining issue is that the Wikidata.php entry file is loaded before we can define some vars in php, thus the repo / client is not loaded hence Lib is not loaded and we get the exception about undefined constant.
The wikidata.php file is loaded by the 50_mw_ext_loader.php file.
As far as I can tell the best ways to deal with this would be to:
Allow tests to specify what they want to be added to localsettings, this would probably require far to much repetition in regard to extension tests, although would mean we can test extensions that have badly named entry points.
Allow tests to specify specific things to add to localsettings but if this is not defined then fallback to the autoloading of entry points (seems like quite a good plan)
Allow tests to skip the autoloading of extensions from 50_mw_ext_loader.php
Allow tests to skip any defined conf.d file by adding it to some sort of ignore array prior to them all loading
Version: wmf-deployment
Severity: enhancement