Complete VersionChecker test coverage
authorKunal Mehta <legoktm@member.fsf.org>
Sat, 10 Feb 2018 07:14:07 +0000 (23:14 -0800)
committerKunal Mehta <legoktm@member.fsf.org>
Sat, 10 Feb 2018 07:14:07 +0000 (23:14 -0800)
And fix a few typos in the error messages and the accidental inclusion
of whitespace.

Change-Id: I4ea90c5543e394c3f30b1da1456e4676377188f7

includes/registration/VersionChecker.php
tests/phpunit/includes/registration/VersionCheckerTest.php

index a31551c..02e3a7c 100644 (file)
@@ -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
index 6f0de16..4a2810b 100644 (file)
@@ -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.' ],
+                       ]
                ];
        }