The below comes from debugging issues with https://gerrit.wikimedia.org/r/#/c/351645/
The issue is that by between the point that the test dbs are setup and the test is run, a new connection is being used and thus the temporary tables that were created are no longer accessible.
This was due to the use of the method setService in the setUp method of the test which calls overrideMwServices if not already calls which replaces the current MediaWikiServices instance, and this new instance has a new LoadBalancer thus we get a new connection.
The rough order of processing is:
- parent::run (phpunit testcase)
- (overrideMwServices called as a result of using setService)
- (overrideMwServices caused a new services instance, & thus new db connections?)