Make WordPress Core

Opened 8 months ago

Closed 3 months ago

Last modified 2 months ago

#64894 closed task (blessed) (fixed)

Test tool and unit test improvements for 7.1

Reported by: desrosj Owned by:
Priority: normal Milestone: 7.1
Component: Build/Test Tools Version:
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses:

Description

This ticket is for various fixes and improvements in PHPUnit tests that don't have a more specific ticket, as well as general improvements to the GitHub Actions workflows that run automated testing.

Previous releases:

Change History (90)

This ticket was mentioned in ​PR #11381 on ​WordPress/wordpress-develop by ​@desrosj.


8 months ago
#1

  • Keywords has-patch has-unit-tests added

This fixes a failing tst that seems to be caused by the fact that MySQL changed the content on release pages.

Unfortunately, it does not seem like there is an official API available from MySQL itself. However, endoflife.date is an open source, MIT licensed, reasonably maintained project that does have an endpoint available.

Trac ticket: Core-64894.

## Use of AI Tools

AI Assistance: Yes
Tool(s): Claude Code
Model(s): Sonnet 4.6
Used for: Searching for possible APIs to use to replace parsing an HTML document.

#2 @desrosj
8 months ago

In 62170:

Tests: Fix test that checks MySQL version recommendation.

A test in the external-http group that detects when the recommended version of MySQL is too old is failing due to an upstream change to the content of version documentation pages.

Because the required information is no longer on the page, this switches to using the public API from endoflife.date. This site is an open source (MIT licensed) resource that is actively maintained.

Props peterwilsoncc.
See #64894.

​@desrosj commented on ​PR #11381:


8 months ago
#3

Merged in r62170.

This ticket was mentioned in ​PR #11433 on ​WordPress/wordpress-develop by ​@johnbillion.


7 months ago
#4

The e2e and performance tests switched from Puppeteer to Playwright. One of the things that prevents Puppeteer being removed as a dependency is the grunt-contrib-qunit test runner which uses Puppeteer.

This replaces the runner with a Playwright config.

Notes:

  • grunt-contrib-qunit reports test counts, this Playwright config reports assertion counts, hence the number of passes has changed from 456 to 535. The actual tests and assertions have not changed.
  • puppeteer-core is still a transitive dependency after this change due to wp-scripts and lighthouse. One step at a time.
  • qunit/editor hasn't existed since https://core.trac.wordpress.org/changeset/40584 nine years ago.

​@johnbillion commented on ​PR #11433:


7 months ago
#5

After further thought, I think the AppArmor config in .github/workflows/reusable-javascript-tests.yml will need to be retained. Removing it will cause older branches that use Puppeteer to start failing.

#6 @SergeyBiryukov
6 months ago

In 62370:

Tests: Correct some test class names.

Follow-up to [62313], [62352], [62366].

See #64894.

This ticket was mentioned in ​PR #11925 on ​WordPress/wordpress-develop by ​@johnbillion.


6 months ago
#7

Trac ticket: https://core.trac.wordpress.org/ticket/64894

## Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 4.7
Used for: Initial investigation and changes, with follow-ups and fixes by me.

This ticket was mentioned in ​PR #11810 on ​WordPress/wordpress-develop by ​@desrosj.


6 months ago
#8

​MySQL 9.7.0 LTS was released on April 21, 2026.

The testing matrices should be updated to reflect this. Also, there are now no MySQL innovation releases actively supported until a new one is published in a few months.

Trac ticket: https://core.trac.wordpress.org/ticket/64894

## Use of AI Tools

None.

#9 @desrosj
6 months ago

In 62407:

Build/Test Tools: Add MySQL 9.7 to relevenat test matrices.

This adds 9.7 (released on April 21, 2026) to the relevant testing strategies and makes it the default version in the local Docker environment.

MySQL 9.7 is also an LTS release.

Props chrisdavidmiles.
See #64894.

​@desrosj commented on ​PR #11810:


6 months ago
#10

Merged in r62407.

#11 @johnbillion
6 months ago

In 62411:

Build/Test Tools: Switch from Puppeteer to Playwright for the QUnit test runner.

This brings the QUnit tests inline with the e2e and performance tests that switched to Playwright in #59517.

This removes the puppeteer dependency, but puppeteer-core remains a transitive dependency due to wp-scripts and lighthouse.

See #64894

This ticket was mentioned in ​PR #12073 on ​WordPress/wordpress-develop by ​@jorbin.


5 months ago
#13

Use a dataProvider in order to simplify code

Trac ticket: https://core.trac.wordpress.org/ticket/64894

## Use of AI Tools

AI assistance: Yes
Tool(s): GitHub Copilot and Opencode
Model(s): Claude Sonnet 4.6
Used for: Initial code investigation and suggestions; final implementation was reviewed and edited by me.

#14 @jorbin
5 months ago

In 62462:

Build/Test Tools: Convert repetitive s-type methods to use a @dataProvider

Make it easier to add additional test cases for parse_query and query_var[s] tests.

See #64894.

#16 @jorbin
5 months ago

In 62463:

Build/Test Tools: Fix comment for tax query test.

B !== A (at least in this instance).

See #64894.

#17 @desrosj
5 months ago

In 62464:

Build/Test Tools: Correct the Multisite PHPUnit log path.

The tests/phpunit part of the logging file path in the multisite.xml configuration file is unnecessary because it already exists within that directory.

See #64894.

#18 @jorbin
5 months ago

In 62500:

Build/Test: Fix documentation that describes each step in coding standard and phpstan workflows.

Props khokansardar, jorbin.
See #64894. Fixes #65391.

This ticket was mentioned in ​PR #12208 on ​WordPress/wordpress-develop by ​@Soean.


5 months ago
#19

This pull request updates and clarifies parameter names and docblocks in various PHPUnit test files to improve code readability and maintainability. The changes primarily focus on making parameter names more descriptive and aligning them with their actual usage in the test methods.

These updates do not affect test logic but enhance code quality and developer experience by making the test suite easier to understand and maintain.

Trac ticket: https://core.trac.wordpress.org/ticket/64894

This ticket was mentioned in ​PR #12238 on ​WordPress/wordpress-develop by ​@desrosj.


5 months ago
#20

This pins the Gutenberg plugin to version 23.3.2 (the last version compatible with WP 6.8) in E2E test workflow.

Trac ticket: Core-64894, Core-64894.

## Use of AI Tools

None.

#21 @desrosj
5 months ago

In 62541:

Build/Test Tools: Run the external-http test group first.

Tests in the external-http group are skipped by default and only run when explicitly specified using the --group flag. In the PHPUnit test workflow, this group is run after the full test suite. Because HTTP requests are made to external sites and APIs, there are occasionally failures due to service or network outatges.

This changes the order of the PHPUnit test commands so that the external-http group runs first. This ensures the run fails early when there are issues within the external-http tests and avoids needlessly running the full test suite.

Props desrosj, mukesh27, johnbillion.
See #64893, #64894.

#22 @desrosj
5 months ago

In 62544:

Build/Test Tools: Pin Gutenberg version for E2E tests in 6.8.

This pins the last version of the Gutenberg plugin compatible with the 6.8 branch (23.4.0) to the E2E test workflow.

Previously in other branches: [59518], [60214], [61667].

See #64893, #64894.

​@desrosj commented on ​PR #12238:


5 months ago
#23

Merged in r62544.

This ticket was mentioned in ​PR #12301 on ​WordPress/wordpress-develop by ​@Soean.


5 months ago
#24

The sprintf( '/wp/v2/posts' ) call wraps a plain string literal without any placeholders or additional arguments, so it returns the string unchanged. Passing the literal directly to WP_REST_Request is equivalent and clearer.

Trac ticket: https://core.trac.wordpress.org/ticket/64894

This ticket was mentioned in ​PR #12302 on ​WordPress/wordpress-develop by ​@Soean.


5 months ago
#25

## Description
Tests_Compat_mbSubstr::data_utf8_substrings() declared every data set with the same array key 'баба'. Since PHP keeps only the last value for a duplicate array key, all but the final 'баба' entry were silently discarded — only 2 of the 12 intended cases were actually executed by test_mb_substr() and test_8bit_mb_substr().

This change replaces the duplicated keys with unique, descriptive ones that name the $start / $length scenario each case covers (e.g. negative start, positive length, start beyond length, large negative length). All previously dropped cases now run, and failures point directly to the relevant scenario.

The duplicate keys were introduced in [60969].

## Testing instructions
Run the affected tests:
npm run test:php -- --filter Tests_Compat_mbSubstr tests/phpunit/tests/compat/mbSubstr.php

Before: (23 tests)
Now: (43 tests) - the data provider now contributes 12 distinct cases per test method instead of 2.

Trac ticket: https://core.trac.wordpress.org/ticket/64894

This ticket was mentioned in ​PR #12303 on ​WordPress/wordpress-develop by ​@Soean.


5 months ago
#26

## Description

Tests_Formatting_SanitizeKey::data_sanitize_key() declared two data sets with the same key 'a lowercase key with commas'. Since PHP keeps only the last value for a duplicate array key, the first case (howdy,admin) was silently discarded and never ran.

On top of that, the second case is mislabeled: its input is HOWDY,ADMIN, i.e. uppercase, not lowercase. Together with the following 'a mixed case key with commas' case, the clear intent is to cover lowercase / uppercase / mixed input.

This renames the second case to 'an uppercase key with commas', fixing both the duplicate key and the inaccurate label, and restoring the dropped lowercase case.

The duplicate key was introduced in [52292].

## Testing instructions
Run the affected tests:
npm run test:php -- --filter Tests_Formatting_SanitizeKey tests/phpunit/tests/formatting/sanitizeKey.php

All cases pass, and the data provider now contributes the lowercase, uppercase, and mixed-case scenarios instead of dropping the lowercase one.

Trac ticket: https://core.trac.wordpress.org/ticket/64894

This ticket was mentioned in ​PR #12329 on ​WordPress/wordpress-develop by ​@Soean.


5 months ago
#27

Corrects the data provider label in Tests_Post_TruncatePostSlug: the test case with length=12 was incorrectly named "fifth" instead of "sixth", duplicating the key of the previous test case. As a result, the length=12 test was silently overwritten and never executed. This fix restores the correct label so both boundary cases are now covered.

Trac ticket: https://core.trac.wordpress.org/ticket/64894

This ticket was mentioned in ​PR #12331 on ​WordPress/wordpress-develop by ​@Soean.


5 months ago
#28

Renames the duplicate data provider key "with other og meta" to "with other og meta and HTML content" in Tests_REST_WpRestUrlDetailsController. The key appeared twice (lines 957 and 1023), causing the first test case to be silently overwritten by the second and never executed. The new name also better describes what the test covers: og meta tags whose content attribute contains HTML markup.

Trac ticket: https://core.trac.wordpress.org/ticket/64894

#31 @dmsnell
5 months ago

In 62576:

Compat: Fix mb_substr() polyfill for out-of-range offsets.

The delegation to substr() in the _mb_substr() polyfill left some results returning false on PHP < 8.0, but mb_substr() always returns an empty string in these cases.

This patch updates the behavior to match mb_substr(). Some issues were not detected due to duplicate test names that appeared in the [60969] refactor. These have been corrected as part of this patch.

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/12302
Discussed in: https://core.trac.wordpress.org/ticket/64894

Follow-up to [60969].

Props dmsnell, soean.
See #64894.

#33 @SergeyBiryukov
4 months ago

In 62621:

Tests: Correct @covers tags for test_get_cookie_host_only().

Follow-up to [45135], [50344].

See #64894.

#34 @SergeyBiryukov
4 months ago

In 62638:

Tests: Correct duplicate data set key in sanitize_key() tests.

Follow-up to [52292].

Props Soean.
See #64894.

This ticket was mentioned in ​PR #12412 on ​WordPress/wordpress-develop by ​@Soean.


4 months ago
#37

Removes redundant array entries that were silently overwritten by a later key with the same name.

Trac ticket: https://core.trac.wordpress.org/ticket/64894

#38 @SergeyBiryukov
4 months ago

In 62643:

Tests: Remove unnecessary sprintf() call in wp_after_insert_post() tests.

Follow-up to [49731].

Props Soean.
See #64894.

#40 @SergeyBiryukov
4 months ago

In 62660:

Tests: Correct test case name in _truncate_post_slug() tests.

Follow-up to [55208].

Props Soean, mukesh27.
See #64894.

#41 @SergeyBiryukov
4 months ago

In 62665:

Tests: Correct duplicate data set key in WP_REST_URL_Details_Controller tests.

Follow-up to [51973].

Props Soean, mukesh27.
See #64894.

#44 @SergeyBiryukov
4 months ago

In 62675:

Tests: Remove duplicated array keys in test data.

This removes redundant array entries that were silently overwritten by a later key with the same name.

Follow-up to [943/tests], [53941], [59866].

Props Soean.
See #64894.

This ticket was mentioned in ​PR #12464 on ​WordPress/wordpress-develop by ​@jorbin.


4 months ago
#46

Follow-up to: r62676, r62677.

Trac Ticket: https://core.trac.wordpress.org/ticket/64894

AI assistance: Yes
Tool(s): Claude Code
Model(s): Sonnet 5
Used for: Initial code skeleton, final implementation was reviewed and modified by me

#47 @jorbin
4 months ago

In 62713:

Build/Test: Add tests to enforce -src in version.

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/12464

Follow-up to: r62676, r62677.

Props jorbin, desrosj.
See #64894.

This ticket was mentioned in ​PR #12509 on ​WordPress/wordpress-develop by ​@jonsurrell.


4 months ago
#49

The web-platform-tests test suite for the HTML API (previously html5lib-tests) used return for the final case, which is not reached by iteration. The final test case in each test file was never run.

Diff with trunk: ./vendor/bin/phpunit --group=html-api-web-platform-tests

-Tests: 1655, Assertions: 1221, Skipped: 434.
+Tests: 1707, Assertions: 1261, Failures: 1, Skipped: 446.

The failure is due to ​https://github.com/web-platform-tests/wpt/pull/61257 (an incorrect tree in WPT) and is temporarily disabled on this branch.

Trac ticket: https://core.trac.wordpress.org/ticket/64894

This ticket was mentioned in ​PR #12511 on ​WordPress/wordpress-develop by ​@Soean.


4 months ago
#50

Using the dedicated boolean assertions clarifies intent and produces more descriptive failure messages.

Trac ticket: https://core.trac.wordpress.org/ticket/64894

#51 @jonsurrell
4 months ago

In 62724:

Build/Test Tools: Run the final HTML API web platform test case.

The web-platform-tests data provider used return instead of yield for the last case in each file, preventing it from running.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/12509.

Follow-up to [58010].

See #64894.

​@jonsurrell commented on ​PR #12509:


4 months ago
#52

Merged in r62724.

This ticket was mentioned in ​PR #12513 on ​WordPress/wordpress-develop by ​@Soean.


4 months ago
#53

Replace boolean assertions wrapping other checks with the dedicated PHPUnit assertions:

  • assertContains()/assertNotContains() instead of in_array() or array_search() wrapped in assertTrue()/assertFalse().
  • assertEmpty() instead of assertTrue( empty( ... ) ).
  • assertDirectoryExists() instead of assertTrue( is_dir( ... ) ). This clarifies intent and produces more descriptive failure messages.

Trac ticket: https://core.trac.wordpress.org/ticket/64894

This ticket was mentioned in ​PR #12515 on ​WordPress/wordpress-develop by ​@Soean.


4 months ago
#54

Replace foreach loops calling assertInstanceOf() on each element with a single assertContainsOnlyInstancesOf() assertion. This clarifies intent, reduces boilerplate, and produces more descriptive failure messages.

Docs: ​https://docs.phpunit.de/en/13.2/assertions.html#assertcontainsonlyinstancesof

Trac ticket: https://core.trac.wordpress.org/ticket/64894

​@SergeyBiryukov commented on ​PR #12513:


4 months ago
#55

Thanks for the PR! The wpdb changes should probably be reverted, they cause warnings when running the tests:

Undefined property: wpdb::$dbh

This ticket was mentioned in ​PR #12521 on ​WordPress/wordpress-develop by ​@jonsurrell.


4 months ago
#56

Update web platform tests to latest version.
Remove invalid test skip (fixed): ​https://github.com/web-platform-tests/wpt/pull/61257

Trac ticket: https://core.trac.wordpress.org/ticket/64894
Follow-up to r62724.

## Use of AI Tools

#57 @jonsurrell
4 months ago

In 62734:

Build/Test Tools: Update the HTML API web platform tests.

Update the web-platform-tests data files to the latest upstream revision and removes a skip for an invalid test case that has since been fixed upstream.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/12521.

Follow-up to [62724].

See #64894.

​@jonsurrell commented on ​PR #12521:


4 months ago
#58

Merged in r62734.

​@Soean commented on ​PR #12513:


4 months ago
#59

Thanks for the feedback, I updated the code.

#60 @wildworks
4 months ago

In 62751:

Tests: Use assertContainsOnlyInstancesOf() over per-item loops.

Replace foreach loops that call assertInstanceOf() on each element with a single assertContainsOnlyInstancesOf() assertion.

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/12515

Props mukesh27, soean, wildworks.
See #64894.

This ticket was mentioned in ​PR #12537 on ​WordPress/wordpress-develop by ​@Soean.


4 months ago
#61

Replace verbose isset()-and-return blocks with the ?? operator in the object cache helper and font-face test dataset.

Trac ticket: https://core.trac.wordpress.org/ticket/64894

#62 @SergeyBiryukov
4 months ago

In 62761:

Tests: Use more specific assertions instead of assertTrue()/assertFalse().

Replace boolean assertions wrapping other checks with the dedicated PHPUnit assertions:

  • assertContains()/assertNotContains() instead of in_array() or array_search() wrapped in assertTrue()/assertFalse().
  • assertDirectoryExists() instead of assertTrue( is_dir( ... ) ). This clarifies intent and produces more descriptive failure messages.

Props Soean, mukesh27, SergeyBiryukov.
See #64894.

This ticket was mentioned in ​PR #12558 on ​WordPress/wordpress-develop by ​@Soean.


4 months ago
#64

This refactors the tests in tests/phpunit/tests/formatting/urlShorten.php and adds coverage that was missing.

### Misplaced test argument

The case meant to test the optional $length parameter passed the length as the third argument to assertSame():

$this->assertSame( 'wordpress.org/about/philosophy/#&hellip;', url_shorten( 'http://wordpress.org/about/philosophy/#decisions' ), 31 );

That third argument is assertSame()'s $message, not the URL length. So url_shorten() ran with its default length of 35, the expected value happened to match the default output, and the assertion passed — while the $length parameter was never actually tested.

### Changes

  • Convert the tests to @dataProvider data sets with descriptive keys, so a failure points to the exact case.
  • Separate the default-behaviour cases from the custom-length cases.
  • Add real coverage for $length: the URL is kept when the length exceeds or equals the cleaned URL (pinning the strict > comparison) and shortened when it is smaller.
  • Add a comment clarifying that a shortened URL is cut to ( $length - 3 ) characters before &hellip; is appended.

No production code is changed — this is a test-only improvement.

All tests pass locally via npm run test:php -- --filter Tests_Formatting_UrlShorten (9 tests, 9 assertions).

Trac ticket: https://core.trac.wordpress.org/ticket/64894

#66 @SergeyBiryukov
4 months ago

In 62768:

Tests: Improve coverage for url_shorten() and test the $length parameter.

The case meant to test the optional $length parameter passed it as an argument to assertSame() instead of url_shorten(). So the latter ran with its default length of 35, the expected value happened to match the default output, and the assertion passed — while the $length parameter was never actually tested.

This commit:

  • Converts the tests to a data provider with descriptive keys, so a failure points to the exact case.
  • Separates the default-behavior cases from the custom-length cases.
  • Adds real coverage for $length: the URL is kept when the length exceeds or equals the cleaned URL (pinning the strict > comparison) and shortened when it is smaller.
  • Adds a comment clarifying that a shortened URL is cut to ( $length - 3 ) characters before &hellip; is appended.

No production code is changed — this is a test-only improvement.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/12558.

Follow-up to [35314].

Props Soean, mukesh27, SergeyBiryukov.
See #64894.

#68 @SergeyBiryukov
4 months ago

In 62795:

Tests: Use wp_parse_url() in plugin management REST API endpoint tests.

This resolves a warning in preparation for updating to WPCS 3.4.0:

Silencing errors is strongly discouraged. Use proper error checking instead.

Additionally, this brings consistency with a similar fragment in the pattern directory endpoint tests, which already used wp_parse_url().

Follow-up to [48242], [51021].

See #64894.

This ticket was mentioned in ​PR #12599 on ​WordPress/wordpress-develop by ​@peterwilsoncc.


4 months ago
#69

Try speeding up the AJAX test suite by re-using roles between tests.

Trac ticket: https://core.trac.wordpress.org/ticket/64894

## Use of AI Tools

VS Code/Co-pilot type ahead.

​@peterwilsoncc commented on ​PR #12599:


4 months ago
#70

This is a nope. Creating the shared fixtures in the test suite slows things down rather than speeds thigns up.

A lot of accounts are created but evidently fewer than this PR creates.

#71 @SergeyBiryukov
4 months ago

In 62802:

Tests: Move get_file_data() tests to their own file.

This aims to make the tests more discoverable and easier to expand.

Includes converting the tests to use a named data provider.

Follow-up to [703/tests], [51182].

Props birgire, gschoppe, sukhendu2002, SergeyBiryukov.
See #42517, #64894.

#72 @westonruter
4 months ago

In 62808:

Build/Test Tools: Fix typing and logic issues in MockAction.

  • Add type information.
  • Fix erroneous fallback case for MockAction::current_filter() in how it gets the last key of $wp_actions.
  • Fix MockAction::get_call_count() to handle getting counts of a provided filter in addition to a provided action.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/12618.

See #64898, #64894.

#73 @SergeyBiryukov
4 months ago

In 62809:

Tests: Move WP_Theme::get_post_templates() tests to their own file.

This aims to make the tests more discoverable and easier to expand.

Follow-up to [41975].

See #64894.

#74 @SergeyBiryukov
4 months ago

In 62852:

Tests: Improve On This Day dashboard widget tests.

Includes:

  • Adding the missing @ticket 65116 annotation to each test method, so the tests are discoverable via the ticket group as required by the core test conventions.
  • Moving the repeated author user creation into shared wpSetUpBeforeClass() fixtures.
  • Renaming the test class to match the wp_dashboard_on_this_day() function name.

No production code is touched and no test assertions change; this only reduces duplicated setup and the number of users created per test run.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/12634.

Follow-up to [62681].

Props mukesh27, westonruter, joedolson, SergeyBiryukov.
See #65116, #64894.

#75 @SergeyBiryukov
4 months ago

In 62870:

Tests: Use null coalescing operator over isset() checks.

This commit replaces verbose isset()-and-return blocks with the ?? operator in the object cache helper and font-face test dataset.

Follow-up to [40561], [56500], [59260].

Props Soean, mukesh27.
See #64894.

​@SergeyBiryukov commented on ​PR #12537:


4 months ago
#76

Thanks for the PR! Merged in r62870.

#77 @wildworks
3 months ago

In 62957:

Tests: Correct @param tags in various test methods.

Some @param tags did not match their method signatures. This corrects the names and types, and removes the tags for parameters that no longer exist.

Two @dataProvider annotations also had no effect. The one on test_prepare_item() is removed, and test_get_items_search_type_post_subtype_invalid() now accepts $method and passes it to the request.

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/12208

Props Soean, mukesh27, wildworks.
See #64894.

#79 @SergeyBiryukov
3 months ago

In 62969:

Tests: Use assertTrue()/assertFalse() instead of assertSame() with booleans.

Using the dedicated boolean assertions clarifies intent and produces more descriptive failure messages.

Follow-up to [51453].

Props Soean, mukesh27.
See #64894.

​@SergeyBiryukov commented on ​PR #12511:


3 months ago
#80

Thanks for the PR! Merged in r62969.

This ticket was mentioned in ​PR #12818 on ​WordPress/wordpress-develop by ​@Soean.


3 months ago
#81

Using the dedicated assertNull() assertion instead of assertSame( null, $actual ) clarifies intent and produces more descriptive failure messages.

Trac ticket: https://core.trac.wordpress.org/ticket/64894

This ticket was mentioned in ​PR #12834 on ​WordPress/wordpress-develop by ​@Soean.


3 months ago
#82

## What

Fixes an incorrect inline @var annotation in WP_Test_REST_Users_Controller::test_get_items_only_fetches_ids_for_head_requests().

The $query variable comes from the pre_user_query filter args and is a WP_User_Query instance, the assertInstanceOf( WP_User_Query::class, ... ) on the line above asserts exactly that. The docblock incorrectly declared it as WP_User.

## Why

WP_User has no query_vars property, so the wrong annotation causes static analysis tools (PHPStan) and IDEs to report false errors on the following $query->query_vars accesses, and it misleads anyone reading the test

Trac ticket: https://core.trac.wordpress.org/ticket/64894

#83 @desrosj
3 months ago

I've gone and created #65819 for the 7.2 release cycle, but it looks like there are 2 outstanding PRs remaining here.

@SergeyBiryukov would you be able to wrap those two up so this can be closed out before RC2 next week?

#84 @SergeyBiryukov
3 months ago

In 63160:

Tests: Correct @var annotation in REST users controller tests.

The $query variable comes from the pre_user_query filter args and is a WP_User_Query instance, the assertInstanceOf( WP_User_Query::class, ... ) on the line above asserts exactly that. The docblock incorrectly declared it as WP_User.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/12834.

Follow-up to r59899.

Props Soean.
See #64894.

​@SergeyBiryukov commented on ​PR #12834:


3 months ago
#85

Thanks for the PR! Merged in r63160.

#86 @SergeyBiryukov
3 months ago

In 63161:

Tests: Use assertNull() instead of assertSame() with null.

Using the dedicated assertNull() assertion instead of assertSame( null, $actual ) clarifies intent and produces more descriptive failure messages.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/12818.

Follow-up to r62969.

Props Soean.
See #64894.

​@SergeyBiryukov commented on ​PR #12818:


3 months ago
#87

Thanks for the PR! Merged in r63161.

#88 @SergeyBiryukov
3 months ago

  • Resolution → fixed
  • Status new → closed

This ticket was mentioned in ​PR #13557 on ​WordPress/wordpress-develop by ​@jonsurrell.


2 months ago
#89

Update the HTML API's Web Platform Tests snapshot from WPT revision ​`45337b8` to ​`d556bd7`, following the procedure in tests/phpunit/data/web-platform-tests/README.md.

Eight .dat files change: seven are updated and scripted_foster01.dat is new. Tree-construction cases go from 1,920 to 1,959.

Five of the new cases do not pass and are added to SKIP_TESTS:

  • html5test-com/line0149, html5test-com/line0160 and html5test-com/line0193: the HTML Processor parses CDATA sections at SVG and MathML integration points as bogus comments. #12539 fixes this.
  • template/line0606 and template/line0619: the HTML Processor does not reset the frameset-ok flag when the BODY element is inserted implicitly from the "after head" insertion mode (​whatwg/html#12908).

The new adoption agency and foster parenting cases need no entry. The processor raises WP_HTML_Unsupported_Exception on them and the existing handler in the test already skips those.

Validation: --group html-api is 1,728 tests, 6,156 assertions, 1 skipped. --group html-api-web-platform-tests is 1,725 tests, 1,276 assertions, 449 skipped. phpcs is clean on the changed test file.

#12539 carries this same resync so its new CDATA cases are covered. It will drop its copy once this lands.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Copying the upstream data files, identifying which new cases fail and why, and drafting this description.

---
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See ​GitHub Pull Requests for Code Review in the Core Handbook for more details.

🤖 Generated with ​Claude Code

​@jonsurrell commented on ​PR #13557:


2 months ago
#90

Merged in r63651.

Note: See TracTickets for help on using tickets.