In #1498574: [policy, no patch] Require PHP 5.4 it was decided that Drupal 8 will require PHP 5.4. More specifically, this requirement is to become 5.4.2 (see #2152073: Bump Drupal core's PHP requirement to 5.4.2. One of the main reasons to go with PHP 5.4 is that availability of traits. However, our current version of PHPUnit (3.7) does not allow testing those. For that to be possible, we will need to upgrade to PHPUnit 3.8, which in turn requires PHP 5.4.7.

Proposal

Upgrade to PHP 5.4.7, so we can use PHPUnit 3.8 to test traits.

Comments

xano’s picture

PHPUnit 3.7 has the inconsistently named getObjectForTrait(). This seems to return a dumb object and not a mock that you can set expectancies and behavior on.

chx’s picture

I support PHPunit 3.8, I reaaaaaally don't support going above 5.4.4 where Debian Wheezy is http://packages.debian.org/wheezy/php5. Raised https://github.com/sebastianbergmann/phpunit/issues/1075 . Also I wonder what PHP 5.4 do the testbots run.

xano’s picture

If we have to ship with PHPUnit 3.7, we can always test traits by making dummy classes that use them. It's not as clean and straightforward as testing traits directly, but at least it won't be impossible.

chx’s picture

Status: Active » Closed (won't fix)

PHPunit 3.8 will likely be 5.5 by the time it releases for traits see http://blog.florianwolters.de/educational/2012/09/20/Testing-Traits-with... .

xano’s picture

Status: Closed (won't fix) » Active

Let's keep this open for a little longer, if only to create awareness for the fact that with PHPUnit 3.7 we can't test traits directly. Also, the discussion on Github is still ongoing.

chx’s picture

Traits can not be tested "directly" as they are not classes. We need a better issue summary than what we have now -- cos for sure phpunit can test traits and also for sure we will not go above Debian stable unless the sky is falling. A better process proposal can be found at https://drupal.org/comment/8291069#comment-8291069

cosmicdreams’s picture

Since PHPUnit 4.0 was just released today, ( https://github.com/sebastianbergmann/phpunit/wiki/ChangeLog-for-PHPUnit-4.0 ) Should we shift the focus of this issue to upgrading to PHPUnit 4?

webchick’s picture

Probably, yes.

Also, unless I'm mis-reading (which is very possible), https://github.com/sebastianbergmann/phpunit/blob/master/composer.json shows a min. PHP requirement of PHP 5.3.3, not PHP 5.4.7? If so, that'd be great. I'd really rather not increase our PHP version to something that the vast majority of active Linux distros don't support just for unit testing, which approximately 0.0000005% of our overall users will ever touch.

longwave’s picture

PHPUnit seems to have dropped their requirement from PHP 5.4.7 down to PHP 5.3.3 in https://github.com/sebastianbergmann/phpunit/commit/c4ae04b949daad9c9858...

longwave’s picture

Title: Upgrade to PHPUnit 3.8/PHP 5.4.7 » Upgrade to PHPUnit 4
Issue tags: -PHP 5.4
longwave’s picture

PHPUnit 4 has removed staticExpects(), so AccessManagerTest, EntityManagerTest and ReverseProxySubscriberUnitTest will need some refactoring to work around this.

cosmicdreams’s picture

I should probably mark #2114823: Update PHPUnit to 4.x as a duplicate if we're going to do this here.

webchick’s picture

Status: Active » Closed (duplicate)

That one's older, so let's close this as a dupe.