Page MenuHomePhabricator

Code in PhpUnit @dataProvider methods will access production DB rather than test DB
Closed, InvalidPublic


In PhpUnit tests using a @dataProvider fooProvider within a test class marked as @group $Database, the code in the data provider function fooProvider will access the production DB throughout MW's usage of the global DB object.
E.g. when using User::createNew( 'John' ) in the data provider will create a new user "John" which will be available in the production wiki but not during the actual test.

The test DB should already be in place during data provider execution.

Event Timeline

Danwe raised the priority of this task from to Needs Triage.
Danwe updated the task description. (Show Details)
Danwe subscribed.

dataProvider are static. There is no test enviroment set up at that time. Same for configurations, see also T70231

But to ensure no leakage of object variables or object states between tests you should create objects in the test, not in the data provider.

Umherirrender claimed this task.