diff options
Diffstat (limited to 'MLEB/Translate/tests/phpunit/unit/MessageValidator/Validators/GettextPluralValidatorTest.php')
-rw-r--r-- | MLEB/Translate/tests/phpunit/unit/MessageValidator/Validators/GettextPluralValidatorTest.php | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/MLEB/Translate/tests/phpunit/unit/MessageValidator/Validators/GettextPluralValidatorTest.php b/MLEB/Translate/tests/phpunit/unit/MessageValidator/Validators/GettextPluralValidatorTest.php new file mode 100644 index 00000000..da81da39 --- /dev/null +++ b/MLEB/Translate/tests/phpunit/unit/MessageValidator/Validators/GettextPluralValidatorTest.php @@ -0,0 +1,54 @@ +<?php +declare( strict_types = 1 ); + +use MediaWiki\Extensions\Translate\MessageValidator\Validators\GettextPluralValidator; + +/** + * @author Niklas Laxström + * @license GPL-2.0-or-later + * @covers \MediaWiki\Extensions\Translate\MessageValidator\Validators\GettextPluralValidator + */ +class GettextPluralValidatorTest extends BaseValidatorTestCase { + /** @dataProvider provideTestCases */ + public function test( ...$params ) { + $this->runValidatorTests( new GettextPluralValidator(), 'plural', ...$params ); + } + + public function provideTestCases() { + // Note that BaseValidatorTestCase uses 'fr' as target language + yield [ + '{{PLURAL:GETTEXT|meter|meters}}', + '{{PLURAL:GETTEXT|metre|metres}}', + [], + 'Correct number of plural forms is not an issue' + ]; + + yield [ + '{{PLURAL:GETTEXT|meter|meters}}', + '{{PLURAL:GETTEXT|metre|metres|so many metres}}', + [ 'forms' ], + 'Extra plural form is an issue' + ]; + + yield [ + '{{PLURAL:GETTEXT|meter|meters}}', + '{{PLURAL:GETTEXT|metres}}', + [ 'forms' ], + 'Missing plural form is an issue' + ]; + + yield [ + '{{PLURAL:GETTEXT|meter|meters}}', + 'metres', + [ 'missing' ], + 'Missing plural is an issue' + ]; + + yield [ + 'meters', + '{{PLURAL:GETTEXT|meter|meters}}', + [ 'unsupported' ], + 'Plural in translation when lacking in the source an issue' + ]; + } +} |