Cleanup HTMLCheckMatrixTest.
authoraddshore <addshorewiki@gmail.com>
Fri, 15 Nov 2013 23:45:43 +0000 (00:45 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Mon, 6 Jan 2014 13:30:46 +0000 (14:30 +0100)
Fix Covers tags, looks like we need more testcases
for all other HTML* classes

Change-Id: I166464da3373b45564dd770feecacafacb301604

tests/phpunit/includes/htmlform/HTMLCheckMatrixTest.php

index 39c3959..c41acef 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 
 /**
- * Unit tests for the HTMLCheckMatrix + HTMLFormField
- * @todo the tests for the two classes could be split up
+ * Unit tests for the HTMLCheckMatrix
+ * @covers HTMLCheckMatrix
  */
 class HtmlCheckMatrixTest extends MediaWikiTestCase {
        static private $defaultOptions = array(
@@ -11,12 +11,9 @@ class HtmlCheckMatrixTest extends MediaWikiTestCase {
                'fieldname' => 'test',
        );
 
-       /**
-        * @covers HTMLCheckMatrix::__construct
-        */
        public function testPlainInstantiation() {
                try {
-                       $form = new HTMLCheckMatrix( array() );
+                       new HTMLCheckMatrix( array() );
                } catch ( MWException $e ) {
                        $this->assertInstanceOf( 'HTMLFormFieldRequiredOptionsException', $e );
                        return;
@@ -25,32 +22,23 @@ class HtmlCheckMatrixTest extends MediaWikiTestCase {
                $this->fail( 'Expected MWException indicating missing parameters but none was thrown.' );
        }
 
-       /**
-        * @covers HTMLCheckMatrix::__construct
-        */
        public function testInstantiationWithMinimumRequiredParameters() {
-               $form = new HTMLCheckMatrix( self::$defaultOptions );
+               new HTMLCheckMatrix( self::$defaultOptions );
                $this->assertTrue( true ); // form instantiation must throw exception on failure
        }
 
-       /**
-        * @covers HTMLFormField::validate
-        */
        public function testValidateCallsUserDefinedValidationCallback() {
                $called = false;
                $field = new HTMLCheckMatrix( self::$defaultOptions + array(
-                       'validation-callback' => function() use ( &$called ) {
-                               $called = true;
-                               return false;
-                       },
-               ) );
+                               'validation-callback' => function() use ( &$called ) {
+                                               $called = true;
+                                               return false;
+                                       },
+                       ) );
                $this->assertEquals( false, $this->validate( $field, array() ) );
                $this->assertTrue( $called );
        }
 
-       /**
-        * @covers HTMLFormField::validate
-        */
        public function testValidateRequiresArrayInput() {
                $field = new HTMLCheckMatrix( self::$defaultOptions );
                $this->assertEquals( false, $this->validate( $field, null ) );
@@ -60,17 +48,11 @@ class HtmlCheckMatrixTest extends MediaWikiTestCase {
                $this->assertEquals( true, $this->validate( $field, array() ) );
        }
 
-       /**
-        * @covers HTMLFormField::validate
-        */
        public function testValidateAllowsOnlyKnownTags() {
                $field = new HTMLCheckMatrix( self::$defaultOptions );
                $this->assertInternalType( 'string', $this->validate( $field, array( 'foo' ) ) );
        }
 
-       /**
-        * @covers HTMLFormField::validate
-        */
        public function testValidateAcceptsPartialTagList() {
                $field = new HTMLCheckMatrix( self::$defaultOptions );
                $this->assertTrue( $this->validate( $field, array() ) );
@@ -84,12 +66,11 @@ class HtmlCheckMatrixTest extends MediaWikiTestCase {
         * foreach ( $field->filterDataForSubmit( $data ) as $k => $v ) {
         *     $user->setOption( $k, $v );
         * }
-        * @covers HTMLFormField::filterDataForSubmit
         */
        public function testValuesForcedOnRemainOn() {
                $field = new HTMLCheckMatrix( self::$defaultOptions + array(
-                       'force-options-on' => array( 'c2-r1' ),
-               ) );
+                               'force-options-on' => array( 'c2-r1' ),
+                       ) );
                $expected = array(
                        'c1-r1' => false,
                        'c1-r2' => false,
@@ -99,13 +80,10 @@ class HtmlCheckMatrixTest extends MediaWikiTestCase {
                $this->assertEquals( $expected, $field->filterDataForSubmit( array() ) );
        }
 
-       /**
-        * @covers HTMLFormField::filterDataForSubmit
-        */
        public function testValuesForcedOffRemainOff() {
                $field = new HTMLCheckMatrix( self::$defaultOptions + array(
-                       'force-options-off' => array( 'c1-r2', 'c2-r2' ),
-               ) );
+                               'force-options-off' => array( 'c1-r2', 'c2-r2' ),
+                       ) );
                $expected = array(
                        'c1-r1' => true,
                        'c1-r2' => false,
@@ -122,4 +100,5 @@ class HtmlCheckMatrixTest extends MediaWikiTestCase {
                        array( self::$defaultOptions['fieldname'] => $submitted )
                );
        }
+
 }