diff --git a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php index fbc518e..8a21187 100644 --- a/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php +++ b/tests/ValueFormatters/Exceptions/MismatchingDataValueTypeException.php @@ -17,6 +17,8 @@ class MismatchingDataValueTypeExceptionTest extends \PHPUnit_Framework_TestCase /** * @dataProvider constructorProvider + * @param string $expectedType + * @param string $actualType */ public function testConstructorWithRequiredArguments( $expectedType, $actualType ) { $exception = new MismatchingDataValueTypeException( $expectedType, $actualType ); @@ -27,6 +29,8 @@ public function testConstructorWithRequiredArguments( $expectedType, $actualType /** * @dataProvider constructorProvider + * @param string $expectedType + * @param string $actualType */ public function testConstructorWithAllArguments( $expectedType, $actualType ) { $message = 'Onoez! an error!'; diff --git a/tests/ValueFormatters/StringFormatterTest.php b/tests/ValueFormatters/StringFormatterTest.php index 9e0e8ff..840cbdf 100644 --- a/tests/ValueFormatters/StringFormatterTest.php +++ b/tests/ValueFormatters/StringFormatterTest.php @@ -5,9 +5,7 @@ use DataValues\StringValue; /** - * Unit tests for the ValueFormatters\StringFormatter class. - * - * @since 0.1 + * @covers ValueFormatters\StringFormatter * * @group ValueFormatters * @group DataValueExtensions @@ -17,6 +15,15 @@ */ class StringFormatterTest extends ValueFormatterTestBase { + /** + * @see ValueFormatterTestBase::getFormatterClass + * + * @return string + */ + protected function getFormatterClass() { + return 'ValueFormatters\StringFormatter'; + } + /** * @see ValueFormatterTestBase::validProvider */ @@ -38,13 +45,4 @@ public function validProvider() { return $argLists; } - /** - * @see ValueFormatterTestBase::getFormatterClass - * - * @return string - */ - protected function getFormatterClass() { - return 'ValueFormatters\StringFormatter'; - } - } diff --git a/tests/ValueParsers/BoolParserTest.php b/tests/ValueParsers/BoolParserTest.php index cfbe828..6d800df 100644 --- a/tests/ValueParsers/BoolParserTest.php +++ b/tests/ValueParsers/BoolParserTest.php @@ -5,9 +5,7 @@ use DataValues\BooleanValue; /** - * Unit test BoolParser class. - * - * @since 0.1 + * @covers ValueParsers\BoolParser * * @group ValueParsers * @group DataValueExtensions @@ -17,6 +15,15 @@ */ class BoolParserTest extends StringValueParserTest { + /** + * @see ValueParserTestBase::getParserClass + * + * @return string + */ + protected function getParserClass() { + return 'ValueParsers\BoolParser'; + } + /** * @see ValueParserTestBase::validInputProvider */ @@ -62,13 +69,4 @@ public function invalidInputProvider() { return $argLists; } - /** - * @see ValueParserTestBase::getParserClass - * - * @return string - */ - protected function getParserClass() { - return 'ValueParsers\BoolParser'; - } - } diff --git a/tests/ValueParsers/FloatParserTest.php b/tests/ValueParsers/FloatParserTest.php index 748d8a5..b8a8c34 100644 --- a/tests/ValueParsers/FloatParserTest.php +++ b/tests/ValueParsers/FloatParserTest.php @@ -5,9 +5,7 @@ use DataValues\NumberValue; /** - * Unit test FloatParser class. - * - * @since 0.1 + * @covers ValueParsers\FloatParser * * @group ValueParsers * @group DataValueExtensions @@ -18,6 +16,15 @@ */ class FloatParserTest extends StringValueParserTest { + /** + * @see ValueParserTestBase::getParserClass + * + * @return string + */ + protected function getParserClass() { + return 'ValueParsers\FloatParser'; + } + /** * @see ValueParserTestBase::validInputProvider */ @@ -83,13 +90,4 @@ public function invalidInputProvider() { return $argLists; } - /** - * @see ValueParserTestBase::getParserClass - * - * @return string - */ - protected function getParserClass() { - return 'ValueParsers\FloatParser'; - } - } diff --git a/tests/ValueParsers/IntParserTest.php b/tests/ValueParsers/IntParserTest.php index e20e003..eb98914 100644 --- a/tests/ValueParsers/IntParserTest.php +++ b/tests/ValueParsers/IntParserTest.php @@ -5,9 +5,7 @@ use DataValues\NumberValue; /** - * Unit test IntParser class. - * - * @since 0.1 + * @covers ValueParsers\IntParser * * @group ValueParsers * @group DataValueExtensions @@ -17,6 +15,15 @@ */ class IntParserTest extends StringValueParserTest { + /** + * @see ValueParserTestBase::getParserClass + * + * @return string + */ + protected function getParserClass() { + return 'ValueParsers\IntParser'; + } + /** * @see ValueParserTestBase::validInputProvider */ @@ -72,13 +79,4 @@ public function invalidInputProvider() { return $argLists; } - /** - * @see ValueParserTestBase::getParserClass - * - * @return string - */ - protected function getParserClass() { - return 'ValueParsers\IntParser'; - } - } diff --git a/tests/ValueParsers/NullParserTest.php b/tests/ValueParsers/NullParserTest.php index bccbc1a..5bf7781 100644 --- a/tests/ValueParsers/NullParserTest.php +++ b/tests/ValueParsers/NullParserTest.php @@ -6,9 +6,7 @@ use ValueParsers\ValueParser; /** - * Unit test NullParser class. - * - * @since 0.1 + * @covers ValueParsers\NullParser * * @group ValueParsers * @group DataValueExtensions @@ -18,6 +16,15 @@ */ class NullParserTest extends ValueParserTestBase { + /** + * @see ValueParserTestBase::getParserClass + * + * @return string + */ + protected function getParserClass() { + return 'ValueParsers\NullParser'; + } + /** * @see ValueParserTestBase::validInputProvider */ @@ -48,28 +55,20 @@ public function validInputProvider() { * @see ValueParserTestBase::invalidInputProvider */ public function invalidInputProvider() { - return array( array( - 'This sucks; this parser has no invalid inputs, so this test should be skipped.' . - 'Not clear how to do that in a way one does not get a "incomplete test" notice though' - ) ); + return array( + array( null ) + ); } /** + * @see ValueParserTestBase::testParseWithInvalidInputs + * * @dataProvider invalidInputProvider - * @param $value - * @param ValueParser $parser + * @param mixed $value + * @param ValueParser|null $parser */ public function testParseWithInvalidInputs( $value, ValueParser $parser = null ) { - $this->assertTrue( true ); - } - - /** - * @see ValueParserTestBase::getParserClass - * - * @return string - */ - protected function getParserClass() { - return 'ValueParsers\NullParser'; + $this->markTestSkipped( 'NullParser has no invalid inputs' ); } } diff --git a/tests/ValueParsers/StringValueParserTest.php b/tests/ValueParsers/StringValueParserTest.php index d374873..2527ecd 100644 --- a/tests/ValueParsers/StringValueParserTest.php +++ b/tests/ValueParsers/StringValueParserTest.php @@ -17,23 +17,20 @@ */ abstract class StringValueParserTest extends ValueParserTestBase { + /** + * @see ValueParserTestBase::invalidInputProvider + * + * @return array[] + */ public function invalidInputProvider() { - $argLists = array(); - - $invalid = array( - true, - false, - null, - 4.2, - array(), - 42, + return array( + array( true ), + array( false ), + array( null ), + array( 4.2 ), + array( array() ), + array( 42 ), ); - - foreach ( $invalid as $value ) { - $argLists[] = array( $value ); - } - - return $argLists; } public function testSetAndGetOptions() { diff --git a/tests/ValueParsers/ValueParserTestBase.php b/tests/ValueParsers/ValueParserTestBase.php index 63a428f..8359536 100644 --- a/tests/ValueParsers/ValueParserTestBase.php +++ b/tests/ValueParsers/ValueParserTestBase.php @@ -22,26 +22,28 @@ abstract class ValueParserTestBase extends \PHPUnit_Framework_TestCase { /** * @since 0.1 + * * @return string */ protected abstract function getParserClass(); /** * @since 0.1 + * * @return array[] */ public abstract function validInputProvider(); /** * @since 0.1 + * * @return array[] */ - public function invalidInputProvider() { - return array(); - } + public abstract function invalidInputProvider(); /** * @since 0.1 + * * @return ValueParser */ protected function getInstance() { @@ -50,14 +52,15 @@ protected function getInstance() { } /** - * @dataProvider validInputProvider * @since 0.1 + * + * @dataProvider validInputProvider * @param mixed $value * @param mixed $expected * @param ValueParser|null $parser */ public function testParseWithValidInputs( $value, $expected, ValueParser $parser = null ) { - if ( is_null( $parser ) ) { + if ( $parser === null ) { $parser = $this->getInstance(); } @@ -86,13 +89,14 @@ private function assertSmartEquals( $expected, $actual ) { } /** - * @dataProvider invalidInputProvider * @since 0.1 + * + * @dataProvider invalidInputProvider * @param mixed $value * @param ValueParser|null $parser */ public function testParseWithInvalidInputs( $value, ValueParser $parser = null ) { - if ( is_null( $parser ) ) { + if ( $parser === null ) { $parser = $this->getInstance(); }