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
|
<?php
declare( strict_types = 1 );
namespace MediaWiki\Tests\Unit\Language;
use LocalisationCache;
use MediaWikiUnitTestCase;
use Wikimedia\TestingAccessWrapper;
/**
* @covers LocalisationCache
* @group Language
*/
class LocalisationCacheTest extends MediaWikiUnitTestCase {
public function testAllKeysSplitIntoCoreOnlyAndNonCoreOnly(): void {
$coreOnlyKeys = TestingAccessWrapper::constant( LocalisationCache::class, 'CORE_ONLY_KEYS' );
$allExceptCoreOnlyKeys = TestingAccessWrapper::constant( LocalisationCache::class, 'ALL_EXCEPT_CORE_ONLY_KEYS' );
$this->assertSame( [],
array_diff( $coreOnlyKeys, LocalisationCache::ALL_KEYS ),
'core-only keys must be subset of all keys' );
$this->assertSame( [],
array_diff( $allExceptCoreOnlyKeys, LocalisationCache::ALL_KEYS ),
'keys that are not core-only must be subset of all keys' );
$this->assertSame( [],
array_intersect( $coreOnlyKeys, $allExceptCoreOnlyKeys ),
'core-only and other keys must not overlap' );
$this->assertSame( [],
array_diff( LocalisationCache::ALL_KEYS, array_merge(
$coreOnlyKeys,
$allExceptCoreOnlyKeys
) ),
'core-only keys + all keys except them must contain all keys' );
}
public function testCoreOnlyKeysNotMergeable(): void {
$coreOnlyKeys = TestingAccessWrapper::constant( LocalisationCache::class, 'CORE_ONLY_KEYS' );
$lc = TestingAccessWrapper::newFromClass( LocalisationCache::class );
foreach ( $coreOnlyKeys as $key ) {
$this->assertFalse( $lc->isMergeableKey( $key ),
'it does not make sense for core-only keys to be mergeable' );
}
}
}
|