Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#25854 closed enhancement (fixed)

PHPUnit Configuration for Grunt

Reported by: bpetty's profile bpetty Owned by: nacin's profile nacin
Milestone: 3.8 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:


I've taken a stab at creating some Grunt tasks for our PHPUnit tests to go along with our QUnit tests.

Note that I did attempt to use grunt-phpunit, however, it appears to not be very mature, and requires configuring the directory location for tests. We make use of more advanced features through the configuration file (stuff like phpVersion requirements) that aren't supported with this Grunt plugin yet. See also issue #9.

Instead, this patch just makes quick and dirty use of grunt.util.spawn to provide the self-explanatory phpunit:default, phpunit:ajax, and phpunit:multisite tasks.

I've also taken the liberty of adding the phpunit:default task to the generic test task along with qunit.

Since this gives developers another way to run the PHPUnit tests from the root folder, I've moved the phpunit.xml.dist file back into the tests/phpunit folder out of the way (where it's still possible to run "phpunit" directly).

Attachments (1)

ticket-25854-grunt-phpunit.patch (3.7 KB) - added by bpetty 11 years ago.

Download all attachments as: .zip

Change History (7)

#1 @jdgrimes
11 years ago

  • Cc jdg@… added

#2 @SergeyBiryukov
11 years ago

  • Component changed from Unit Tests to Build Tools

#3 @nacin
11 years ago

I think we could easily leave phpunit.xml.dist where it is, at least for the moment. The benefit being that we're already used to running phpunit from the root, so we should probably keep it that way. We've been trying to emphasize that tests and the source are just two pieces of the same pie, hence committing both sides in the same commit. At least for me, it's also fairly common to "idle" on the command line at the root of the repository (sometimes opening files in src, other times in tests, and eventually in tools as well) and run tests from there. grunt gives us the opportunity to run them from anywhere, but I don't think we need to switch up our test instructions yet again just yet.

#4 @nacin
11 years ago

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

In 26064:

Add grunt phpunit which runs three tasks: phpunit, ajax tests, and phpunit as multisite.

You can also run grunt phpunit:default, grunt phpunit:ajax, and grunt phpunit:multisite separately.

grunt test now runs the qunit task (both compiled and uncompiled scripts) and the phpunit tasks.

props bpetty.
fixes #25854, see #25781.

#5 @nacin
11 years ago

In 26066:

Make [25064] lint-free. see #25854.

#6 @nacin
11 years ago

  • Milestone changed from Awaiting Review to 3.8
Note: See TracTickets for help on using tickets.