Follow-up to #13815: Added Testcase for numberFormat (Thanks to Sebastian Michaelsen)
authorSteffen Kamper <info@sk-typo3.de>
Fri, 13 Aug 2010 22:16:37 +0000 (22:16 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Fri, 13 Aug 2010 22:16:37 +0000 (22:16 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@8602 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
tests/typo3/sysext/cms/tslib/tslib_contentTest.php

index 877f06a..76e3938 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-08-13 Steffen Kamper  <steffen@typo3.org>
+
+       * Follow-up to #13815: Added Testcase for numberFormat (Thanks to Sebastian Michaelsen)
+
 2010-08-13  Steffen Gebert  <steffen@steffen-gebert.de>
 
        * Fixed bug #15423: Remove lowlevel page tree (Thanks to Steffen Kamper)
index eea9ea7..74f8892 100644 (file)
@@ -630,5 +630,71 @@ class tslib_contentTest extends tx_phpunit_testcase {
                        $result
                );
        }
+       
+       /**
+        * Data provider for the numberFormat test
+        *
+        * @return array multi-dimensional array with the second level like this:
+        *               0 => the input float number
+        *               1 => the conf array for the numberFormat stdWrap function
+        *               2 => the expected result
+        *
+        * @see numberFormat
+        */
+       public function numberFormatDataProvider() {
+               $data = array(
+                       'testing decimals' => array(
+                               0.8,
+                               array(
+                                       'decimals' => 2
+                               ),
+                               '0.80'
+                       ),
+                       'testing dec_point' => array(
+                               0.8,
+                               array(
+                                       'decimals' => 1,
+                                       'dec_point' => ','
+                               ),
+                               '0,8'
+                       ),
+                       'testing thousands_sep' => array(
+                               999.99,
+                               array(
+                                       'decimals' => 0,
+                                       'thousands_sep.' => array(
+                                               'char' => 46
+                                       )
+                               ),
+                               '1.000'
+                       ),
+                       'testing mixture' => array(
+                               1281731.45,
+                               array(
+                                       'decimals' => 1,
+                                       'dec_point.' => array(
+                                               'char' => 44
+                                       ),
+                                       'thousands_sep.' => array(
+                                               'char' => 46
+                                       )
+                               ),
+                               '1.281.731,5'
+                       )
+               );
+               return $data;
+       }
+       
+       /**
+        * Check if stdWrap.numberFormat and all of its properties work properly
+        *
+        * @dataProvider numberFormatDataProvider
+        *
+        * @test
+        */
+       public function numberFormat($float, $formatConf, $expected) {
+               $result = $this->cObj->numberFormat($float, $formatConf);
+               $this->assertEquals($expected, $result);
+       }
 }
 ?>
\ No newline at end of file