Debian Codegraph @

tests/phpunit/bootstrap.common.php

raw symbols SCIP
1 <?php
2
3 if ( ( PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg' ) || defined( 'MEDIAWIKI' ) ) {
4 exit( 'This file is only meant to be executed indirectly by PHPUnit\'s bootstrap process' );
5 }
6
7 fwrite( STDERR, 'Using PHP ' . PHP_VERSION . "\n" );
8
9 define( 'MEDIAWIKI', true );
10 define( 'MW_ENTRY_POINT', 'cli' );
11 // Set a flag which can be used to detect when other scripts have been entered
12 // through this entry point or not.
13 define( 'MW_PHPUNIT_TEST', true );
14
15 if ( getenv( 'PHPUNIT_WIKI' ) ) {
16 $wikiName = getenv( 'PHPUNIT_WIKI' );
17 $bits = explode( '-', $wikiName, 2 );
18 define( 'MW_DB', $bits[0] );
19 define( 'MW_PREFIX', $bits[1] ?? '' );
20 define( 'MW_WIKI_NAME', $wikiName );
21 }
22
23 require_once __DIR__ . '/../common/TestSetup.php';
24 require_once __DIR__ . "/../../includes/BootstrapHelperFunctions.php";
25
26 // phpcs:ignore MediaWiki.NamingConventions.ValidGlobalName.allowedPrefix
27 global $IP;
28 $IP = wfDetectInstallPath();
29 // Note: unit tests don't use a settings file but some code still assumes that one exists
30 wfDetectLocalSettingsFile( $IP );
31 if ( getenv( 'MW_INSTALL_PATH' ) === false ) {
32 // Set the env variable for BC with maintenance scripts and the like
33 putenv( 'MW_INSTALL_PATH=' . $IP );
34 }
35
36 TestSetup::snapshotGlobals();
37
38 // Start an output buffer to avoid headers being sent by constructors,
39 // data providers, etc. (T206476)
40 ob_start();