[MediaWiki-commits] [Gerrit] CLDRPluralRuleParser[master]: tests: Update phpunit and enable coverage for all classes
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/406055 ) Change subject: tests: Update phpunit and enable coverage for all classes .. tests: Update phpunit and enable coverage for all classes The structure of the Evaluator is that there is a single class that serves as the main entry point, and everything else is called internally, so at this point we might as well allow coverage of all classes from our current tests, which are essentially integration tests. This is normally achieved by disabling 'forceCoversAnnotation', but that is disabled by default and wasn't enabled. The reason the test coverage report was behaving this way was due to the presence of one @covers annotation, which I removed. Also: * Minor phpunit update. * Remove redundant variable assignment in test. * Add 'composer cover' command. * Add /coverage to gitignore. * Add visibility to tests. Change-Id: I9f671dbf5b575799570db307df3fa310fad7976f --- M .gitignore M composer.json M tests/EvaluatorTest.php 3 files changed, 12 insertions(+), 17 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/.gitignore b/.gitignore index de4a392..a37efea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +/coverage /vendor /composer.lock diff --git a/composer.json b/composer.json index f71a4b0..db5ce9f 100644 --- a/composer.json +++ b/composer.json @@ -24,11 +24,11 @@ } }, "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "require-dev": { "jakub-onderka/php-parallel-lint": "^0.9.0.0", - "phpunit/phpunit": "^4.7.7.0", + "phpunit/phpunit": "^4.8", "mediawiki/mediawiki-codesniffer": "15.0.0" }, "scripts": { @@ -37,6 +37,7 @@ "phpunit $PHPUNIT_ARGS", "phpcs -p" ], + "cover": "phpunit --coverage-html coverage/", "fix": [ "phpcbf" ] diff --git a/tests/EvaluatorTest.php b/tests/EvaluatorTest.php index cc44f37..3243d4d 100644 --- a/tests/EvaluatorTest.php +++ b/tests/EvaluatorTest.php @@ -8,28 +8,25 @@ use CLDRPluralRuleParser\Evaluator; -/** - * @covers \CLDRPluralRuleParser\Evaluator - */ class EvaluatorTest extends \PHPUnit_Framework_TestCase { /** -* @dataProvider validTestCases +* @dataProvider provideValidCases */ - function testValidRules( $expected, $rules, $number, $comment ) { + public function testValidRules( $expected, $rules, $number, $comment ) { $result = Evaluator::evaluate( $number, (array)$rules ); $this->assertEquals( $expected, $result, $comment ); } /** -* @dataProvider invalidTestCases +* @dataProvider provideInvalidCases * @expectedException CLDRPluralRuleParser\Error */ - function testInvalidRules( $rules, $comment ) { + public function testInvalidRules( $rules, $comment ) { Evaluator::evaluate( 1, (array)$rules ); } - function validTestCases() { - $tests = [ + public static function provideValidCases() { + return [ # expected, rule, number, comment [ 0, 'n is 1', 1, 'integer number and is' ], [ 0, 'n is 1', "1", 'string integer number and is' ], @@ -139,17 +136,13 @@ array( 1, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14', '10.0', 'bs other' ), // @codingStandardsIgnoreEnd ]; - - return $tests; } - function invalidTestCases() { - $tests = [ + public static function provideInvalidCases() { + return [ [ 'n mod mod 5 is 1', 'mod mod' ], [ 'n', 'just n' ], [ 'n is in 5', 'is in' ], ]; - - return $tests; } } -- To view, visit https://gerrit.wikimedia.org/r/406055 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9f671dbf5b575799570db307df3fa310fad7976f Gerrit-PatchSet: 1 Gerrit-Project: CLDRPluralRuleParser Gerrit-Branch: master Gerrit-Owner: Krinkle Gerrit-Reviewer: Krinkle Gerrit-Reviewer: Legoktm Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] CLDRPluralRuleParser[master]: tests: Update phpunit and enable coverage for all classes
Krinkle has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/406055 ) Change subject: tests: Update phpunit and enable coverage for all classes .. tests: Update phpunit and enable coverage for all classes The structure of the Evaluator is that there is a single class that serves as the main entry point, and everything else is called internally, so at this point we might as well allow coverage of all classes from our current tests, which are essentially integration tests. This is normally achieved by disabling 'forceCoversAnnotation', but that is disabled by default and wasn't enabled. The reason the test coverage report was behaving this way was due to the presence of one @covers annotation, which I removed. Also: * Minor phpunit update. * Remove redundant variable assignment in test. * Add 'composer cover' command. * Add /coverage to gitignore. * Add visibility to tests. Change-Id: I9f671dbf5b575799570db307df3fa310fad7976f --- M .gitignore M composer.json M tests/EvaluatorTest.php 3 files changed, 12 insertions(+), 17 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/CLDRPluralRuleParser refs/changes/55/406055/1 diff --git a/.gitignore b/.gitignore index de4a392..a37efea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +/coverage /vendor /composer.lock diff --git a/composer.json b/composer.json index f71a4b0..db5ce9f 100644 --- a/composer.json +++ b/composer.json @@ -24,11 +24,11 @@ } }, "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "require-dev": { "jakub-onderka/php-parallel-lint": "^0.9.0.0", - "phpunit/phpunit": "^4.7.7.0", + "phpunit/phpunit": "^4.8", "mediawiki/mediawiki-codesniffer": "15.0.0" }, "scripts": { @@ -37,6 +37,7 @@ "phpunit $PHPUNIT_ARGS", "phpcs -p" ], + "cover": "phpunit --coverage-html coverage/", "fix": [ "phpcbf" ] diff --git a/tests/EvaluatorTest.php b/tests/EvaluatorTest.php index cc44f37..3243d4d 100644 --- a/tests/EvaluatorTest.php +++ b/tests/EvaluatorTest.php @@ -8,28 +8,25 @@ use CLDRPluralRuleParser\Evaluator; -/** - * @covers \CLDRPluralRuleParser\Evaluator - */ class EvaluatorTest extends \PHPUnit_Framework_TestCase { /** -* @dataProvider validTestCases +* @dataProvider provideValidCases */ - function testValidRules( $expected, $rules, $number, $comment ) { + public function testValidRules( $expected, $rules, $number, $comment ) { $result = Evaluator::evaluate( $number, (array)$rules ); $this->assertEquals( $expected, $result, $comment ); } /** -* @dataProvider invalidTestCases +* @dataProvider provideInvalidCases * @expectedException CLDRPluralRuleParser\Error */ - function testInvalidRules( $rules, $comment ) { + public function testInvalidRules( $rules, $comment ) { Evaluator::evaluate( 1, (array)$rules ); } - function validTestCases() { - $tests = [ + public static function provideValidCases() { + return [ # expected, rule, number, comment [ 0, 'n is 1', 1, 'integer number and is' ], [ 0, 'n is 1', "1", 'string integer number and is' ], @@ -139,17 +136,13 @@ array( 1, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14', '10.0', 'bs other' ), // @codingStandardsIgnoreEnd ]; - - return $tests; } - function invalidTestCases() { - $tests = [ + public static function provideInvalidCases() { + return [ [ 'n mod mod 5 is 1', 'mod mod' ], [ 'n', 'just n' ], [ 'n is in 5', 'is in' ], ]; - - return $tests; } } -- To view, visit https://gerrit.wikimedia.org/r/406055 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9f671dbf5b575799570db307df3fa310fad7976f Gerrit-PatchSet: 1 Gerrit-Project: CLDRPluralRuleParser Gerrit-Branch: master Gerrit-Owner: Krinkle ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits