Browse Source

add tests

euromark 12 years ago
parent
commit
d7be29ac11
2 changed files with 35 additions and 2 deletions
  1. 1 2
      Lib/Utility/NumberLib.php
  2. 34 0
      Test/Case/Lib/Utility/NumberLibTest.php

+ 1 - 2
Lib/Utility/NumberLib.php

@@ -80,8 +80,7 @@ class NumberLib extends CakeNumber {
 	 * //TODO: automize per localeconv() ?
 	 *
 	 * @param float $number
-	 * @param integer $places (0 = int, 1..x places after dec, -1..-x places before dec)
-	 * @param array $option : currency=true/false, ... (leave empty for no special treatment)
+	 * @param array $options : currency=true/false, ... (leave empty for no special treatment)
 	 * @return string
 	 */
 	public static function format($number, $formatOptions = array()) {

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

@@ -49,6 +49,11 @@ class NumberLibTest extends MyCakeTestCase {
 		$this->assertSame($expected, $is);
 	}
 
+	/**
+	 * NumberLibTest::testMoney()
+	 *
+	 * @return void
+	 */
 	public function testMoney() {
 		$is = NumberLib::money(22.11);
 		$expected = '22,11 €';
@@ -59,6 +64,11 @@ class NumberLibTest extends MyCakeTestCase {
 		$this->assertSame($expected, $is);
 	}
 
+	/**
+	 * NumberLibTest::testPrice()
+	 *
+	 * @return void
+	 */
 	public function testPrice() {
 		$is = NumberLib::price(22.11);
 		$expected = '22,11 €';
@@ -69,6 +79,11 @@ class NumberLibTest extends MyCakeTestCase {
 		$this->assertSame($expected, $is);
 	}
 
+	/**
+	 * NumberLibTest::testCurrency()
+	 *
+	 * @return void
+	 */
 	public function testCurrency() {
 		$is = NumberLib::currency(22.11);
 		$expected = '22,11 €';
@@ -88,6 +103,25 @@ class NumberLibTest extends MyCakeTestCase {
 	}
 
 	/**
+	 * NumberLibTest::testFormat()
+	 *
+	 * @return void
+	 */
+	public function testFormat() {
+		$is = NumberLib::format(22.11);
+		$expected = '22,11';
+		$this->assertSame($expected, $is);
+
+		$is = NumberLib::format(22933773);
+		$expected = '22.933.773,00';
+		$this->assertSame($expected, $is);
+
+		$is = NumberLib::format(-0.895, array('places' => 3));
+		$expected = '-0,895';
+		$this->assertSame($expected, $is);
+	}
+
+	/**
 	 * @return void
 	 */
 	public function testToPercentage() {