This repository was archived by the owner on Oct 2, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -415,6 +415,12 @@ public function setType($type)
415
415
public function convertTo ($ type , $ round = 0 , $ locale = null )
416
416
{
417
417
$ this ->setType ($ type );
418
+
419
+ // Roman numerals do not need a formatting
420
+ if ($ this ->getType () === self ::ROMAN ) {
421
+ return $ this ->_value ;
422
+ }
423
+
418
424
return $ this ->toString ($ round , $ locale );
419
425
}
420
426
}
Original file line number Diff line number Diff line change @@ -254,4 +254,44 @@ public function testConvertTo()
254
254
$ value = new Zend_Measure_Number ('_X ' ,Zend_Measure_Number::ROMAN , 'en ' );
255
255
$ this ->assertEquals ('10,000 ⑽ ' , $ value ->convertTo (Zend_Measure_Number::DECIMAL ));
256
256
}
257
+
258
+ /**
259
+ * @dataProvider providerConvertingDecimalToRoman
260
+ * @group GH-536
261
+ */
262
+ public function testConvertingDecimalToRoman ($ decimal , $ roman )
263
+ {
264
+ $ number = new Zend_Measure_Number (
265
+ $ decimal ,
266
+ Zend_Measure_Number::DECIMAL ,
267
+ null
268
+ );
269
+
270
+ $ this ->assertEquals (
271
+ $ roman ,
272
+ $ number ->convertTo (Zend_Measure_Number::ROMAN )
273
+ );
274
+ }
275
+
276
+ /**
277
+ * Data provider for testConvertingDecimalToRoman
278
+ * @group GH-536
279
+ * @return array
280
+ */
281
+ public function providerConvertingDecimalToRoman ()
282
+ {
283
+ return array (
284
+ array (10 , 'X ' ),
285
+ array (11 , 'XI ' ),
286
+ array (12 , 'XII ' ),
287
+ array (13 , 'XIII ' ),
288
+ array (14 , 'XIV ' ),
289
+ array (15 , 'XV ' ),
290
+ array (16 , 'XVI ' ),
291
+ array (17 , 'XVII ' ),
292
+ array (18 , 'XVIII ' ),
293
+ array (19 , 'XIX ' ),
294
+ array (20 , 'XX ' ),
295
+ );
296
+ }
257
297
}
You can’t perform that action at this time.
0 commit comments