From b97109f113d6589743254d056acdd4488fd74a74 Mon Sep 17 00:00:00 2001 From: addshore Date: Sat, 16 Nov 2013 00:45:43 +0100 Subject: [PATCH] Cleanup HTMLCheckMatrixTest. Fix Covers tags, looks like we need more testcases for all other HTML* classes Change-Id: I166464da3373b45564dd770feecacafacb301604 --- .../includes/htmlform/HTMLCheckMatrixTest.php | 49 ++++++------------- 1 file changed, 14 insertions(+), 35 deletions(-) diff --git a/tests/phpunit/includes/htmlform/HTMLCheckMatrixTest.php b/tests/phpunit/includes/htmlform/HTMLCheckMatrixTest.php index 39c39595e2..c41acef1b9 100644 --- a/tests/phpunit/includes/htmlform/HTMLCheckMatrixTest.php +++ b/tests/phpunit/includes/htmlform/HTMLCheckMatrixTest.php @@ -1,8 +1,8 @@ '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 ) ); } + } -- 2.20.1