Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#25065 closed defect (bug) (fixed)

The unit tests assume that PHPUnit is installed via PEAR

Reported by: scribu's profile scribu Owned by: dd32's profile 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 11 years ago.
remove loading of PHPUnit/Autoload.php

Download all attachments as: .zip

Change History (14)

#1 @scribu
11 years ago

  • Description modified (diff)

@scribu
11 years ago

remove loading of PHPUnit/Autoload.php

#2 @scribu
11 years 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.

#3 @dd32
11 years ago

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

#4 @SergeyBiryukov
11 years ago

Appears to work with PEAR for me too.

#5 follow-up: @scribu
11 years 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.

#6 in reply to: ↑ 5 @nacin
11 years 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.

#7 follow-up: @nofearinc
11 years 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.

#8 @nofearinc
11 years ago

  • Cc mario@… added

#9 in reply to: ↑ 7 ; follow-up: @dd32
11 years 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/

#10 @markoheijnen
11 years 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.

#11 in reply to: ↑ 9 ; follow-up: @nofearinc
11 years 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)

#12 in reply to: ↑ 11 @kpdesign
11 years 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 to volunteer to do that, it would be most appreciated. :)

Last edited 11 years ago by kpdesign (previous) (diff)

#13 @dd32
11 years 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.