Follow-up to #2461863: Upgrade PHPUnit to the latest stable release

PHPUnit 4.8 is the current stable release series, it became stable on April 3, 2015.

We currently use 4.8.6. There is an update to 4.8.10.

Also, we only require PHPUnit 4.6 but our composer.json requires 4.8.*. Change to allow a lower version of PHPUnit if Drupal is used in a composer workflow. See #2400407-53: [meta] Ensure vendor (PHP) libraries are on latest stable release and #2400407-141: [meta] Ensure vendor (PHP) libraries are on latest stable release for some discussion around this subject.

Beta phase evaluation
Reference: https://www.drupal.org/core/beta-changes
Prioritized changes
External PHP library update

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hussainweb created an issue. See original summary.

hussainweb’s picture

Status: Active » Needs review
FileSize
116.38 KB

This is the relevant change in composer.json.

diff --git a/core/composer.json b/core/composer.json
index abb57e6..ef9b510 100644
--- a/core/composer.json
+++ b/core/composer.json
@@ -34,7 +34,7 @@
     "behat/mink": "~1.6",
     "behat/mink-goutte-driver": "dev-master#cc5ce119b5a8e06662f634b35967aff0b0c7dfdd",
     "mikey179/vfsStream": "~1.2",
-    "phpunit/phpunit": "4.8.*",
+    "phpunit/phpunit": "~4.6",
     "symfony/css-selector": "2.7.*"
   },
   "replace": {
hussainweb’s picture

I should point out again that even though composer.json now requires a minimum of PHPUnit 4.6, the patch actually contains the latest stable, which is 4.8.7.

dawehner’s picture

Status: Needs review » Needs work
+++ b/core/composer.json
@@ -34,7 +34,7 @@
     "mikey179/vfsStream": "~1.2",
-    "phpunit/phpunit": "4.8.*",
+    "phpunit/phpunit": "~4.6",
     "symfony/css-selector": "2.7.*"

Seriously, let's not downgrade to 4.6, are you sure we don't use any of the newer features? Let's go with ~4.8 ?

hussainweb’s picture

Priority: Normal » Critical

I believe we are marking all external library upgrades as critical before RC. If this is not the case, please downgrade.

@dawehner: I believe that we should still decrease the minimum required version to the version we actually need. We had changed it to 4.8.* in #2400407-68: [meta] Ensure vendor (PHP) libraries are on latest stable release just to upgrade but it was not necessary then.

hussainweb’s picture

@dawehner: The update to PHPUnit was committed recently in #2400407-68: [meta] Ensure vendor (PHP) libraries are on latest stable release, and the version constraint was changed just to update. I don't think we have added anything to tests since then (it's only 10 days or so). We can test in a patch to see. I will do that now.

chx’s picture

Please provide more information about what's going on. We are dropping to 4.6 and upgrading to 4.8.7?? *confused*

catch’s picture

Priority: Critical » Major

Patch-level releases aren't critical to update to, unless there's something independently critical about them like a security release.

hussainweb’s picture

@chx: We are not dropping 4.6. I don't think we are using anything new after 4.6 in any of our tests as we upgraded only about 10 days back. I will test to be sure though. I believe we could still use PHPUnit 4.6 and our composer dependencies should point to that. That would be relevant if we use Drupal in a composer workflow.

Mixologic outlined why we should do this in #2400407-53: [meta] Ensure vendor (PHP) libraries are on latest stable release.

hussainweb’s picture

Status: Needs work » Needs review
FileSize
700.58 KB

I am just testing the attached patch with PHPUnit 4.6.10. If it fails, then we could just play it safe and change the version constraint to ~4.8.

hussainweb’s picture

I'll try to explain this a bit more clearly.

We have tried and kept up to date with all our external libraries over the past few months. It is a good idea to upgrade even if we are not using the new features so that we can be sure that we are on the latest stable branch. As long as there are no BC breaks, it is very simple to keep up to date as well.

However, while updating, we also increase the version in composer.json even if we didn't need to. PHPUnit is one example where this happened; composer/installers is another example (see #139).

Normally, this doesn't matter as we ship with composer.lock, but if used Drupal with a composer based workflow, Drupal's composer.lock would not be used and we may get any version. Also, think of another scenario: Another component needs PHPUnit 4.9, but since we have locked it to PHPUnit 4.8.*, that package won't be able to work with Drupal, even though it should.

To keep things simple, our composer version constraints should just specify the range of versions we can work with rather than locking to just the latest version. This ensures maximum compatibility possible.

I am just waiting on the patch in #10. If it turns green, then we are not using any new features introduced after PHPUnit 4.6.10. If it fails, then we are using newer features and we should modify the composer.json to ~4.8.

FWIW, I am not even sure if 4.6 is required. It could just be that the same thing happened earlier and it got increase in an update, but I don't know when that might have happened and hence using 4.6 as base now (as it is just 10 days old).

dawehner’s picture

IMHO we should follow at least the major version in our composer.json file as, there is another level of dependency managment outside of composer.json
People will still build Drupal together how they are used to, so for example, they will see, core ships with 4.8, I'll use feature X, as their module code, might not
add the dependency to 4.8 explicitly. I think this is really likely to happen, so we should better protect against that.

Given that new features are usually introduced in majors, we should at least follow that in our composer.json file.

I am just waiting on the patch in #10. If it turns green, then we are not using any new features introduced after PHPUnit 4.6.10. If it fails, then we are using newer features and we should modify the composer.json to ~4.8.

Certainly +1 to that idea! It would though be great to keep this issue as straightforward as possible as at least according the issue summary is about 4.8.6 to 4.8.7

hussainweb’s picture

Thanks @dawehner. That is certainly an interesting thought.

On thinking more about it, it seems to me that it comes down to using the tool properly. Consider two scenarios:

  1. The people who wouldn't know enough about composer to require the necessary version in their setup would not be using the composer workflow in the first place. In that case, they would get what we ship with Drupal core as per the composer.lock file, i.e., the version we specify.
  2. The people who use the composer workflow would/should know enough to specify the version they need.

In both the scenarios above, the problem is averted.

chx’s picture

> FWIW, I am not even sure if 4.6 is required.

You need 4.6 https://github.com/sebastianbergmann/phpunit/issues/1599

dawehner’s picture

Well, I think for contrib this is much less of a problem. Contrib has often a much higher quality than custom modules, but yeah custom modules will rely on that implicit version,
and well, once you then switch over to a composer based workflow, the custom modules might be still in the same repo, at which you then have the issues.

hussainweb’s picture

The patch in #10 is green. This means that we don't really need anything more than 4.6, but we should stick to the latest version, of course. I think the patch in #1 is still valid. We should discuss a bit on #12 and #13 before proceeding. I don't think this is very urgent, considering it is only a patch upgrade.

I am not married to either approach but I think the version constraint ~4.6 makes sense as it allows a wider range of components to work with Drupal. If there are significant disadvantages to using that, then we could switch to ~4.8.

dawehner’s picture

Well, right, this is core, which has certainly a much higher code quality. Personally I'd like to vote on ~4.8

Status: Needs review » Needs work

The last submitted patch, 10: testing-phpunit-4.6-only.patch, failed testing.

hussainweb’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
293.5 KB

There has been no response here. Also, PHPUnit 5 came out and I am not sure if PHPUnit 4.6 is supported anymore. The website lists 4.8 as supported. The composer.json in this patch now specifies a constraint of ~4.8.

I am still keen to revisit this but I think we have waited long enough. Let's update to 4.8.10. :)

hussainweb’s picture

Status: Needs review » Needs work

Okay, I messed up with that patch in #20. It modified the wrong composer.json file. I am working on a new patch now.

hussainweb’s picture

Status: Needs work » Needs review
FileSize
145.77 KB

Here is the proper patch.

The last submitted patch, 20: upgrade_phpunit_to_the-2568595-20.patch, failed testing.

chx’s picture

Title: Upgrade PHPUnit to the latest stable release » Upgrade PHPUnit to latest 4.8.x

Note we can not update to the latest stable because phpunit 5 simply doesn't support 5.5. (The collaboration is noted.)

dawehner’s picture

Note we can not update to the latest stable because phpunit 5 simply doesn't support 5.5. (The collaboration is noted.)

Yeah we have noted that on the update to phpunit 5 issue.

dawehner’s picture

+++ b/composer.lock
@@ -5,7 +5,6 @@
     "hash": "8c9fdf621ce53640f24b24749e59717c",
-    "content-hash": "f38613812a285c03a1a18458384fe0b1",

This is a little bit odd

dawehner’s picture

@hussainweb
Any thoughts about #26?

hussainweb’s picture

@dawehner: I am not entirely sure. I think that was a composer version mismatch. I upgraded and recreated the patch again. The line had already disappeared due to another issue that got in. Uploading a new patch.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Alright, cool

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.0.x. Thanks!

Also, April 2015? Wonder how this got missed in the last round of updates?

  • webchick committed cc51b6e on 8.0.x
    Issue #2568595 by hussainweb, dawehner: Upgrade PHPUnit to latest 4.8.x
    
dawehner’s picture

We currently use 4.8.6. There is an update to 4.8.10.

The release in april 2015 was 4.8.0

neclimdul’s picture

Status: Fixed » Needs work
diff --git a/vendor/bin/phpunit b/vendor/bin/phpunit
deleted file mode 120000
index 2c48930..0000000
--- a/vendor/bin/phpunit
+++ /dev/null
@@ -1 +0,0 @@
-../phpunit/phpunit/phpunit
\ No newline at end of file
diff --git a/vendor/bin/phpunit b/vendor/bin/phpunit
new file mode 100644
index 0000000..d91886c
--- /dev/null
+++ b/vendor/bin/phpunit
@@ -0,0 +1,7 @@
+#!/usr/bin/env sh
+SRC_DIR="`pwd`"
+cd "`dirname "$0"`"
+cd '../phpunit/phpunit'
+BIN_TARGET="`pwd`/phpunit"
+cd "$SRC_DIR"
+"$BIN_TARGET" "$@"

this is troublesome for at least me. Was calling vendor/bin/phpunit with different php binaries and now they're just outputing a shell script and not running anything. Not sure how we want to proceed.

neclimdul’s picture

Status: Needs work » Fixed

quick follow up fixes it. generating /vendor/bin in windows causes problems it seems. #2580527: Revert vendor/bin/phpunit

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.