Browse Source

added test cases for ordinal helper

Ritesh Pandey 10 years ago
parent
commit
7cc2dc4b8f
1 changed files with 28 additions and 0 deletions
  1. 28 0
      tests/TestCase/I18n/NumberTest.php

+ 28 - 0
tests/TestCase/I18n/NumberTest.php

@@ -538,4 +538,32 @@ class NumberTest extends TestCase
         $result = $this->Number->toReadableSize(512.05 * 1024 * 1024 * 1024);
         $this->assertEquals('512,05 GB', $result);
     }
+    
+    /**
+     * test ordinal() with locales
+     *
+     * @return void
+     */
+    public function testOrdinal()
+    {
+        I18n::locale('en_US');
+        $result = $this->Number->ordinal(1);
+        $this->assertEquals('1st', $result);
+
+        $result = $this->Number->toReadableSize(2);
+        $this->assertEquals('2nd', $result);
+
+        $result = $this->Number->toReadableSize(3);
+        $this->assertEquals('3rd', $result);
+
+        $result = $this->Number->toReadableSize(4);
+        $this->assertEquals('4th', $result);
+
+        I18n::locale('fr_FR');
+        $result = $this->Number->toReadableSize(1);
+        $this->assertEquals('1er', $result);
+
+        $result = $this->Number->toReadableSize(2);
+        $this->assertEquals('2e', $result);
+    }
 }