Merge "Selenium: replace UserLoginPage with BlankPage where possible"
[lhc/web/wiklou.git] / tests / phpunit / bootstrap.maintenance.php
1 <?php
2 /**
3 * Bootstrapping for MediaWiki PHPUnit tests when called via the maintenance class tests runner.
4 * This file is included by phpunit and is NOT in the global scope.
5 *
6 * @file
7 */
8
9 if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
10 echo <<<EOF
11 You are running these tests directly from phpunit. You may not have all globals correctly set.
12 Running phpunit.php instead is recommended.
13 EOF;
14 require_once __DIR__ . "/phpunit.php";
15 }
16
17 // The PHPUnit_TextUI_TestRunner class will run each test suite and may call
18 // exit() with an exit status code. As such, we cannot run code "after the last test"
19 // by adding statements to PHPUnitMaintClass::execute or MediaWikiPHPUnitCommand::run.
20 // Instead, we work around it by registering a shutdown callback from the bootstrap
21 // file, which runs before PHPUnit starts.
22 // @todo Once we use PHPUnit 8 or higher, use the 'AfterLastTestHook' feature.
23 // https://phpunit.readthedocs.io/en/8.0/extending-phpunit.html#available-hook-interfaces
24 register_shutdown_function( function () {
25 // This will:
26 // - clear the temporary job queue.
27 // - allow extensions to delete any temporary tables they created.
28 // - restore ability to connect to the real database,
29 // (for logging profiling data).
30 MediaWikiTestCase::teardownTestDB();
31
32 // Log profiling data, e.g. in the database or UDP
33 wfLogProfilingData();
34 } );