From 4ca1b96184331984d26c1b3811d2b16c06414597 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Fri, 9 Feb 2018 23:14:07 -0800 Subject: [PATCH] Complete VersionChecker test coverage And fix a few typos in the error messages and the accidental inclusion of whitespace. Change-Id: I4ea90c5543e394c3f30b1da1456e4676377188f7 --- includes/registration/VersionChecker.php | 8 ++--- .../registration/VersionCheckerTest.php | 34 +++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/includes/registration/VersionChecker.php b/includes/registration/VersionChecker.php index a31551c361..02e3a7c8ab 100644 --- a/includes/registration/VersionChecker.php +++ b/includes/registration/VersionChecker.php @@ -175,13 +175,13 @@ class VersionChecker { if ( !isset( $this->loaded[$dependencyName]['version'] ) ) { // If we depend upon any version, and none is set, that's fine. if ( $constraint === '*' ) { - wfDebug( "{$dependencyName} does not expose it's version, but {$checkedExt} - mentions it with constraint '*'. Assume it's ok so." ); + wfDebug( "{$dependencyName} does not expose its version, but {$checkedExt}" + . " mentions it with constraint '*'. Assume it's ok so." ); return false; } else { // Otherwise, mark it as incompatible. - return "{$dependencyName} does not expose it's version, but {$checkedExt} - requires: {$constraint}."; + return "{$dependencyName} does not expose its version, but {$checkedExt}" + . " requires: {$constraint}."; } } else { // Try to get a constraint for the dependency version diff --git a/tests/phpunit/includes/registration/VersionCheckerTest.php b/tests/phpunit/includes/registration/VersionCheckerTest.php index 6f0de160f5..4a2810bb58 100644 --- a/tests/phpunit/includes/registration/VersionCheckerTest.php +++ b/tests/phpunit/includes/registration/VersionCheckerTest.php @@ -54,6 +54,7 @@ class VersionCheckerTest extends PHPUnit_Framework_TestCase { 'FakeDependency' => [ 'version' => '1.0.0', ], + 'NoVersionGiven' => [], ] ); $this->assertEquals( $expected, $checker->checkArray( [ 'FakeExtension' => $given, @@ -78,6 +79,39 @@ class VersionCheckerTest extends PHPUnit_Framework_TestCase { ], [] ], + [ + [ + 'extensions' => [ + 'NoVersionGiven' => '*' + ] + ], + [], + ], + [ + [ + 'extensions' => [ + 'NoVersionGiven' => '1.0', + ] + ], + [ 'NoVersionGiven does not expose its version, but FakeExtension requires: 1.0.' ], + ], + [ + [ + 'extensions' => [ + 'Missing' => '*', + ] + ], + [ 'FakeExtension requires Missing to be installed.' ], + ], + [ + [ + 'extensions' => [ + 'FakeDependency' => '2.0.0', + ] + ], + // phpcs:ignore Generic.Files.LineLength.TooLong + [ 'FakeExtension is not compatible with the current installed version of FakeDependency (1.0.0), it requires: 2.0.0.' ], + ] ]; } -- 2.20.1