summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'MLEB/Translate/tests/phpunit/mocks/MockWikiMessageGroup.php')
-rw-r--r--MLEB/Translate/tests/phpunit/mocks/MockWikiMessageGroup.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/MLEB/Translate/tests/phpunit/mocks/MockWikiMessageGroup.php b/MLEB/Translate/tests/phpunit/mocks/MockWikiMessageGroup.php
new file mode 100644
index 00000000..ad257d57
--- /dev/null
+++ b/MLEB/Translate/tests/phpunit/mocks/MockWikiMessageGroup.php
@@ -0,0 +1,59 @@
+<?php
+/**
+ * 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 MessageValidator( $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;
+ }
+}