File: LocalisationCacheTest.php

package info (click to toggle)
mediawiki 1%3A1.43.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 417,464 kB
  • sloc: php: 1,062,949; javascript: 664,290; sql: 9,714; python: 5,458; xml: 3,489; sh: 1,131; makefile: 64
file content (46 lines) | stat: -rw-r--r-- 1,595 bytes parent folder | download
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' );
		}
	}

}