Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / maintenance / DatabaseLagTest.php
blob0b5dfa9a6de91a53ae64f40e54fe346561610424
1 <?php
3 namespace MediaWiki\Tests\Maintenance;
5 use Wikimedia\Rdbms\ILoadBalancer;
7 /**
8 * @covers \DatabaseLag
9 * @group Maintenance
11 class DatabaseLagTest extends MaintenanceBaseTestCase {
13 public function getMaintenanceClass() {
14 return \DatabaseLag::class;
17 public static function provideLagTimes() {
18 return [
19 'No lag' => [ 0, 'db-nolag-01', '/^db-nolag-01\s+0$/m' ],
20 'Some lag' => [ 42, 'db-somelag-02', '/^db-somelag-02\s+42$/m' ],
21 'Not replicating' => [
22 false, 'db-not-replicating-03',
23 '/db-not-replicating-03\s+replication stopped or errored$/m'
28 /**
29 * @dataProvider provideLagTimes
31 public function testReportedOutput( $lag, $servername, $expected ) {
32 $lb = $this->createMock( ILoadBalancer::class );
33 $lb->method( 'getLagTimes' )->willReturn( [ $lag ] );
34 $lb->method( 'getServerName' )->willReturn( $servername );
36 $this->setService( 'DBLoadBalancer', $lb );
38 $this->maintenance->setOption( '-r', false );
39 $this->maintenance->execute();
41 $this->maintenance->setOption( '-r', true );
42 $this->maintenance->stopReporting = true;
43 $this->maintenance->execute();
45 $this->expectOutputRegex( $expected );