summaryrefslogtreecommitdiff
blob: 6fcf9e2acccab8c2a6a977575b6f078c27c9f998 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
declare( strict_types = 1 );

/**
 * @author Niklas Laxström
 * @license GPL-2.0-or-later
 * @covers \ElasticSearchTTMServer
 */
class ElasticSearchTTMServerTest extends MediaWikiIntegrationTestCase {
	public function setUp(): void {
		parent::setUp();

		$this->config = [
			'primary' => [
				'class' => ElasticSearchTTMServer::class,
				'mirrors' => [ 'secondary' ],
			],
			'secondary' => [
				'class' => ElasticSearchTTMServer::class,
				'mirrors' => [ 'primary', 'unknown' ],
			],
		];

		$this->setMwGlobals( [
			'wgTranslateTranslationServices' => $this->config,
			'wgTranslateTranslationDefaultService' => 'primary',
		] );
	}

	public function testMirrorsConfig() {
		$primary = TTMServer::factory( $this->config['primary'] );
		$this->assertEquals( [ 'secondary' ], $primary->getMirrors() );
		$secondary = TTMServer::factory( $this->config['secondary'] );
		$this->expectException( TTMServerException::class );
		$secondary->getMirrors();
	}
}