euromark 12 年 前
コミット
3e551bb049
2 ファイル変更19 行追加0 行削除
  1. 13 0
      Lib/Utility/NumberLib.php
  2. 6 0
      Test/Case/Lib/Utility/NumberLibTest.php

+ 13 - 0
Lib/Utility/NumberLib.php

@@ -324,4 +324,17 @@ class NumberLib extends CakeNumber {
 		return ($x + $precision >= $y) && ($x - $precision <= $y);
 		return ($x + $precision >= $y) && ($x - $precision <= $y);
 	}
 	}
 
 
+	/**
+	 * Get the settings for a specific formatName
+	 *
+	 * @param string $formatName (EUR, ...)
+	 * @return array $currencySettings or null on failure
+	 */
+	public function getFormat($formatName) {
+		if (!isset(self::$_currencies[$formatName])) {
+			return null;
+		}
+		return self::$_currencies[$formatName];
+	}
+
 }
 }

+ 6 - 0
Test/Case/Lib/Utility/NumberLibTest.php

@@ -193,6 +193,12 @@ class NumberLibTest extends MyCakeTestCase {
 	 * @return void
 	 * @return void
 	 */
 	 */
 	public function testCurrencySpacer() {
 	public function testCurrencySpacer() {
+		if ((float)Configure::version() < 2.4) {
+			$format = NumberLib::getFormat('GBP');
+			$format['wholeSymbol'] = '£';
+			NumberLib::addFormat('GBP', $format);
+		}
+
 		$result = NumberLib::currency('4.111', 'GBP');
 		$result = NumberLib::currency('4.111', 'GBP');
 		$expected = '£4.11';
 		$expected = '£4.11';
 		$this->assertEquals($expected, $result);
 		$this->assertEquals($expected, $result);