Manual:Hooks/UnitTestsAfterDatabaseSetup

UnitTestsAfterDatabaseSetup
Available from version 1.30.0
Called right after MediaWiki's test infrastructure has finished creating/duplicating core tables for unit tests.
Define function:
public static function onUnitTestsAfterDatabaseSetup( $database, $prefix ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"UnitTestsAfterDatabaseSetup": "MyExtensionHooks::onUnitTestsAfterDatabaseSetup"
	}
}

For MediaWiki ≤1.25:

$wgHooks['UnitTestsAfterDatabaseSetup'][] = 'MyExtensionHooks::onUnitTestsAfterDatabaseSetup';
Called from:File(s): ../tests/phpunit/MediaWikiIntegrationTestCase.php

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:UnitTestsAfterDatabaseSetup extensions.

DetailsEdit

  • $database: Database in question
  • $prefix: Table prefix to be used in unit tests

NotesEdit

Use this hook to add your database setup to the test database before any tests are run.