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
|
<?php
use MediaWiki\Extension\Translate\Validation\ValidationRunner;
/**
* This file contains multiple unmanaged message group implementation.
*
* @file
* @author Niklas Laxström
* @author Siebrand Mazeland
* @copyright Copyright © 2008-2013, Niklas Laxström, Siebrand Mazeland
* @license GPL-2.0-or-later
*/
class MockWikiMessageGroup extends WikiMessageGroup {
public function __construct( $id, array $messages ) {
parent::__construct( $id, 'unused' );
$this->id = $id;
$this->messages = $messages;
}
public function getDefinitions() {
return $this->messages;
}
public function getMessage( $key, $code ) {
if ( $code === $this->getSourceLanguage() ) {
return $this->messages[strtolower( $key )] ?? null;
}
parent::getMessage( $key, $code );
}
}
/**
* Has validators that always return a validation error and warning.
*/
class MockWikiValidationMessageGroup extends MockWikiMessageGroup {
public function getValidator() {
$validator = new ValidationRunner( $this->getId() );
$validator->setValidators( [
[ 'class' => AnotherMockTranslateValidator::class ],
[
'class' => MockTranslateValidator::class,
'enforce' => true,
'keymatch' => [
'translated',
'untranslated',
[
'type' => 'regex',
'pattern' => '/regex-key/'
],
[
'type' => 'wildcard',
'pattern' => '*translated*'
]
]
],
] );
return $validator;
}
}
|