Skip to content

Repair wp/6.0 branch Actions: use PHPUnit Polyfills' set_up()/tear_down() fixture methods - #383

Closed
desrosj wants to merge 1 commit into
fix-actions-6.0/fix-phpunit-executionfrom
fix-actions-6.0/fix-setup-teardown-polyfills
Closed

desrosj wants to merge 1 commit into
fix-actions-6.0/fix-phpunit-executionfrom
fix-actions-6.0/fix-setup-teardown-polyfills

Conversation

@desrosj

@desrosj desrosj commented Sep 17, 2026

Copy link
Copy Markdown
Owner

What?

Fixes a fatal error, identical across all six PHP 7.4/8.0/8.1 (single-site and multisite) unit-test.yml legs, that blocks PHPUnit from even starting the test suite.

Why?

#380 (the base of this PR) bumped wp-phpunit/wp-phpunit to 6.0.x to fix a different, unrelated PHPUnit-startup gate. That bump changed WP_UnitTestCase's own ancestry: it now chains through yoast/phpunit-polyfills, whose TestCase class seals setUp()/tearDown() (and the static setUpBeforeClass()/tearDownAfterClass()) with a : void return type, and instead expects subclasses to override the snake_case set_up()/tear_down()/set_up_before_class()/tear_down_after_class() methods — a deliberate Polyfills design that keeps fixture methods callable on PHP versions that predate the void return type.

Nine test classes in this repository still declare the old camelCase fixture methods with no return type, which PHP treats as an incompatible override of the parent's typed declaration:

Fatal error: Declaration of WP_Block_Supports_Layout_Test::setUp() must be compatible with
Yoast\PHPUnitPolyfills\TestCases\TestCase::setUp(): void in phpunit/block-supports/layout-test.php

This is fatal on every PHP-version leg where PHP itself supports typed return declarations (7.1+), which covers 7.4/8.0/8.1 of the current matrix.

How?

Renames each affected method to its Polyfills-expected name, including the corresponding parent:: call where one exists. Checked each of the 9 files individually rather than assuming a uniform pattern — some notable differences found along the way:

  • phpunit/class-wp-webfonts-local-provider-test.php already had a correctly-named tear_down(); only its setUp() needed renaming.
  • phpunit/navigation-test.php's setUp()/tearDown() never call parent::setUp()/parent::tearDown(), so only the method names themselves needed changing.
  • phpunit/navigation-page-test.php is the only file with static setUpBeforeClass()/tearDownAfterClass() overrides in addition to the instance methods — all four needed renaming.
  • phpunit/class-wp-test-rest-users-controller.php also defines wpSetUpBeforeClass()/wpTearDownAfterClass() — a separate, WP-specific factory convention (not PHPUnit's own fixture methods) — left untouched.

Testing

php -l passes on all 9 changed files. Real CI evidence: triggered a run on this PR and confirmed the specific Declaration of ... setUp() must be compatible with ... TestCase::setUp(): void fatal error no longer occurs on the previously-failing PHP 7.4/8.0/8.1 legs.

Use of AI Tools

This PR was created by Claude Code under my supervision. All code should be treated as AI-produced and not yet reviewed by a human until this PR is marked Ready for Review.

@desrosj desrosj self-assigned this Sep 17, 2026
@desrosj
desrosj added this pull request to stack #329 September 17, 2026 03:49
@desrosj
desrosj force-pushed the fix-actions-6.0/fix-setup-teardown-polyfills branch from d51b5c7 to cff18f8 Compare September 18, 2026 19:27
@desrosj
desrosj removed this pull request from stack #329 September 21, 2026 18:46
@desrosj
desrosj changed the base branch from fix-actions-6.0/fix-phpunit-execution to wp/6.0 September 21, 2026 18:47
@desrosj
desrosj force-pushed the fix-actions-6.0/fix-setup-teardown-polyfills branch from cff18f8 to 132d88d Compare September 21, 2026 18:52
@desrosj
desrosj changed the base branch from wp/6.0 to fix-actions-6.0/fix-phpunit-execution September 21, 2026 18:54
@desrosj
desrosj added this pull request to stack #404 September 21, 2026 18:54
@desrosj
desrosj removed this pull request from stack #404 September 21, 2026 19:38
@desrosj
desrosj changed the base branch from fix-actions-6.0/fix-phpunit-execution to wp/6.0 September 21, 2026 19:39
@desrosj
desrosj force-pushed the fix-actions-6.0/fix-setup-teardown-polyfills branch from 132d88d to 3b603e9 Compare September 21, 2026 19:42
@desrosj
desrosj changed the base branch from wp/6.0 to fix-actions-6.0/fix-phpunit-execution September 21, 2026 19:45
@desrosj
desrosj added this pull request to stack #418 September 21, 2026 19:45
@desrosj
desrosj removed this pull request from stack #418 September 21, 2026 21:52
@desrosj
desrosj changed the base branch from fix-actions-6.0/fix-phpunit-execution to wp/6.0 September 21, 2026 21:53
@desrosj
desrosj force-pushed the fix-actions-6.0/fix-setup-teardown-polyfills branch from 3b603e9 to e395188 Compare September 21, 2026 21:55
@desrosj
desrosj changed the base branch from wp/6.0 to fix-actions-6.0/fix-phpunit-execution September 21, 2026 21:56
@desrosj
desrosj added this pull request to stack #429 September 21, 2026 21:57
@desrosj
desrosj removed this pull request from stack #429 September 21, 2026 23:49
@desrosj
desrosj changed the base branch from fix-actions-6.0/fix-phpunit-execution to wp/6.0 September 21, 2026 23:50
@desrosj
desrosj changed the base branch from wp/6.0 to fix-actions-6.0/fix-phpunit-execution September 21, 2026 23:52
@desrosj
desrosj added this pull request to stack #438 September 21, 2026 23:52
@desrosj
desrosj removed this pull request from stack #438 September 22, 2026 15:57
@desrosj
desrosj changed the base branch from fix-actions-6.0/fix-phpunit-execution to wp/6.0 September 22, 2026 15:58
@desrosj
desrosj force-pushed the fix-actions-6.0/fix-setup-teardown-polyfills branch from e395188 to 26c5f0b Compare September 22, 2026 16:00
@desrosj
desrosj changed the base branch from wp/6.0 to fix-actions-6.0/fix-phpunit-execution September 22, 2026 16:01
@desrosj
desrosj added this pull request to stack #502 September 23, 2026 21:30
@desrosj
desrosj force-pushed the fix-actions-6.0/fix-setup-teardown-polyfills branch from c97d253 to fd9658c Compare September 24, 2026 00:38
@desrosj
desrosj force-pushed the fix-actions-6.0/fix-setup-teardown-polyfills branch from fd9658c to 4a13744 Compare September 24, 2026 02:44
@desrosj
desrosj removed this pull request from stack #502 September 24, 2026 18:18
@desrosj
desrosj changed the base branch from fix-actions-6.0/fix-phpunit-execution to wp/6.0 September 24, 2026 18:18
@desrosj
desrosj force-pushed the fix-actions-6.0/fix-setup-teardown-polyfills branch from 4a13744 to 0ce719f Compare September 24, 2026 18:18
@desrosj
desrosj changed the base branch from wp/6.0 to fix-actions-6.0/fix-phpunit-execution September 24, 2026 18:19
@desrosj
desrosj added this pull request to stack #522 September 24, 2026 18:19
@desrosj
desrosj removed this pull request from stack #522 September 28, 2026 14:36
@desrosj
desrosj changed the base branch from fix-actions-6.0/fix-phpunit-execution to wp/6.0 September 28, 2026 14:37
@desrosj
desrosj force-pushed the fix-actions-6.0/fix-setup-teardown-polyfills branch from 0ce719f to 95398c7 Compare September 28, 2026 14:37
@desrosj
desrosj changed the base branch from wp/6.0 to fix-actions-6.0/fix-phpunit-execution September 28, 2026 14:38
@desrosj
desrosj added this pull request to stack #543 September 28, 2026 14:38
@desrosj
desrosj removed this pull request from stack #543 September 28, 2026 19:11
@desrosj
desrosj changed the base branch from fix-actions-6.0/fix-phpunit-execution to wp/6.0 September 28, 2026 19:11
@desrosj
desrosj force-pushed the fix-actions-6.0/fix-setup-teardown-polyfills branch from 95398c7 to f3a8908 Compare September 28, 2026 19:12
@desrosj
desrosj changed the base branch from wp/6.0 to fix-actions-6.0/fix-phpunit-execution September 28, 2026 19:12
@desrosj
desrosj added this pull request to stack #569 September 28, 2026 19:12
@desrosj
desrosj removed this pull request from stack #569 October 5, 2026 18:42
@desrosj
desrosj added this pull request to stack #605 October 5, 2026 18:43
@desrosj
desrosj force-pushed the fix-actions-6.0/fix-setup-teardown-polyfills branch from f3a8908 to 37889bf Compare October 5, 2026 20:55
@desrosj
desrosj removed this pull request from stack #605 October 5, 2026 20:55
@desrosj
desrosj added this pull request to stack #618 October 5, 2026 20:56
…lasses.

wp-phpunit/wp-phpunit 6.0.14's WP_UnitTestCase now chains through
yoast/phpunit-polyfills, whose TestCase seals setUp()/tearDown()
(and the static setUpBeforeClass()/tearDownAfterClass()) with a
`: void` return type and expects subclasses to override the
snake_case set_up()/tear_down()/set_up_before_class()/tear_down_after_class()
methods instead — a deliberate Polyfills design so fixture methods stay
callable on PHP versions that predate the `void` return type.

Nine test classes still declared the old camelCase methods without a
return type, which PHP considers an incompatible override of the
parent's typed declaration:

    Fatal error: Declaration of WP_Block_Supports_Layout_Test::setUp()
    must be compatible with Yoast\PHPUnitPolyfills\TestCases\TestCase::setUp(): void

This is fatal on every PHP-version leg where PHP itself supports typed
return declarations (7.1+), which is most of unit-test.yml's matrix.

Renames each to its Polyfills-expected name, including the
corresponding parent:: call where one exists. WP_Test_REST_Users_Controller's
wpSetUpBeforeClass()/wpTearDownAfterClass() are a separate, WP-specific
factory convention (not PHPUnit's own fixture methods) and are left as
they are.
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: desrosj <desrosj@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@desrosj

desrosj commented Oct 8, 2026

Copy link
Copy Markdown
Owner Author

Moved to WordPress#84280.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant