updated packages
This commit is contained in:
@@ -55,7 +55,7 @@ class TranslatorTest extends TestCase
|
||||
$translator = $this->getTranslator();
|
||||
$translator->setLocale('en');
|
||||
|
||||
$this->assertEquals($expected, $translator->trans($id, array('%count%' => $number)));
|
||||
$this->assertEquals($expected, $translator->trans($id, ['%count%' => $number]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +67,7 @@ class TranslatorTest extends TestCase
|
||||
|
||||
$translator = $this->getTranslator();
|
||||
|
||||
$this->assertEquals($expected, $translator->trans($id, array('%count%' => $number)));
|
||||
$this->assertEquals($expected, $translator->trans($id, ['%count%' => $number]));
|
||||
}
|
||||
|
||||
public function testGetSetLocale()
|
||||
@@ -94,24 +94,24 @@ class TranslatorTest extends TestCase
|
||||
|
||||
public function getTransTests()
|
||||
{
|
||||
return array(
|
||||
array('Symfony is great!', 'Symfony is great!', array()),
|
||||
array('Symfony is awesome!', 'Symfony is %what%!', array('%what%' => 'awesome')),
|
||||
);
|
||||
return [
|
||||
['Symfony is great!', 'Symfony is great!', []],
|
||||
['Symfony is awesome!', 'Symfony is %what%!', ['%what%' => 'awesome']],
|
||||
];
|
||||
}
|
||||
|
||||
public function getTransChoiceTests()
|
||||
{
|
||||
return array(
|
||||
array('There are no apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 0),
|
||||
array('There is one apple', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 1),
|
||||
array('There are 10 apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 10),
|
||||
array('There are 0 apples', 'There is 1 apple|There are %count% apples', 0),
|
||||
array('There is 1 apple', 'There is 1 apple|There are %count% apples', 1),
|
||||
array('There are 10 apples', 'There is 1 apple|There are %count% apples', 10),
|
||||
return [
|
||||
['There are no apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 0],
|
||||
['There is one apple', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 1],
|
||||
['There are 10 apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 10],
|
||||
['There are 0 apples', 'There is 1 apple|There are %count% apples', 0],
|
||||
['There is 1 apple', 'There is 1 apple|There are %count% apples', 1],
|
||||
['There are 10 apples', 'There is 1 apple|There are %count% apples', 10],
|
||||
// custom validation messages may be coded with a fixed value
|
||||
array('There are 2 apples', 'There are 2 apples', 2),
|
||||
);
|
||||
['There are 2 apples', 'There are 2 apples', 2],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,22 +121,22 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
|
||||
$this->assertEquals($expected, $translator->trans($interval.' foo|[1,Inf[ bar', array('%count%' => $number)));
|
||||
$this->assertEquals($expected, $translator->trans($interval.' foo|[1,Inf[ bar', ['%count%' => $number]));
|
||||
}
|
||||
|
||||
public function getInternal()
|
||||
{
|
||||
return array(
|
||||
array('foo', 3, '{1,2, 3 ,4}'),
|
||||
array('bar', 10, '{1,2, 3 ,4}'),
|
||||
array('bar', 3, '[1,2]'),
|
||||
array('foo', 1, '[1,2]'),
|
||||
array('foo', 2, '[1,2]'),
|
||||
array('bar', 1, ']1,2['),
|
||||
array('bar', 2, ']1,2['),
|
||||
array('foo', log(0), '[-Inf,2['),
|
||||
array('foo', -log(0), '[-2,+Inf]'),
|
||||
);
|
||||
return [
|
||||
['foo', 3, '{1,2, 3 ,4}'],
|
||||
['bar', 10, '{1,2, 3 ,4}'],
|
||||
['bar', 3, '[1,2]'],
|
||||
['foo', 1, '[1,2]'],
|
||||
['foo', 2, '[1,2]'],
|
||||
['bar', 1, ']1,2['],
|
||||
['bar', 2, ']1,2['],
|
||||
['foo', log(0), '[-Inf,2['],
|
||||
['foo', -log(0), '[-2,+Inf]'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,14 +146,14 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
|
||||
$this->assertEquals($expected, $translator->trans($id, array('%count%' => $number)));
|
||||
$this->assertEquals($expected, $translator->trans($id, ['%count%' => $number]));
|
||||
}
|
||||
|
||||
public function testReturnMessageIfExactlyOneStandardRuleIsGiven()
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
|
||||
$this->assertEquals('There are two apples', $translator->trans('There are two apples', array('%count%' => 2)));
|
||||
$this->assertEquals('There are two apples', $translator->trans('There are two apples', ['%count%' => 2]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,98 +164,98 @@ class TranslatorTest extends TestCase
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
|
||||
$translator->trans($id, array('%count%' => $number));
|
||||
$translator->trans($id, ['%count%' => $number]);
|
||||
}
|
||||
|
||||
public function getNonMatchingMessages()
|
||||
{
|
||||
return array(
|
||||
array('{0} There are no apples|{1} There is one apple', 2),
|
||||
array('{1} There is one apple|]1,Inf] There are %count% apples', 0),
|
||||
array('{1} There is one apple|]2,Inf] There are %count% apples', 2),
|
||||
array('{0} There are no apples|There is one apple', 2),
|
||||
);
|
||||
return [
|
||||
['{0} There are no apples|{1} There is one apple', 2],
|
||||
['{1} There is one apple|]1,Inf] There are %count% apples', 0],
|
||||
['{1} There is one apple|]2,Inf] There are %count% apples', 2],
|
||||
['{0} There are no apples|There is one apple', 2],
|
||||
];
|
||||
}
|
||||
|
||||
public function getChooseTests()
|
||||
{
|
||||
return array(
|
||||
array('There are no apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 0),
|
||||
array('There are no apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 0),
|
||||
array('There are no apples', '{0}There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 0),
|
||||
return [
|
||||
['There are no apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 0],
|
||||
['There are no apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 0],
|
||||
['There are no apples', '{0}There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 0],
|
||||
|
||||
array('There is one apple', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 1),
|
||||
['There is one apple', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 1],
|
||||
|
||||
array('There are 10 apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 10),
|
||||
array('There are 10 apples', '{0} There are no apples|{1} There is one apple|]1,Inf]There are %count% apples', 10),
|
||||
array('There are 10 apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 10),
|
||||
['There are 10 apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 10],
|
||||
['There are 10 apples', '{0} There are no apples|{1} There is one apple|]1,Inf]There are %count% apples', 10],
|
||||
['There are 10 apples', '{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples', 10],
|
||||
|
||||
array('There are 0 apples', 'There is one apple|There are %count% apples', 0),
|
||||
array('There is one apple', 'There is one apple|There are %count% apples', 1),
|
||||
array('There are 10 apples', 'There is one apple|There are %count% apples', 10),
|
||||
['There are 0 apples', 'There is one apple|There are %count% apples', 0],
|
||||
['There is one apple', 'There is one apple|There are %count% apples', 1],
|
||||
['There are 10 apples', 'There is one apple|There are %count% apples', 10],
|
||||
|
||||
array('There are 0 apples', 'one: There is one apple|more: There are %count% apples', 0),
|
||||
array('There is one apple', 'one: There is one apple|more: There are %count% apples', 1),
|
||||
array('There are 10 apples', 'one: There is one apple|more: There are %count% apples', 10),
|
||||
['There are 0 apples', 'one: There is one apple|more: There are %count% apples', 0],
|
||||
['There is one apple', 'one: There is one apple|more: There are %count% apples', 1],
|
||||
['There are 10 apples', 'one: There is one apple|more: There are %count% apples', 10],
|
||||
|
||||
array('There are no apples', '{0} There are no apples|one: There is one apple|more: There are %count% apples', 0),
|
||||
array('There is one apple', '{0} There are no apples|one: There is one apple|more: There are %count% apples', 1),
|
||||
array('There are 10 apples', '{0} There are no apples|one: There is one apple|more: There are %count% apples', 10),
|
||||
['There are no apples', '{0} There are no apples|one: There is one apple|more: There are %count% apples', 0],
|
||||
['There is one apple', '{0} There are no apples|one: There is one apple|more: There are %count% apples', 1],
|
||||
['There are 10 apples', '{0} There are no apples|one: There is one apple|more: There are %count% apples', 10],
|
||||
|
||||
array('', '{0}|{1} There is one apple|]1,Inf] There are %count% apples', 0),
|
||||
array('', '{0} There are no apples|{1}|]1,Inf] There are %count% apples', 1),
|
||||
['', '{0}|{1} There is one apple|]1,Inf] There are %count% apples', 0],
|
||||
['', '{0} There are no apples|{1}|]1,Inf] There are %count% apples', 1],
|
||||
|
||||
// Indexed only tests which are Gettext PoFile* compatible strings.
|
||||
array('There are 0 apples', 'There is one apple|There are %count% apples', 0),
|
||||
array('There is one apple', 'There is one apple|There are %count% apples', 1),
|
||||
array('There are 2 apples', 'There is one apple|There are %count% apples', 2),
|
||||
['There are 0 apples', 'There is one apple|There are %count% apples', 0],
|
||||
['There is one apple', 'There is one apple|There are %count% apples', 1],
|
||||
['There are 2 apples', 'There is one apple|There are %count% apples', 2],
|
||||
|
||||
// Tests for float numbers
|
||||
array('There is almost one apple', '{0} There are no apples|]0,1[ There is almost one apple|{1} There is one apple|[1,Inf] There is more than one apple', 0.7),
|
||||
array('There is one apple', '{0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 1),
|
||||
array('There is more than one apple', '{0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 1.7),
|
||||
array('There are no apples', '{0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0),
|
||||
array('There are no apples', '{0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0.0),
|
||||
array('There are no apples', '{0.0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0),
|
||||
['There is almost one apple', '{0} There are no apples|]0,1[ There is almost one apple|{1} There is one apple|[1,Inf] There is more than one apple', 0.7],
|
||||
['There is one apple', '{0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 1],
|
||||
['There is more than one apple', '{0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 1.7],
|
||||
['There are no apples', '{0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0],
|
||||
['There are no apples', '{0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0.0],
|
||||
['There are no apples', '{0.0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0],
|
||||
|
||||
// Test texts with new-lines
|
||||
// with double-quotes and \n in id & double-quotes and actual newlines in text
|
||||
array("This is a text with a\n new-line in it. Selector = 0.", '{0}This is a text with a
|
||||
["This is a text with a\n new-line in it. Selector = 0.", '{0}This is a text with a
|
||||
new-line in it. Selector = 0.|{1}This is a text with a
|
||||
new-line in it. Selector = 1.|[1,Inf]This is a text with a
|
||||
new-line in it. Selector > 1.', 0),
|
||||
new-line in it. Selector > 1.', 0],
|
||||
// with double-quotes and \n in id and single-quotes and actual newlines in text
|
||||
array("This is a text with a\n new-line in it. Selector = 1.", '{0}This is a text with a
|
||||
["This is a text with a\n new-line in it. Selector = 1.", '{0}This is a text with a
|
||||
new-line in it. Selector = 0.|{1}This is a text with a
|
||||
new-line in it. Selector = 1.|[1,Inf]This is a text with a
|
||||
new-line in it. Selector > 1.', 1),
|
||||
array("This is a text with a\n new-line in it. Selector > 1.", '{0}This is a text with a
|
||||
new-line in it. Selector > 1.', 1],
|
||||
["This is a text with a\n new-line in it. Selector > 1.", '{0}This is a text with a
|
||||
new-line in it. Selector = 0.|{1}This is a text with a
|
||||
new-line in it. Selector = 1.|[1,Inf]This is a text with a
|
||||
new-line in it. Selector > 1.', 5),
|
||||
new-line in it. Selector > 1.', 5],
|
||||
// with double-quotes and id split accros lines
|
||||
array('This is a text with a
|
||||
['This is a text with a
|
||||
new-line in it. Selector = 1.', '{0}This is a text with a
|
||||
new-line in it. Selector = 0.|{1}This is a text with a
|
||||
new-line in it. Selector = 1.|[1,Inf]This is a text with a
|
||||
new-line in it. Selector > 1.', 1),
|
||||
new-line in it. Selector > 1.', 1],
|
||||
// with single-quotes and id split accros lines
|
||||
array('This is a text with a
|
||||
['This is a text with a
|
||||
new-line in it. Selector > 1.', '{0}This is a text with a
|
||||
new-line in it. Selector = 0.|{1}This is a text with a
|
||||
new-line in it. Selector = 1.|[1,Inf]This is a text with a
|
||||
new-line in it. Selector > 1.', 5),
|
||||
new-line in it. Selector > 1.', 5],
|
||||
// with single-quotes and \n in text
|
||||
array('This is a text with a\nnew-line in it. Selector = 0.', '{0}This is a text with a\nnew-line in it. Selector = 0.|{1}This is a text with a\nnew-line in it. Selector = 1.|[1,Inf]This is a text with a\nnew-line in it. Selector > 1.', 0),
|
||||
['This is a text with a\nnew-line in it. Selector = 0.', '{0}This is a text with a\nnew-line in it. Selector = 0.|{1}This is a text with a\nnew-line in it. Selector = 1.|[1,Inf]This is a text with a\nnew-line in it. Selector > 1.', 0],
|
||||
// with double-quotes and id split accros lines
|
||||
array("This is a text with a\nnew-line in it. Selector = 1.", "{0}This is a text with a\nnew-line in it. Selector = 0.|{1}This is a text with a\nnew-line in it. Selector = 1.|[1,Inf]This is a text with a\nnew-line in it. Selector > 1.", 1),
|
||||
["This is a text with a\nnew-line in it. Selector = 1.", "{0}This is a text with a\nnew-line in it. Selector = 0.|{1}This is a text with a\nnew-line in it. Selector = 1.|[1,Inf]This is a text with a\nnew-line in it. Selector > 1.", 1],
|
||||
// esacape pipe
|
||||
array('This is a text with | in it. Selector = 0.', '{0}This is a text with || in it. Selector = 0.|{1}This is a text with || in it. Selector = 1.', 0),
|
||||
['This is a text with | in it. Selector = 0.', '{0}This is a text with || in it. Selector = 0.|{1}This is a text with || in it. Selector = 1.', 0],
|
||||
// Empty plural set (2 plural forms) from a .PO file
|
||||
array('', '|', 1),
|
||||
['', '|', 1],
|
||||
// Empty plural set (3 plural forms) from a .PO file
|
||||
array('', '||', 1),
|
||||
);
|
||||
['', '||', 1],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -285,13 +285,13 @@ class TranslatorTest extends TestCase
|
||||
*/
|
||||
public function successLangcodes()
|
||||
{
|
||||
return array(
|
||||
array('1', array('ay', 'bo', 'cgg', 'dz', 'id', 'ja', 'jbo', 'ka', 'kk', 'km', 'ko', 'ky')),
|
||||
array('2', array('nl', 'fr', 'en', 'de', 'de_GE', 'hy', 'hy_AM')),
|
||||
array('3', array('be', 'bs', 'cs', 'hr')),
|
||||
array('4', array('cy', 'mt', 'sl')),
|
||||
array('6', array('ar')),
|
||||
);
|
||||
return [
|
||||
['1', ['ay', 'bo', 'cgg', 'dz', 'id', 'ja', 'jbo', 'ka', 'kk', 'km', 'ko', 'ky']],
|
||||
['2', ['nl', 'fr', 'en', 'de', 'de_GE', 'hy', 'hy_AM']],
|
||||
['3', ['be', 'bs', 'cs', 'hr']],
|
||||
['4', ['cy', 'mt', 'sl']],
|
||||
['6', ['ar']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -304,13 +304,13 @@ class TranslatorTest extends TestCase
|
||||
*/
|
||||
public function failingLangcodes()
|
||||
{
|
||||
return array(
|
||||
array('1', array('fa')),
|
||||
array('2', array('jbo')),
|
||||
array('3', array('cbs')),
|
||||
array('4', array('gd', 'kw')),
|
||||
array('5', array('ga')),
|
||||
);
|
||||
return [
|
||||
['1', ['fa']],
|
||||
['2', ['jbo']],
|
||||
['3', ['cbs']],
|
||||
['4', ['gd', 'kw']],
|
||||
['5', ['ga']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -340,7 +340,7 @@ class TranslatorTest extends TestCase
|
||||
}
|
||||
};
|
||||
|
||||
$matrix = array();
|
||||
$matrix = [];
|
||||
foreach ($langCodes as $langCode) {
|
||||
for ($count = 0; $count < 200; ++$count) {
|
||||
$plural = $translator->getPluralizationRule($count, $langCode);
|
||||
|
||||
Reference in New Issue
Block a user