aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/translation/Symfony/Component/Translation/Tests/MessageSelectorTest.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-03 19:26:54 +0200
committerNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-03 19:26:54 +0200
commit4f5b44bd3bd490309eb2ba7b44df4769816ba729 (patch)
tree6cefe170dfe0a5a361cb1e2d1fc4d580a3316d02 /vendor/symfony/translation/Symfony/Component/Translation/Tests/MessageSelectorTest.php
parent2b840e0cfb63a453bea67a98541f3df9c273c5f5 (diff)
downloadwallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.gz
wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.zst
wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.zip
twig implementation
Diffstat (limited to 'vendor/symfony/translation/Symfony/Component/Translation/Tests/MessageSelectorTest.php')
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Tests/MessageSelectorTest.php80
1 files changed, 80 insertions, 0 deletions
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Tests/MessageSelectorTest.php b/vendor/symfony/translation/Symfony/Component/Translation/Tests/MessageSelectorTest.php
new file mode 100644
index 00000000..74956294
--- /dev/null
+++ b/vendor/symfony/translation/Symfony/Component/Translation/Tests/MessageSelectorTest.php
@@ -0,0 +1,80 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Translation\Tests;
13
14use Symfony\Component\Translation\MessageSelector;
15
16class MessageSelectorTest extends \PHPUnit_Framework_TestCase
17{
18 /**
19 * @dataProvider getChooseTests
20 */
21 public function testChoose($expected, $id, $number)
22 {
23 $selector = new MessageSelector();
24
25 $this->assertEquals($expected, $selector->choose($id, $number, 'en'));
26 }
27
28 /**
29 * @expectedException InvalidArgumentException
30 */
31 public function testChooseWhenNoEnoughChoices()
32 {
33 $selector = new MessageSelector();
34
35 $selector->choose('foo', 10, 'en');
36 }
37
38 public function getChooseTests()
39 {
40 return array(
41 array('There is no apples', '{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples', 0),
42 array('There is no apples', '{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples', 0),
43 array('There is no apples', '{0}There is no apples|{1} There is one apple|]1,Inf] There is %count% apples', 0),
44
45 array('There is one apple', '{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples', 1),
46
47 array('There is %count% apples', '{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples', 10),
48 array('There is %count% apples', '{0} There is no apples|{1} There is one apple|]1,Inf]There is %count% apples', 10),
49 array('There is %count% apples', '{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples', 10),
50
51 array('There is %count% apples', 'There is one apple|There is %count% apples', 0),
52 array('There is one apple', 'There is one apple|There is %count% apples', 1),
53 array('There is %count% apples', 'There is one apple|There is %count% apples', 10),
54
55 array('There is %count% apples', 'one: There is one apple|more: There is %count% apples', 0),
56 array('There is one apple', 'one: There is one apple|more: There is %count% apples', 1),
57 array('There is %count% apples', 'one: There is one apple|more: There is %count% apples', 10),
58
59 array('There is no apples', '{0} There is no apples|one: There is one apple|more: There is %count% apples', 0),
60 array('There is one apple', '{0} There is no apples|one: There is one apple|more: There is %count% apples', 1),
61 array('There is %count% apples', '{0} There is no apples|one: There is one apple|more: There is %count% apples', 10),
62
63 array('', '{0}|{1} There is one apple|]1,Inf] There is %count% apples', 0),
64 array('', '{0} There is no apples|{1}|]1,Inf] There is %count% apples', 1),
65
66 // Indexed only tests which are Gettext PoFile* compatible strings.
67 array('There are %count% apples', 'There is one apple|There are %count% apples', 0),
68 array('There is one apple', 'There is one apple|There are %count% apples', 1),
69 array('There are %count% apples', 'There is one apple|There are %count% apples', 2),
70
71 // Tests for float numbers
72 array('There is almost one apple', '{0} There is no apples|]0,1[ There is almost one apple|{1} There is one apple|[1,Inf] There is more than one apple', 0.7),
73 array('There is one apple', '{0} There is no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 1),
74 array('There is more than one apple', '{0} There is no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 1.7),
75 array('There is no apples', '{0} There is no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0),
76 array('There is no apples', '{0} There is no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0.0),
77 array('There is no apples', '{0.0} There is no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0),
78 );
79 }
80}