Skip to content

Conversation

@GaryJones
Copy link
Contributor

@GaryJones GaryJones commented Dec 1, 2025

Summary

Migrates the PHPUnit testing setup from yoast/phpunit-polyfills to yoast/wp-test-utils, following the pattern established in the edit-flow plugin (PR Automattic/edit-flow#796).

This unblocks PR #721 (PHPUnit 11 upgrade from Dependabot).

Changes

  • composer.json: Replace yoast/phpunit-polyfills with yoast/wp-test-utils ^1.2, rename scripts to test:integration convention, add test script
  • phpunit.xml.dist: Update testsuite to look for *Test.php files in ./tests/Integration/
  • tests/bootstrap.php: Rewrite following Yoast WPIntegration pattern with conditional WordPress loading
  • Test files: Move to tests/Integration/*Test.php, namespace under Automattic\Liveblog\Tests\Integration, extend Yoast\WPTestUtils\WPIntegration\TestCase, add declare(strict_types=1)
  • .github/workflows/integrations.yml: Update to use new script names

Test plan

  • All 67 tests pass in single-site mode
  • All 67 tests pass in multisite mode
  • CI passes

🤖 Generated with Claude Code

The existing test setup relied on yoast/phpunit-polyfills, which provides
polyfills for PHPUnit functionality but lacks the WordPress-specific test
utilities that modern WordPress plugin testing requires. This migration
adopts yoast/wp-test-utils, following the established pattern from the
edit-flow plugin, to gain better WordPress integration testing capabilities
and more robust test isolation.

Key improvements:

- Conditional WordPress loading based on test suite selection, allowing
  for future unit tests that don't require the full WordPress environment
- Proper namespace support throughout the test suite under
  Automattic\Liveblog\Tests\Integration
- PSR-4 compliant file naming and class structure
- Modern PHP syntax with strict types declaration
- Better test isolation through Yoast's TestCase implementation

This change maintains full test coverage whilst establishing a more
maintainable and extensible testing foundation for future development.
All 67 tests continue to pass in both single-site and multisite modes.
@GaryJones GaryJones merged commit 60dd367 into develop Dec 1, 2025
19 checks passed
@GaryJones GaryJones deleted the refactor/wp-test-utils-migration branch December 1, 2025 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants