Recent updates to the unit testing infrastructure

Several changes have made their way into WordPress’ unit test suite and its infrastructure recently. If you maintain a WordPress project (such as a plugin or website) that has its own test coverage, you may be interested in porting some of these changes to your test suite too. Here’s a round-up:

  • Tests which require Multisite to be enabled, or tests which should be excluded from running when Multisite is enabled, can now use the new ms-required and ms-excluded groups along with the new skipWithoutMultisite() and skipWithMultisite() test case methods respectively to more cleanly skip tests without them always being marked as skipped. This removes unwanted noise from PHPUnit’s reporting when run in verbose mode. See #40531.

Example usage:

/**
 * @group ms-required
 */
function test_something_on_multisite() {
	$this->skipWithoutMultisite();

	// Run your Multisite-only assertions here
}

/**
 * @group ms-excluded
 */
function test_something_without_multisite() {
	$this->skipWithMultisite();

	// Run your single-site-only assertions here
}
  • XDebug is now disabled when running tests on Travis in order to speed up the builds. This resulted in a huge reduction in build times, up to 40% in some cases. See #39978.
  • The PHPUnit version used when running tests on Travis is now explicitly coupled to the PHP version in order to avoid incompatibilities such as the one caused when PHPUnit 6 was rolled out. See [40269] for the main change and #40100 and #40086 for more info.
  • A compatibility shim for PHPUnit 6+ has been added, which means the test suite will no longer cause fatal errors if you want to update to PHPUnit 6+ locally or, for example, you want to require it through a Composer dependency. See #39822.
  • Several tests which were previously skipped when the environment wasn’t suitable will now cause failures, for example tests which depend on constants such as DISALLOW_FILE_MODS not being set. This is to avoid hiding tests that never run and therefore never fail if the assertions contained within them would otherwise fail. If the core test suite begins failing on your local environment as a result, you should address the cause. See #40533.
  • The number of PHP versions which older branches are tested against on Travis has been significantly reduced in order to speed up build times for patch releases. This is most beneficial when security fixes are released and backported. As a general rule, branch builds except the latest branch are now only tested on the oldest supported version (5.2), the latest in the 5.x branch, and the latest in the 7.x branch. See #40407.

#dev-notes

Target Browser Coverage

Previously, we discussed the new editor and browser support within WordPress core. Following up on those conversations, we are officially ending support for Internet Explorer versions 8, 9, and 10, starting with WordPress 4.8.

Microsoft officially discontinued supporting these browsers in January 2016, and attempting to continue supporting them ourselves has gotten to the point where it’s holding back development. I realize that folks still running these browsers are probably stuck with them because of something out of their control, like being at a library or something. Depending on how you count it, those browsers combined are either around 3% or under 1% of total users, but either way they’ve fallen below the threshold where it’s helpful for WordPress to continue testing and developing against. (The numbers surprised me, as did how low IE market share overall has gone.)

Of course, wp-admin should still work in these older browsers, but with fewer capabilities, and we will no longer be testing new features and enhancements in these browsers. For example, the next versions of TinyMCE – currently targeted at WordPress 4.8 – will not support older IE browsers.

As part of this change, we will work to update Browse Happy to show that these browsers are no longer supported and encourage users to upgrade or switch browsers.

Week in Core, April 12th – April 18th 2017

Welcome back the latest issue of Week in Core, covering changes [40417-40475]. Here are the highlights:

  • 59 commits
  • 37 contributors
  • 59 tickets created
  • 6 tickets reopened
  • 36 tickets closed

Ticket numbers based on trac timeline for the period above. The following is a summary of commits, organized by component.

Code Changes

Administration

  • Add “(link opens in a new window)” as a screen reader text for “Preview” link on Edit Post screen. [40422] #40185

Build/Test Tools

  • Build/Test tools: Ruthlessly remove failing tests from the 4.0 branch. [40457] #40463
  • Better rewrite rule flushing in test_permalink_without_title(). [40456] #40463
  • Remove failing tests related to WP_User::__unset(). [40455] #30284, #40463
  • Remove failing is_textdomain_loaded() test. [40454] #30284, #40463
  • Remove failing tests related to square brackets being stripped in URL sanitizers. [40453] #30284, #40463
  • Remove failing test in the hooks group. [40452] #30284, #40463
  • Remove skipped tests for unimplemented JS plural functions. [40451] #22229, #40463
  • Remove failing unit tests from ‘canonical’ group. [40450] #30284, #40463
  • Partial merge of [30283] into the 4.0 branch to avoid PHP notices that cause a test failure. [40449] #30284
  • assertTag() has been deprecated in PHPUnit 4.2. Rewrite some of the tests in Tests_Paginate_Links to use DOMDocument. [40447] #29545
  • Build/Test tools: Reverse the order in which the Travis jobs run on the 3.8 branch. [40444] #39705
  • Build/Test tools: Reverse the order in which the Travis jobs run. [40435] #39705
  • Build/Test tools: Introduce and implement assertNotIXRError() and assertIXRError() assertion methods. [40417] #40423

Bundled Theme

  • Twenty Seventeen: Bump version and update the changelog. [40473] #40461
  • Twenty Seventeen: Correct heading hierarchy for posts on the front page. [40459] #40264

Customize

  • Use fixed-width illustrative placeholder for hex field in color picker to prevent truncation. [40471] #39096
  • Verify availability of history.replaceState (in IE9) before attempting to populate changeset_uuid parameter. [40420] #39227, #40405

Media

  • Fix broken audio/video functions when sanitizing ID3 data [40470] #40075, #40085
  • Default to always showing the “Create Audio/Video Playlist” buttons. [40430] #31071
  • Ensure Crop Image is always visible. [40429] #40152
  • Add filters to allow overriding slow media queries. [40425] #31071
  • Improve filters that allow overriding slow media queries. [40421] #31071

Misc

  • Bump 4.7 branch to 4.7.4-RC1. [40475] #
  • 4.7.4-RC [40474] #
  • Tests: Fix a YouTube embed test failing since YouTube switched to HTTPS-only. [40448] #
  • Updates for 4.6. Merge of and to the 4.6 branch.

Networks and Sites

  • Correct a capability check when accessing the Sites -> Add New screen. [40433] #39156

Options, Meta APIs

Posts, Post Types

  • In wp_check_post_lock(), check if the user with lock exists and return false otherwise. [40424] #39888
  • Improve the docs for wp_check_post_lock() and wp_set_post_lock(). [40423] #39888

Query

REST API

Taxonomy

TinyMCE

  • Update TinyMCE to 4.5.6. Has many improvements and bug [40419] #40305

Toolbar

  • Reset CSS properties that might be inherited from the active Theme. [40418] #40313

Upload

  • Improve legacy SWFUpload event handlers for current jQuery. [40431] #39886

Thanks to @sagarprajapati, @1naveengiri, @adamsilverstein, @afercia, @arshidkv12, @azaozz, @celloexpressions, @curdin, @Cybr, @davidakennedy, @eclev91, @boldwater, @flixos9, @jdgrimes, @jnylen0, @joedolson, @joemcgill, @johnbillion, @karinedo, @lukecavanagh, @MatheusGimenez, @mayurk, @mayur, @MMDeveloper, @netwe, @Presskopp, @programmin, @rianrietveld, @sagarprajapati, @sboisvert, @SergeyBiryukov, @stormrockwell, @swissspidy, @tejas5989, @timmydcrawfor, @westonruter, and @wonderboymusic for their contributions!

#week-in-core

Proposal for Weekly Core JavaScript Chat

In last week’s core dev chat, @rmccue identified a need to coordinate on consistent approaches to common JavaScript requirements. As the projects of this year’s focuses have more heavily leveraged JavaScript, a few specific needs have arisen:

To coordinate work towards a common goal for JavaScript in core, we are planning weekly Core-JavaScript meetings to take place in the #core Slack channel. Proposed times for the meeting are (weekly at): April 26, 2017 at 00:00 UTC, April 26, 2017 at 01:00 UTC or April 27, 2017 at 02:00 UTC. @adamsilverstein and @aduth were nominated to lead the effort.

Additional topics may include:

  • Media Manager extensibility (#40427).
  • Modernization of tooling, patterns, and frameworks to accommodate heavier usage of JavaScript.

Comment with your interest and availability for the proposed meeting times below.

#javascript

4.7.4 Release Candidate

After about six weeks of development, a Release Candidate for WordPress 4.7.4 is now available. This maintenance release fixes 46 issues reported against 4.7 and is scheduled for final release on Thursday, April 20, 2017.

Thus far WordPress 4.7 has been downloaded nearly 60 million times since its release on December 6, 2016. Please help us by testing this release candidate to ensure 4.7.4 fixes the reported issues and doesn’t introduce any new ones.

Notable Bug Fixes

There are a few more notable issues being addressed in this release. The first one is about broken video/audio thumbnails when uploading media (#40075). Additionally, an incompatibility between the upcoming Chrome version and the visual editor (#40305) has been solved by updating TinyMCE. Furthermore, the REST API saw some enhancements in relation to date handling (#39854, #40136).

All Changes

Here’s a list of all closed tickets, sorted by component:

Administration

  • #39983 – Consider to don’t use the CSS class button-link for controls that don’t look like links
  • #40056 – Shift-click to select a range of checkboxes isn’t working anymore since 4.7.3 update

Bootstrap/Load

  • #39445 – Add class_exists() check before defining the PasswordHash class

Build/Test Tools

  • #38500 – Automatically cancel pending Travis builds with each commit
  • #39219 – Add assertNotFalse method to WP_UnitTestCase.
  • #39367 – Don’t no-op $user_id in test suite’s wp_set_auth_cookie()
  • #39988 – The theme used during tests should call wp_head() and wp_footer()
  • #40066 – Remove the twentysixteen git clone from the Travis config
  • #40086 – Get Travis tests working again on PHP 7

Bundled Theme

  • #40216 – Twenty Seventeen: Some parts do not escape html attributes
  • #40224 – Twenty Seventeen: navigation.js should be enqueued with jQuery as dependency
  • #40264 – Twenty Seventeen: Incorrect heading hierarchy for front page sections
  • #40461 – Twenty Seventeen: Bump version and update changelog

Customize

  • #31850 – Customizer links should use canonical admin URL
  • #37471 – Widgets: If your theme only has one widget area, we should open it automatically
  • #38953 – Customize Menus: clicking outside of the available menu items panel does not close the panel
  • #39430 – sections and panels that are open and become inactive should be closed
  • #39770 – Client-side notification error is unexpectedly cleared when no corresponding server-side validation
  • #40010 – Template for site icon control fails to check if full image size exists before using
  • #40018 – Selective refresh always falls back to full refreshes when customizing the 404 template
  • #40112 – Can’t preview starter content “Home” menu item in subdirectory installation
  • #40198 – all previewable links are blocked in the customize preview on IE11
  • #40271 – Use get_user_locale() in Customizer
  • #40277 – Adding page created with the dropdown-pages settings to menu creates Custom Link instead of Page
  • #40308 – Video header control fails to use is_header_video_active() for active_callback
  • #40405 – IE9 errors when attempting to generate changeset parameter

Login and Registration

  • #39497 – Can’t log out completely without closing my browser

Media

  • #31071 – media / post_mime_type related queries are very slow on larger sites
  • #40017 – wp_get_image_mime() returns ‘application/octet-stream’ for non-image files.
  • #40075 – Broken video/audio thumbnails because of corrupted blob meta data
  • #40085 – Audio/video uploads are broken in 4.2.13 and 4.3.9
  • #40152 – Crop Image button off-screen on mobile

Networks and Sites

  • #40036 – Re-save Network Settings ruin starter content
  • #40063 – Handle site cache invalidation more specifically for option updates

Posts, Post Types

  • #39986 – Register missing REST API properties on WP_Post_Type

Quick/Bulk Edit

  • #40242 – Bulk edit tag autocomplete layout error

REST API

  • #39854 – Add gmt_offset to base /wp-json response
  • #39881WP_REST_Posts_Controller::check_read_permission() should check if $parent exists before calling itself
  • #40027 – Tags and Categories should have a “slugs” parameter for batch fetching
  • #40136 – Issues with dates and DST
  • #40213 – Users endpoint slug parameter should allow an array of slugs

Taxonomy

  • #39987 – Register missing REST API properties on WP_Taxonomy
  • #40154 – Incorrectly formatted $taxonomies parameter passed to wp_get_object_terms filter
  • #40306 – Term cache isn’t cleared completely when setting and removing object terms

Themes

  • #38292 – Introduce exclusion for WP_Theme::scandir()

TinyMCE

  • #40305 – Image popup toolbar does not support Chrome Beta

Download the Release Candidate now and help us test!

#4-7, #4-7-4, #maintenance, #release

Dev Chat Agenda for April 19th (4.7.4 week 7)

This is the agenda for the weekly dev meeting on April 19, 2017 at 20:00 UTC:

  • 4.7.4 release timing
  • REST API: Plans for JavaScript in WP 4.8
  • General announcements

If you have anything to propose to add to the agenda or specific items related to the above, please leave a comment below. See you there!

#4-7, #4-7-4, #agenda, #dev-chat

Nearby WordPress Events

In an effort to grow awareness of WordPress community events like WordCamps and meetups, a group of us have been working to upgrade the WordPress News widget, adding WordCamps and meetups, as Matt mentioned in his recent post. We’ve created a plugin (background) called Nearby WordPress Events for testing and iteration. It turns the existing News widget on the Dashboard into WordPress Events and News, with a short list of upcoming nearby events above the usual news items.

WordPress Events and News widget

Why?

The community that has been created around WordPress is one of its best features, and one of the primary reasons for its success, but many users are still unaware that it exists, and aren’t taking advantage of all of the resources that it makes available to them.

Inviting more people to join the community will help to increase its overall health, diversity, and effectiveness, which in turn helps to ensure that WordPress will continue to thrive in the years to come.

We think that wp-admin is the perfect place to display these events, because that’s the place where almost all WordPress users are visiting already. Instead of expecting them to come to us, we can bring the relevant information directly to them.

How does it work?

In order to display events that are “nearby”, the plugin uses a determined location for the current user. If a site has multiple users, each one will be shown the events that are close to their individual location. The widget tries to automatically detect a user’s location, but they’ll also be able to enter any city they like.

The WordCamp and meetup event data for the plugin is provided by a new api.wordpress.org endpoint [source, documentation].

Feedback

We’ve solicited the Community team for testing and feedback and have made several improvements. Now we’d like to take it to the next level and get feedback from the Core team, in preparation for a proposal to merge it into Core, perhaps for WordPress 4.8.

Specifically, we’d like to get testing and feedback about:

  • UX: What is the user experience like? Is it easy to find a local event near you? Do you have trouble changing your location? Have we built the widget in an accessible way? (cc +make.wordpress.org/design)
  • Location detection: Does the widget accurately detect your location? If not, be sure to report your approximate location at the time you started using the plugin/widget.
  • City search: Does it find the city nearest to you with the name you searched? How well does it work when searching in languages other than English? Character sets other than Latin? (cc +make.wordpress.org/polyglots)

The best place to file issues is the GitHub repo.

 

Kudos to everyone who worked to make this a reality: @andreamiddleton, @azaozz, @camikaos, @coreymckrill, @chanthaboune, @courtneypk, @dd32, @iandunn, @iseulde, @mapk, @obenland, @pento, @samuelsidler, @stephdau, @tellyworth

#nearby-wordpress-events

Dev Chat Summary: April 12th (4.7.4 week 6)

This post summarizes the dev chat meeting from April 12th (agendaSlack archive).

4.7.4 Planning

  • There are currently 23 open tickets in the milestone
  • We had been aiming for an early May release, but an annoying bug (#40305, noted by @azaozz) related to TinyMCE and the upcoming Chrome release has forced us to reevaluate this strategy
  • After talking to Andrew and the security team, we decided on a new release date for WordPress 4.7.4: Tuesday, April 18, with April 20 as a fallback.
  • There will likely be an additional 4.7.5 release soon after this one

Customize Team

Editor Team

  • We’re in the long stretch of building and building, so we’re also holding “office hours” instead of weekly meetings.

REST API Team

General Announcements

  • @helen is going on leave after Friday, April 14th until August (probably 2017) (hopefully she meant 2017) (is it August yet?)

#4-7, #4-7-4, #core-customize, #core-editor, #core-restapi, #dev-chat, #summary

First Quarter Check-in

Just wanted to give folks my perception and feelings on of how we’re doing thus far with the core foci:

Writing: I’m really happy with the progress. It has had some slower weeks here and there the past few months, but by and large the technical prototypes we implemented have been successful and we’re ready to move into the next phase. We have a Chrome fix we have to get in the next minor release, and the link boundary improvements will be going into TinyMCE core and could be great for an interim +0.1 release.

Customization: Doing well. Remember: The plan is for the larger block-driven customization work to kick off in June. Prior to that, we’re focusing on widgets and other low-hanging fruit. Lack of developers slowed us down last few months, now doing better but could still use more help there. Media widgets + WYSIWYG on text widget seem simple but will have a big user impact.

REST API: There has been little to no perceivable progress on having any parts of wp-admin powered by the REST API.

Considering 4.8: The TinyMCE inline element / link boundaries, new media widgets, WYSIWYG in text widget, and perhaps something else small like the WordCamp / meetup dashboard upgrade to the “news” section, would comprise a nice chunk of new functionality for a +0.1 “major” release. I’m hopeful their progress over the remainder of April will allow us to kick off a process to do a nice 4.8 update in the May / June timeframe, without drawing too much focus away from the Big Changes in the next-generation editor that is still the top priority.

#4-8

Week in Core, April 5th – April 11th 2017

Welcome back the latest issue of Week in Core, covering changes [40376-40416]. Here are the highlights:

  • 41 commits
  • 26 contributors
  • 61 tickets created
  • 12 tickets reopened
  • 56 tickets closed

Ticket numbers based on trac timeline for the period above. The following is a summary of commits, organized by component.

Code Changes

Bootstrap/Load

Build/Test Tools

  • Build/Test tools: Improve the failure message reported by assertQueryTrue() so it’s a little less cryptic. [40416] #40411
  • Build/Test tools: Trim the test matrix on Travis in order to speed up the 3.8 branch build. [40407-40415] #40407
  • Add assertNotFalse() method to WP_UnitTestCase and use it where appropriate. [40388] #39219

Customize

  • Verify availability of history.replaceState (in IE9) before attempting to populate changeset_uuid parameter. [40405] #39227, #40405
  • Auto-expand a widget area section when expanding the Widgets panel if there is only one registered sidebar and it is active. [40395], [40402] #37471
  • Fix behavior of clicking Delete Menu link and keep available nav menu items panel open when doing bulk deletion. [40396], [40401] #38953
  • Fix HTTPS navigation of site in preview on IE11. [40381], [40386] #38409, #40198
  • Use is_header_video_active() as active_callback for external_header_video control instead of is_front_page(). [40379], [40384] #38738, #40308
  • Fix reversal of nav menu item’s type and object properties for page stub added in customizer. [40380], [40383] #38164, #40277

General

  • Build/Test tools: Remove occurrences of create_function() in unit tests. [40392] #37082

Media

Networks and Sites

  • Multisite: Replace unnecessary is_super_admin() check when setting up the initial network. [40406] #40406, #37616
  • Align the display of site statuses on the Sites listing screen with those of posts on the Posts listing screen. [40393] #40290
  • Multisite: Partially revert [40295]. [40391] #39676, #37616
  • Multisite: Handle sites cache invalidation more granularly for option updates. [40385] #40063

REST API

Role/Capability

TinyMCE

  • Update the tests for version 4.5.6. Remove default plugins tests, it is quite pointless to keep repeating them at this point. [40399] #40305
  • Update TinyMCE to 4.5.6. Has many improvements and bug [40398] #40305

Upgrade/Install

  • Introduce wp_disallow_file_mods() helper function. [40394] #38673

Thanks to @adamsilverstein, @ashokkumar24, @azaozz, @blobfolio, @curdin, @DavidAnderson, @delawski, @desrosj, @dhanendran, @flixos90, @jnylen0, @joemcgill, @johnbillion, @ketuchetan, @maguiar, @MatheusGimenez, @mattwiebe, @MaximeCulea, @melchoyce, @peterwilsoncc, @pratikshrestha, @sboisvert, @swissspidy, @timmydcrawford , @westonruter, and @wonderboymusic for their contributions!

#week-in-core