2012-02-01 04:53:55 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @author Amir E. Aharoni
|
|
|
|
|
|
* @copyright Copyright © 2012, Amir E. Aharoni
|
|
|
|
|
|
* @file
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2021-07-31 21:23:21 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @group Language
|
|
|
|
|
|
*/
|
2012-10-23 20:53:17 +00:00
|
|
|
|
class LanguageUkTest extends LanguageClassesTestCase {
|
2013-10-22 10:32:29 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @dataProvider providePlural
|
|
|
|
|
|
* @covers Language::convertPlural
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function testPlural( $result, $value ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
|
$forms = [ 'one', 'few', 'many', 'other' ];
|
2012-10-23 20:53:17 +00:00
|
|
|
|
$this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
|
2012-02-01 04:53:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-12-03 08:37:14 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Test explicit plural forms - n=FormN forms
|
|
|
|
|
|
* @covers Language::convertPlural
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function testExplicitPlural() {
|
2016-02-17 09:09:32 +00:00
|
|
|
|
$forms = [ 'one', 'few', 'many', 'other', '12=dozen' ];
|
2013-12-03 08:37:14 +00:00
|
|
|
|
$this->assertEquals( 'dozen', $this->getLang()->convertPlural( 12, $forms ) );
|
2016-02-17 09:09:32 +00:00
|
|
|
|
$forms = [ 'one', 'few', 'many', '100=hundred', 'other', '12=dozen' ];
|
2013-12-03 08:37:14 +00:00
|
|
|
|
$this->assertEquals( 'hundred', $this->getLang()->convertPlural( 100, $forms ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @dataProvider providePlural
|
|
|
|
|
|
* @covers Language::getPluralRuleType
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function testGetPluralRuleType( $result, $value ) {
|
2013-01-25 01:10:37 +00:00
|
|
|
|
$this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-22 02:12:37 +00:00
|
|
|
|
public static function providePlural() {
|
2016-02-17 09:09:32 +00:00
|
|
|
|
return [
|
|
|
|
|
|
[ 'one', 1 ],
|
|
|
|
|
|
[ 'many', 11 ],
|
|
|
|
|
|
[ 'one', 91 ],
|
|
|
|
|
|
[ 'one', 121 ],
|
|
|
|
|
|
[ 'few', 2 ],
|
|
|
|
|
|
[ 'few', 3 ],
|
|
|
|
|
|
[ 'few', 4 ],
|
|
|
|
|
|
[ 'few', 334 ],
|
|
|
|
|
|
[ 'many', 5 ],
|
|
|
|
|
|
[ 'many', 15 ],
|
|
|
|
|
|
[ 'many', 120 ],
|
|
|
|
|
|
];
|
2012-02-01 04:53:55 +00:00
|
|
|
|
}
|
2013-02-15 10:27:48 +00:00
|
|
|
|
|
2013-10-22 10:32:29 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* @dataProvider providePluralTwoForms
|
|
|
|
|
|
* @covers Language::convertPlural
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function testPluralTwoForms( $result, $value ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
|
$forms = [ '1=one', 'other' ];
|
2012-10-23 20:53:17 +00:00
|
|
|
|
$this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
|
2012-02-01 04:53:55 +00:00
|
|
|
|
}
|
2013-02-15 10:27:48 +00:00
|
|
|
|
|
2013-03-22 02:12:37 +00:00
|
|
|
|
public static function providePluralTwoForms() {
|
2016-02-17 09:09:32 +00:00
|
|
|
|
return [
|
|
|
|
|
|
[ 'one', 1 ],
|
|
|
|
|
|
[ 'other', 11 ],
|
|
|
|
|
|
[ 'other', 91 ],
|
|
|
|
|
|
[ 'other', 121 ],
|
|
|
|
|
|
];
|
2012-02-01 04:53:55 +00:00
|
|
|
|
}
|
2015-09-27 07:34:25 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @dataProvider providerGrammar
|
|
|
|
|
|
* @covers Language::convertGrammar
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function testGrammar( $result, $word, $case ) {
|
|
|
|
|
|
$this->assertEquals( $result, $this->getLang()->convertGrammar( $word, $case ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static function providerGrammar() {
|
2016-02-17 09:09:32 +00:00
|
|
|
|
return [
|
|
|
|
|
|
[
|
2015-09-27 07:34:25 +00:00
|
|
|
|
'Вікіпедії',
|
|
|
|
|
|
'Вікіпедія',
|
|
|
|
|
|
'genitive',
|
2016-02-17 09:09:32 +00:00
|
|
|
|
],
|
|
|
|
|
|
[
|
2015-09-27 07:34:25 +00:00
|
|
|
|
'Віківидів',
|
|
|
|
|
|
'Віківиди',
|
|
|
|
|
|
'genitive',
|
2016-02-17 09:09:32 +00:00
|
|
|
|
],
|
|
|
|
|
|
[
|
2015-09-27 12:21:49 +00:00
|
|
|
|
'Вікіцитат',
|
|
|
|
|
|
'Вікіцитати',
|
|
|
|
|
|
'genitive',
|
2016-02-17 09:09:32 +00:00
|
|
|
|
],
|
|
|
|
|
|
[
|
2015-09-27 12:21:49 +00:00
|
|
|
|
'Вікіпідручника',
|
|
|
|
|
|
'Вікіпідручник',
|
|
|
|
|
|
'genitive',
|
2016-02-17 09:09:32 +00:00
|
|
|
|
],
|
|
|
|
|
|
[
|
2015-09-27 07:34:25 +00:00
|
|
|
|
'Вікіпедію',
|
|
|
|
|
|
'Вікіпедія',
|
|
|
|
|
|
'accusative',
|
2016-02-17 09:09:32 +00:00
|
|
|
|
],
|
2020-06-11 22:02:05 +00:00
|
|
|
|
[
|
|
|
|
|
|
'у MediaWiki',
|
|
|
|
|
|
'MediaWiki',
|
|
|
|
|
|
'locative',
|
|
|
|
|
|
]
|
2016-02-17 09:09:32 +00:00
|
|
|
|
];
|
2015-09-27 07:34:25 +00:00
|
|
|
|
}
|
2012-02-01 04:53:55 +00:00
|
|
|
|
}
|