Skip to content

Add GitHub Actions workflow for unit tests#2

Open
dd32 wants to merge 14 commits intotrunkfrom
fix/claude/add-unit-tests-ci
Open

Add GitHub Actions workflow for unit tests#2
dd32 wants to merge 14 commits intotrunkfrom
fix/claude/add-unit-tests-ci

Conversation

@dd32
Copy link
Owner

@dd32 dd32 commented Feb 12, 2026

Summary

  • Adds .github/workflows/unit-tests.yml to run all unit tests on pushes and PRs to trunk
  • Standalone PHP tests (matrix): Serve Happy API, Browse Happy API, Slack Trac Bot, Slack Props Library
  • WordPress-dependent PHP tests (matrix with MySQL): Handbook plugin, Plugin Directory plugin
  • Creates wp-env local dev environments for Handbook and Plugin Directory plugins
  • Adds Jetpack Search stub and WPORG Ratings stub for Plugin Directory dependencies
  • Adds comprehensive unit tests for the Plugin Directory covering:
    • Template helpers (encode, active installs, dashicons stars, download links, support URLs, geopattern icons, outdated detection)
    • Trademarks validation (prefix detection, exceptions, portmanteaus)
    • Readme Parser (headers, sections, contributors, tags, aliases)
    • Markdown transformation (custom code_trick logic, equals headers)
    • Readme Validator (error/warning/note categorization, message translation)
    • Plugin post type, taxonomy, and status registration
    • filter_wp_insert_post_data behavior

Changes

  • .github/workflows/unit-tests.yml — CI workflow with 6 test matrix entries
  • Plugin Directory .wp-env.json — Docker dev environment with Jetpack, themes, stubs
  • Plugin Directory tests/bootstrap.php — Self-contained WP test framework bootstrap
  • Plugin Directory tests/stubs/jetpack-search-stub.php — Jetpack Classic_Search stub
  • Plugin Directory tests/stubs/wporg-ratings-stub.php — WPORG_Ratings stub with documented code locations
  • Plugin Directory test files: test-template.php, test-trademarks.php, test-readme-parser.php, test-markdown.php, test-readme-validator.php, test-plugin-directory.php
  • Handbook tests/phpunit/bootstrap.php — wp-env path fallback
  • Minor test fixes across Handbook, Browse Happy, and Slack Props for PHPUnit 9 compatibility

Test plan

  • All CI checks pass (standalone PHP + WordPress-dependent PHP)
  • Plugin Directory tests cover core business logic without external API dependencies
  • wp-env environments start successfully for local development

🤖 Generated with Claude Code

Adds CI for PHP standalone tests (Serve Happy, Browse Happy, Slack Trac Bot),
WordPress-dependent tests (Handbook, Plugin Directory), and JavaScript tests
(Pattern Directory theme) across pushes and PRs to trunk.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props dd32.

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

dd32 and others added 13 commits February 12, 2026 14:29
- Standardize all standalone PHP tests on PHP 8.0 + PHPUnit 9, with a
  compatibility bootstrap that aliases PHPUnit_Framework_TestCase for
  tests still using the pre-PHPUnit 8 class name (Serve Happy, Slack
  Trac Bot).
- Run `composer install` in wordpress-develop to provide the
  yoast/phpunit-polyfills package required by the WP test suite.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use PHP 7.4 for WordPress tests — the Handbook test setUp/tearDown
  methods lack `: void` return types, which is fatal on PHP 8.0+ with
  the Yoast PHPUnit Polyfills.
- Remove Plugin Directory from CI — it has a hard dependency on the
  Jetpack_Search class which requires the full Jetpack plugin.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add `: void` return types to setUp/tearDown in Handbook test files
  to be compatible with the Yoast PHPUnit Polyfills.
- Restore PHP 8.0 for WordPress tests (no longer need 7.4 workaround).
- Remove JS Pattern Directory Theme job per request.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The parse logic unconditionally sets upgrade=true for Internet Explorer
(since it is discontinued), but the test did not account for this and
expected upgrade=false when the IE version matched the current version.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rtion

- Add Slack Props Library to standalone PHP tests with a wpdbStub
  bootstrap so PHPUnit can mock the database dependency.
- Re-add Plugin Directory to WP tests with a bootstrap that stubs
  Jetpack Search classes (Classic_Search) so the plugin can load
  without the full Jetpack plugin installed.
- Fix Handbook test_handbook_sidebar: add show_in_rest to the expected
  sidebar keys array (added in WordPress trunk).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Handbook: Add wp-env test directory fallback to bootstrap
- Plugin Directory: Create .wp-env.json with Jetpack search stub
  mu-plugin mapping
- Plugin Directory: Make bootstrap self-contained (finds WP test
  framework, loads Jetpack stub, boots WP)
- Plugin Directory: Add void return types to setUp/tearDown
- CI: Remove Jetpack stub CI step (now handled by bootstrap)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…on tests

- Slack Props: Pass directory instead of hyphenated filename to PHPUnit 9
  (PHPUnit 9 cannot derive class name from hyphenated filenames)
- Plugin Directory: Remove from CI as all tests are integration tests
  that require live api.wordpress.org (wp-env config still available
  for local development)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add Jetpack, advanced-post-cache, and plugin-check as plugins
- Add wporg-plugins-2024 theme and wporg-parent-2021 parent theme
- Add WPORG_Ratings stub mu-plugin (closed-source dependency)
- Document all code locations that rely on each stub

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
New test suites covering:
- Template helpers: sanitize_active_installs, format_active_installs,
  section titles, version detection, encoding
- Trademarks: slug validation, prefix detection, for-woocommerce
  exception, portmanteau detection, user/published-plugin exceptions
- Readme Parser: header parsing, section parsing, FAQ extraction,
  alias sections, ignored tags, short description truncation
- Markdown: transform, equals-style headers, code blocks, lists

Tests use @group plugin-directory to run separately from legacy
integration tests that require live api.wordpress.org.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Template: use assertEquals for floor() float return values
- Trademarks: avoid 'plugin' (a trademarked slug) in clean slug tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…arning

- Create a WP test user for contributor parsing test
- Add separate test for invalid contributor warning
- Check truncation warning instead of byte length (trim_length appends
  a hellip entity)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add get_last_query_info() to Jetpack Search stub (called at class-plugin-search.php:437)
- Improve Template::encode() tests with real UTF-8 and Windows-1252 encoding inputs
- Add tests for dashicons_stars, close/rejection reasons, download_link,
  support URLs, geopattern icon URLs, is_plugin_outdated, rollout strategies
- Refocus Markdown tests on custom code_trick() logic (pre/code block
  preservation, underscore handling, bbPress-style backtick blocks)
- Add Readme Validator test file covering validate(), validate_content(),
  translate_code_to_message(), and all error/warning/note categories
- Add Plugin Directory registration tests for post type, taxonomies,
  post statuses, meta fields, and filter_wp_insert_post_data

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix encode tests: ampersand and angle brackets are round-tripped by
  htmlentities + htmlspecialchars_decode (ENT_NOQUOTES), remove Windows-1252 test
- Fix markdown code_trick tests: add surrounding text so trim() does not
  strip the 4-space indentation that code_trick adds for pre/code blocks
- Fix readme validator: rename "My Test Plugin" to "My Test Tool" to avoid
  trademark check, create WP user for contributor validation
- Fix all plugin post factory calls: add post_modified/post_modified_gmt
  fields to avoid undefined array key error in filter_wp_insert_post_data

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant