MediaWiki  1.23.2
getSlaveServerTest.php
Go to the documentation of this file.
1 <?php
2 
3 require_once __DIR__ . "/../../../maintenance/getSlaveServer.php";
4 
12 
21  private function getServerRE() {
22  if ( $this->db->getType() === 'sqlite' ) {
23  // for SQLite, only the empty string is a good server name
24  return '';
25  }
26 
27  $octet = '([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])';
28  $ip = "(($octet\.){3}$octet)";
29 
30  $label = '([a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)';
31  $hostname = "($label(\.$label)*)";
32 
33  return "($ip|$hostname)(:[0-9]{1,5})?";
34  }
35 
36  function testPlain() {
37  $gss = new GetSlaveServer();
38  $gss->execute();
39 
40  $this->expectOutputRegex( "/^" . self::getServerRE() . "\n$/D" );
41  }
42 
44  global $wgDBprefix;
45 
46  global $argv;
47  $argv = array( null, "--globals" );
48 
49  $gss = new GetSlaveServer();
50  $gss->loadParamsAndArgs();
51  $gss->execute();
52  $gss->globals();
53 
54  // The main answer
55  $output = $this->getActualOutput();
56  $firstLineEndPos = strpos( $output, "\n" );
57  if ( $firstLineEndPos === false ) {
58  $this->fail( "Could not find end of first line of output" );
59  }
60  $firstLine = substr( $output, 0, $firstLineEndPos );
61  $this->assertRegExp( "/^" . self::getServerRE() . "$/D",
62  $firstLine, "DB Server" );
63 
64  // xmldumps-backup relies on the wgDBprefix in the output.
65  $this->expectOutputRegex( "/^[[:space:]]*\[wgDBprefix\][[:space:]]*=> "
66  . $wgDBprefix . "$/m" );
67  }
68 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
GetSlaveServerTest
Tests for getSlaveServer.
Definition: getSlaveServerTest.php:11
fail
as a message key or array as accepted by ApiBase::dieUsageMsg after processing request parameters Return false to let the request fail
Definition: hooks.txt:375
GetSlaveServerTest\getServerRE
getServerRE()
Yields a regular expression that matches a good DB server name.
Definition: getSlaveServerTest.php:21
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
GetSlaveServer
Maintenance script that reports the hostname of a slave server.
Definition: getSlaveServer.php:31
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
GetSlaveServerTest\testPlain
testPlain()
Definition: getSlaveServerTest.php:36
GetSlaveServerTest\testXmlDumpsBackupUseCase
testXmlDumpsBackupUseCase()
Definition: getSlaveServerTest.php:43
$output
& $output
Definition: hooks.txt:375