@@ -52,14 +52,25 @@ public function testTransWithoutCaching()
52
52
$ this ->assertEquals ('foo (FR) ' , $ translator ->trans ('foo ' ));
53
53
$ this ->assertEquals ('bar (EN) ' , $ translator ->trans ('bar ' ));
54
54
$ this ->assertEquals ('foobar (ES) ' , $ translator ->trans ('foobar ' ));
55
- $ this ->assertEquals ('choice 0 (EN) ' , $ translator ->transChoice ('choice ' , 0 ));
56
55
$ this ->assertEquals ('no translation ' , $ translator ->trans ('no translation ' ));
57
56
$ this ->assertEquals ('foobarfoo (PT-PT) ' , $ translator ->trans ('foobarfoo ' ));
58
- $ this ->assertEquals ('other choice 1 (PT-BR) ' , $ translator ->transChoice ('other choice ' , 1 ));
59
57
$ this ->assertEquals ('foobarbaz (fr.UTF-8) ' , $ translator ->trans ('foobarbaz ' ));
60
58
$ this ->assertEquals ('foobarbax (sr@latin) ' , $ translator ->trans ('foobarbax ' ));
61
59
}
62
60
61
+ /**
62
+ * @group legacy
63
+ */
64
+ public function testTransChoiceWithoutCaching ()
65
+ {
66
+ $ translator = $ this ->getTranslator ($ this ->getLoader ());
67
+ $ translator ->setLocale ('fr ' );
68
+ $ translator ->setFallbackLocales (array ('en ' , 'es ' , 'pt-PT ' , 'pt_BR ' , 'fr.UTF-8 ' , 'sr@latin ' ));
69
+
70
+ $ this ->assertEquals ('choice 0 (EN) ' , $ translator ->transChoice ('choice ' , 0 ));
71
+ $ this ->assertEquals ('other choice 1 (PT-BR) ' , $ translator ->transChoice ('other choice ' , 1 ));
72
+ }
73
+
63
74
public function testTransWithCaching ()
64
75
{
65
76
// prime the cache
@@ -70,10 +81,8 @@ public function testTransWithCaching()
70
81
$ this ->assertEquals ('foo (FR) ' , $ translator ->trans ('foo ' ));
71
82
$ this ->assertEquals ('bar (EN) ' , $ translator ->trans ('bar ' ));
72
83
$ this ->assertEquals ('foobar (ES) ' , $ translator ->trans ('foobar ' ));
73
- $ this ->assertEquals ('choice 0 (EN) ' , $ translator ->transChoice ('choice ' , 0 ));
74
84
$ this ->assertEquals ('no translation ' , $ translator ->trans ('no translation ' ));
75
85
$ this ->assertEquals ('foobarfoo (PT-PT) ' , $ translator ->trans ('foobarfoo ' ));
76
- $ this ->assertEquals ('other choice 1 (PT-BR) ' , $ translator ->transChoice ('other choice ' , 1 ));
77
86
$ this ->assertEquals ('foobarbaz (fr.UTF-8) ' , $ translator ->trans ('foobarbaz ' ));
78
87
$ this ->assertEquals ('foobarbax (sr@latin) ' , $ translator ->trans ('foobarbax ' ));
79
88
@@ -88,14 +97,37 @@ public function testTransWithCaching()
88
97
$ this ->assertEquals ('foo (FR) ' , $ translator ->trans ('foo ' ));
89
98
$ this ->as
A3E2
sertEquals ('bar (EN) ' , $ translator ->trans ('bar ' ));
90
99
$ this ->assertEquals ('foobar (ES) ' , $ translator ->trans ('foobar ' ));
91
- $ this ->assertEquals ('choice 0 (EN) ' , $ translator ->transChoice ('choice ' , 0 ));
92
100
$ this ->assertEquals ('no translation ' , $ translator ->trans ('no translation ' ));
93
101
$ this ->assertEquals ('foobarfoo (PT-PT) ' , $ translator ->trans ('foobarfoo ' ));
94
- $ this ->assertEquals ('other choice 1 (PT-BR) ' , $ translator ->transChoice ('other choice ' , 1 ));
95
102
$ this ->assertEquals ('foobarbaz (fr.UTF-8) ' , $ translator ->trans ('foobarbaz ' ));
96
103
$ this ->assertEquals ('foobarbax (sr@latin) ' , $ translator ->trans ('foobarbax ' ));
97
104
}
98
105
106
+ /**
107
+ * @group legacy
108
+ */
109
+ public function testTransChoiceWithCaching ()
110
+ {
111
+ // prime the cache
112
+ $ translator = $ this ->getTranslator ($ this ->getLoader (), array ('cache_dir ' => $ this ->tmpDir ));
113
+ $ translator ->setLocale ('fr ' );
114
+ $ translator ->setFallbackLocales (array ('en ' , 'es ' , 'pt-PT ' , 'pt_BR ' , 'fr.UTF-8 ' , 'sr@latin ' ));
115
+
116
+ $ this ->assertEquals ('choice 0 (EN) ' , $ translator ->transChoice ('choice ' , 0 ));
117
+ $ this ->assertEquals ('other choice 1 (PT-BR) ' , $ translator ->transChoice ('other choice ' , 1 ));
118
+
119
+ // do it another time as the cache is primed now
120
+ $ loader = $ this ->getMockBuilder ('Symfony\Component\Translation\Loader\LoaderInterface ' )->getMock ();
121
+ $ loader ->expects ($ this ->never ())->method ('load ' );
122
+
123
+ $ translator = $ this ->getTranslator ($ loader , array ('cache_dir ' => $ this ->tmpDir ));
124
+ $ translator ->setLocale ('fr ' );
125
+ $ translator ->setFallbackLocales (array ('en ' , 'es ' , 'pt-PT ' , 'pt_BR ' , 'fr.UTF-8 ' , 'sr@latin ' ));
126
+
127
+ $ this ->assertEquals ('choice 0 (EN) ' , $ translator ->transChoice ('choice ' , 0 ));
128
+ $ this ->assertEquals ('other choice 1 (PT-BR) ' , $ translator ->transChoice ('other choice ' , 1 ));
129
+ }
130
+
99
131
/**
100
132
* @expectedException \InvalidArgumentException
101
133
* @expectedExceptionMessage Invalid "invalid locale" locale.
0 commit comments