MediaWiki REL1_32
FinderTest.php
Go to the documentation of this file.
1<?php
8namespace LocalisationUpdate;
9
13class FinderTest extends \PHPUnit\Framework\TestCase {
14 public function testGetComponents() {
15 $finder = new Finder(
16 [
17 'TranslateSearch' => '/IP/extensions/Translate/TranslateSearch.i18n.php',
18 'Babel' => '/IP/extensions/Babel/Babel.i18n.php',
19 ],
20 [
21 'Babel' => '/IP/extensions/Babel/i18n',
22 'Door' => [
23 'core' => '/IP/extensions/Door/i18n/core',
24 'extra' => '/IP/extensions/Door/i18n/extra',
25 ],
26 'Vector' => '/IP/skins/Vector/i18n',
27 ],
28 '/IP'
29 );
30 $observed = $finder->getComponents();
31
32 $expected = [
33 'repo' => 'mediawiki',
34 'orig' => "file:///IP/languages/messages/Messages*.php",
35 'path' => 'languages/messages/i18n/*.json',
36 ];
37
38 $this->assertArrayHasKey( 'core', $observed );
39 $this->assertEquals( $expected, $observed['core'], 'Core php file' );
40
41 $expected = [
42 'repo' => 'extension',
43 'name' => 'Translate',
44 'orig' => 'file:///IP/extensions/Translate/TranslateSearch.i18n.php',
45 'path' => 'TranslateSearch.i18n.php'
46 ];
47 $this->assertArrayHasKey( 'TranslateSearch', $observed );
48 $this->assertEquals( $expected, $observed['TranslateSearch'], 'PHP only extension' );
49
50 $expected = [
51 'repo' => 'extension',
52 'name' => 'Babel',
53 'orig' => 'file:///IP/extensions/Babel/i18n/*.json',
54 'path' => 'i18n/*.json'
55 ];
56 $this->assertArrayHasKey( 'Babel-0', $observed );
57 $this->assertEquals( $expected, $observed['Babel-0'], 'PHP&JSON extension' );
58
59 $expected = [
60 'repo' => 'extension',
61 'name' => 'Door',
62 'orig' => 'file:///IP/extensions/Door/i18n/core/*.json',
63 'path' => 'i18n/core/*.json'
64 ];
65 $this->assertArrayHasKey( 'Door-core', $observed );
66 $this->assertEquals( $expected, $observed['Door-core'], 'Multidir json extension' );
67
68 $expected = [
69 'repo' => 'extension',
70 'name' => 'Door',
71 'orig' => 'file:///IP/extensions/Door/i18n/extra/*.json',
72 'path' => 'i18n/extra/*.json'
73 ];
74 $this->assertArrayHasKey( 'Door-extra', $observed );
75 $this->assertEquals( $expected, $observed['Door-extra'], 'Multidir json extension' );
76
77 $expected = [
78 'repo' => 'skin',
79 'name' => 'Vector',
80 'orig' => 'file:///IP/skins/Vector/i18n/*.json',
81 'path' => 'i18n/*.json'
82 ];
83 $this->assertArrayHasKey( 'Vector-0', $observed );
84 $this->assertEquals( $expected, $observed['Vector-0'], 'Json skin' );
85 }
86}
\LocalisationUpdate\Finder
Interface for classes which provide list of components, which should be included for l10n updates.
Definition Finder.php:14