summaryrefslogtreecommitdiff
path: root/extensions/LocalisationUpdate/tests/phpunit/finder/FinderTest.php
blob: b8213bacd0417a0aca93d75e1d001e0bb8c1ba75 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
 * @file
 * @author Niklas Laxström
 * @license GPL-2.0+
 */

class LU_FinderTest extends MediaWikiTestCase {
	public function testGetComponents() {
		$finder = new LU_Finder(
			array(
				'TranslateSearch' => '/IP/extensions/Translate/TranslateSearch.i18n.php',
				'Babel' => '/IP/extensions/Babel/Babel.i18n.php',
			),
			array(
				'Babel' => '/IP/extensions/Babel/i18n',
				'Door' => array(
					'core' => '/IP/extensions/Door/i18n/core',
					'extra' => '/IP/extensions/Door/i18n/extra',
				),
				'Vector' => '/IP/skins/Vector/i18n',
			),
			'/IP'
		);
		$observed = $finder->getComponents();

		$expected = array(
			'repo' => 'mediawiki',
			'orig' => "file:///IP/languages/messages/Messages*.php",
			'path' => 'languages/messages/i18n/*.json',
		);

		$this->assertArrayHasKey( 'core', $observed );
		$this->assertEquals( $expected, $observed['core'], 'Core php file' );

		$expected = array(
			'repo' => 'extension',
			'name' => 'Translate',
			'orig' => 'file:///IP/extensions/Translate/TranslateSearch.i18n.php',
			'path' => 'TranslateSearch.i18n.php'
		);
		$this->assertArrayHasKey( 'TranslateSearch', $observed );
		$this->assertEquals( $expected, $observed['TranslateSearch'], 'PHP only extension' );

		$expected = array(
			'repo' => 'extension',
			'name' => 'Babel',
			'orig' => 'file:///IP/extensions/Babel/i18n/*.json',
			'path' => 'i18n/*.json'
		);
		$this->assertArrayHasKey( 'Babel-0', $observed );
		$this->assertEquals( $expected, $observed['Babel-0'], 'PHP&JSON extension' );

		$expected = array(
			'repo' => 'extension',
			'name' => 'Door',
			'orig' => 'file:///IP/extensions/Door/i18n/core/*.json',
			'path' => 'i18n/core/*.json'
		);
		$this->assertArrayHasKey( 'Door-core', $observed );
		$this->assertEquals( $expected, $observed['Door-core'], 'Multidir json extension' );

		$expected = array(
			'repo' => 'extension',
			'name' => 'Door',
			'orig' => 'file:///IP/extensions/Door/i18n/extra/*.json',
			'path' => 'i18n/extra/*.json'
		);
		$this->assertArrayHasKey( 'Door-extra', $observed );
		$this->assertEquals( $expected, $observed['Door-extra'], 'Multidir json extension' );

		$expected = array(
			'repo' => 'skin',
			'name' => 'Vector',
			'orig' => 'file:///IP/skins/Vector/i18n/*.json',
			'path' => 'i18n/*.json'
		);
		$this->assertArrayHasKey( 'Vector-0', $observed );
		$this->assertEquals( $expected, $observed['Vector-0'], 'Json skin' );
	}
}