WordPress.org

Make WordPress Core

#25065 closed defect (bug) (fixed)

The unit tests assume that PHPUnit is installed via PEAR

Reported by: scribu Owned by: dd32
Milestone: 3.7 Priority: normal
Severity: normal Version:
Component: Unit Tests Keywords: has-patch
Focuses: Cc:

Description (last modified by scribu)

PHPUnit officially supports 3 installation methods:

  1. via PEAR
  2. via Phar file
  3. via Composer

Core apparently only supports the first one, which also happens to be the most cumbersome.

Steps to reproduce:

  1. Install PHPUnit via Phar:
wget http://pear.phpunit.de/get/phpunit.phar
chmod +x phpunit.phar
mv phpunit.phar /usr/local/bin/phpunit
  1. Try to run the WP test suite with it:
phpunit -c tests/phpunit.xml

Result:

PHP Fatal error:  require_once(): Failed opening required 'PHPUnit/Autoload.php' (include_path='.:/usr/local/Cellar/php55/5.5.1/lib/php') in /Users/User/svn/wp-develop/tests/includes/bootstrap.php on line 7

Attachments (1)

25065.diff (382 bytes) - added by scribu 23 months ago.
remove loading of PHPUnit/Autoload.php

Download all attachments as: .zip

Change History (14)

comment:1 @scribu23 months ago

  • Description modified (diff)

@scribu23 months ago

remove loading of PHPUnit/Autoload.php

comment:2 @scribu23 months ago

  • Keywords has-patch needs-testing added

The patch fixes the case when PHPUnit is installed as a Phar file.

I don't know if it works when it's installed as a PEAR package, because I wasn't able to install it in that manner.

comment:3 @dd3223 months ago

FWIW, this appears to still work when using it with PEAR.

comment:4 @SergeyBiryukov23 months ago

Appears to work with PEAR for me too.

comment:5 follow-up: @scribu23 months ago

  • Keywords needs-testing removed
  • Milestone changed from Awaiting Review to 3.7

Cool. Setting this to 3.7 milestone, since there doesn't seem to be a Tools milestone.

comment:6 in reply to: ↑ 5 @nacin23 months ago

Replying to scribu:

Cool. Setting this to 3.7 milestone, since there doesn't seem to be a Tools milestone.

We're still working out how exactly we're going to handle our revamped workflows (including features-as-plugins starting in 3.8) but in this case 3.7 is quite fine as we're now tagging/branching our tools like source.

comment:7 follow-up: @nofearinc23 months ago

I can confirm the issue and that the patch above works.

One comment though - the patched file from the diff is tests/includes/bootstrap.php, on my just checked out setup from here (as per the handbook) it's in includes/bootstrap.php instead and not in the tests folder. Not sure if it matters, but just saying.

comment:8 @nofearinc23 months ago

  • Cc mario@… added

comment:9 in reply to: ↑ 7 ; follow-up: @dd3223 months ago

Replying to nofearinc:

One comment though - the patched file from the diff is tests/includes/bootstrap.php, on my just checked out setup from here (as per the handbook) it's in includes/bootstrap.php instead and not in the tests folder. Not sure if it matters, but just saying.

It appears the handbook probably hasn't been updated yet, but we're in the midst of changing to a new SVN structure which lives at http://develop.svn.wordpress.org/trunk/ - See http://make.wordpress.org/core/2013/08/06/a-new-frontier-for-core-development/

comment:10 @markoheijnen23 months ago

I still think it is save for now to create the patch from the unit tests folder since the folder name can/will change when the JS unit tests arrive.

comment:11 in reply to: ↑ 9 ; follow-up: @nofearinc23 months ago

Replying to dd32:

It appears the handbook probably hasn't been updated yet, but we're in the midst of changing to a new SVN structure which lives at http://develop.svn.wordpress.org/trunk/ - See http://make.wordpress.org/core/2013/08/06/a-new-frontier-for-core-development/

I'm aware of the change, but: 1) the handbook should be updated (this is a memo) and 2) there is ambiguity due to the existence of tests/includes folder within the wordpress tests folder, and 3) not sure if the tests would be in tests/ at the end or phpunit/ or something when the migration is fully complete (due to JS tests, or some Behat additions or whatever is to be added as other tests)

comment:12 in reply to: ↑ 11 @kpdesign23 months ago

Replying to nofearinc:

I'm aware of the change, but: 1) the handbook should be updated (this is a memo)

I've updated the handbook this morning to point to the new SVN structure. Could you please review it to ensure it is accurate?

Also, the Writing Tests section still needs to be written. If anyone would like volunteer to do that, it would be most appreciated. :)

Version 0, edited 23 months ago by kpdesign (next)

comment:13 @dd3223 months ago

  • Owner set to dd32
  • Resolution set to fixed
  • Status changed from new to closed

In 25145:

Unit Tests: Make it more compatible with PHPUnit when installed as a Phar, or, Composer package, by removing a duplicate require (Phpunit already includes the file itself). Props scribu Fixes #25065

Note: See TracTickets for help on using tickets.