@@ -248,6 +248,45 @@ public function testTranslatorMethods()
248
248
$ this ->assertFalse ($ this ->helper ->isTranslatorEnabled ());
249
249
}
250
250
251
+ public function testLabelWillBeTranslatedOnceWithoutId ()
252
+ {
253
+ $ element = new Element ('foo ' );
254
+ $ element ->setLabel ('The value for foo: ' );
255
+
256
+ $ mockTranslator = $ this ->getMock ('Zend\I18n\Translator\Translator ' );
257
+ $ mockTranslator ->expects ($ this ->exactly (1 ))
258
+ ->method ('translate ' )
259
+ ->will ($ this ->returnValue ('translated content ' ));
260
+
261
+ $ this ->helper ->setTranslator ($ mockTranslator );
262
+ $ this ->assertTrue ($ this ->helper ->hasTranslator ());
263
+
264
+ $ markup = $ this ->helper ->__invoke ($ element );
265
+ $ this ->assertContains ('>translated content< ' , $ markup );
266
+ $ this ->assertContains ('<label ' , $ markup );
267
+ $ this ->assertContains ('</label> ' , $ markup );
268
+ }
269
+
270
+ public function testLabelWillBeTranslatedOnceWithId ()
271
+ {
272
+ $ element = new Element ('foo ' );
273
+ $ element ->setLabel ('The value for foo: ' );
274
+ $ element ->setAttribute ('id ' , 'foo ' );
275
+
276
+ $ mockTranslator = $ this ->getMock ('Zend\I18n\Translator\Translator ' );
277
+ $ mockTranslator ->expects ($ this ->exactly (1 ))
278
+ ->method ('translate ' )
279
+ ->will ($ this ->returnValue ('translated content ' ));
280
+
281
+ $ this ->helper ->setTranslator ($ mockTranslator );
282
+ $ this ->assertTrue ($ this ->helper ->hasTranslator ());
283
+
284
+ $ markup = $ this ->helper ->__invoke ($ element );
285
+ $ this ->assertContains ('>translated content< ' , $ markup );
286
+ $ this ->assertContains ('<label ' , $ markup );
287
+ $ this ->assertContains ('</label> ' , $ markup );
288
+ }
289
+
251
290
public function testSetLabelPositionInputNullRaisesException ()
252
291
{
253
292
$ this ->setExpectedException ('Zend\Form\Exception\InvalidArgumentException ' );
0 commit comments