Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit b70f259

Browse files
committed
Merge branch 'froschdesign-hotfix/536'
2 parents 0cef832 + aa10640 commit b70f259

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

library/Zend/Measure/Number.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,12 @@ public function setType($type)
415415
public function convertTo($type, $round = 0, $locale = null)
416416
{
417417
$this->setType($type);
418+
419+
// Roman numerals do not need a formatting
420+
if ($this->getType() === self::ROMAN) {
421+
return $this->_value;
422+
}
423+
418424
return $this->toString($round, $locale);
419425
}
420426
}

tests/Zend/Measure/NumberTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,44 @@ public function testConvertTo()
254254
$value = new Zend_Measure_Number('_X',Zend_Measure_Number::ROMAN, 'en');
255255
$this->assertEquals('10,000 ⑽', $value->convertTo(Zend_Measure_Number::DECIMAL));
256256
}
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+
}
257297
}

0 commit comments

Comments
 (0)