Merge "jquery.tablesorter: Improve detection and handling of isoDate"
[lhc/web/wiklou.git] / tests / phpunit / includes / FormOptionsTest.php
index 0a13cfe..2ee8b98 100644 (file)
@@ -10,7 +10,6 @@
 
 /**
  * Test class for FormOptions methods.
- * Generated by PHPUnit on 2011-02-28 at 20:46:27.
  *
  * Copyright © 2011, Antoine Musso
  *
@@ -34,6 +33,7 @@ class FormOptionsTest extends MediaWikiTestCase {
                $this->object->add( 'string1', 'string one' );
                $this->object->add( 'string2', 'string two' );
                $this->object->add( 'integer', 0 );
+               $this->object->add( 'float', 0.0 );
                $this->object->add( 'intnull', 0, FormOptions::INTNULL );
        }
 
@@ -45,9 +45,15 @@ class FormOptionsTest extends MediaWikiTestCase {
        private function assertGuessInt( $data ) {
                $this->guess( FormOptions::INT, $data );
        }
+       private function assertGuessFloat( $data ) {
+               $this->guess( FormOptions::FLOAT, $data );
+       }
        private function assertGuessString( $data ) {
                $this->guess( FormOptions::STRING, $data );
        }
+       private function assertGuessArray( $data ) {
+               $this->guess( FormOptions::ARR, $data );
+       }
 
        /** Generic helper */
        private function guess( $expected, $data ) {
@@ -60,6 +66,7 @@ class FormOptionsTest extends MediaWikiTestCase {
 
        /**
         * Reuse helpers above assertGuessBoolean assertGuessInt assertGuessString
+        * @covers FormOptions::guessType
         */
        public function testGuessTypeDetection() {
                $this->assertGuessBoolean( true );
@@ -70,20 +77,22 @@ class FormOptionsTest extends MediaWikiTestCase {
                $this->assertGuessInt( 5 );
                $this->assertGuessInt( 0x0F );
 
+               $this->assertGuessFloat( 0.0 );
+               $this->assertGuessFloat( 1.5 );
+               $this->assertGuessFloat( 1e3 );
+
                $this->assertGuessString( 'true' );
                $this->assertGuessString( 'false' );
                $this->assertGuessString( '5' );
                $this->assertGuessString( '0' );
-       }
+               $this->assertGuessString( '1.5' );
 
-       /**
-        * @expectedException MWException
-        */
-       public function testGuessTypeOnArrayThrowException() {
-               $this->object->guessType( array( 'foo' ) );
+               $this->assertGuessArray( [ 'foo' ] );
        }
+
        /**
         * @expectedException MWException
+        * @covers FormOptions::guessType
         */
        public function testGuessTypeOnNullThrowException() {
                $this->object->guessType( null );