X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FFormOptionsTest.php;h=665fa390171d2f6ea3cc04d656c518ff59d66985;hb=5957856c46c3c351b88b6f150ccd39afb5be2c5c;hp=0a13cfec59022046712c0a805d45856cc18f4f67;hpb=8b39246edec852455837131ff6145b82970c55d6;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/FormOptionsTest.php b/tests/phpunit/includes/FormOptionsTest.php index 0a13cfec59..665fa39017 100644 --- a/tests/phpunit/includes/FormOptionsTest.php +++ b/tests/phpunit/includes/FormOptionsTest.php @@ -34,6 +34,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,6 +46,9 @@ 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 ); } @@ -60,6 +64,7 @@ class FormOptionsTest extends MediaWikiTestCase { /** * Reuse helpers above assertGuessBoolean assertGuessInt assertGuessString + * @covers FormOptions::guessType */ public function testGuessTypeDetection() { $this->assertGuessBoolean( true ); @@ -70,20 +75,27 @@ 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 + * @covers FormOptions::guessType */ public function testGuessTypeOnArrayThrowException() { $this->object->guessType( array( 'foo' ) ); } /** * @expectedException MWException + * @covers FormOptions::guessType */ public function testGuessTypeOnNullThrowException() { $this->object->guessType( null );