Skip to content

Add PHPUnit unit + integration test suites to all sub-plugins - #6

Merged
miguelcolmenares merged 2 commits into
mainfrom
feature/add-phpunit-test-suites
Aug 18, 2026
Merged

Add PHPUnit unit + integration test suites to all sub-plugins#6
miguelcolmenares merged 2 commits into
mainfrom
feature/add-phpunit-test-suites

Conversation

@miguelcolmenares

Copy link
Copy Markdown
Member

Summary

  • Adds real PHPUnit test suites (unit + WPGraphQL integration) to community-listings, contentful-tables, and graphql-shortcode-support — 148 tests total, none of which had any automated coverage before
  • Each sub-plugin gets its own phpunit.xml and tests/Unit/tests/Integration directories, extending silverassist/wp-plugin-kernel's Testing\TestCase (already available via the existing runtime dependency from PR Adopt silverassist/wp-plugin-kernel across all sub-plugins #5)
  • Two new repo-root scripts (scripts/install-wp-tests.sh, scripts/install-wpgraphql-for-tests.sh) set up one shared WordPress test environment for all three sub-plugins, avoiding triplicated downloads
  • WPGraphQL integration tests are guarded with class_exists('WPGraphQL') + markTestSkipped(), matching the pattern already proven in silver-assist-security
  • Found and fixed a real bug while writing the database-fallback test: TableDataLoader::load_tables_from_database() selected a table_id column that has never existed in the schema (Activator creates entry_id) — this fallback path was previously untested and would have thrown a real SQL error the first time a site reached it in production

Related

Completes PR B2 of the contentful-wordpress-plugins standardization plan (follows #5, wp-plugin-kernel adoption). PR B3 (wiring these suites into CI) follows next.

Test plan

  • composer run phpunit passes in all 3 sub-plugins (38 + 92 + 18 tests)
  • make phpcs && make phpstan clean across all 3 sub-plugins
  • make build still packages correctly (tests/ excluded from shipped zips, confirmed pre-existing exclude pattern)
  • Pre-PR core-review pass — no findings

Adds real test coverage (148 tests total) to community-listings,
contentful-tables, and graphql-shortcode-support, none of which had any
automated tests before. Each sub-plugin gets its own phpunit.xml and
tests/Unit + tests/Integration suites, extending wp-plugin-kernel's
Testing\TestCase; WPGraphQL integration tests are guarded with
class_exists('WPGraphQL') + markTestSkipped(). Two new repo-root scripts
set up one shared WordPress test environment for all three sub-plugins:
install-wp-tests.sh (thin wrapper around the vendored wp-coding-standards
installer) and install-wpgraphql-for-tests.sh (adapted from
silver-assist-security).

Writing the database-fallback test for TableDataLoader surfaced a real bug:
load_tables_from_database() selected a table_id column that has never
existed in the schema (Activator creates entry_id) — fixed alongside the
new tests.

This is PR B2 of the contentful-wordpress-plugins standardization effort.
core-review flagged assertTrue(true) in
GraphQLShortcodeResolverTest::test_register_rendered_content_field_does_not_fatal()
as a tautology that verifies nothing beyond "no exception thrown" (which
PHPUnit already catches on its own). Replaced with a real GraphQL query
against the built schema, asserting no errors — matches the pattern already
used for the equivalent case in community-listings/contentful-tables.
@miguelcolmenares
miguelcolmenares merged commit 089f67c into main Aug 18, 2026
3 checks passed
@miguelcolmenares
miguelcolmenares deleted the feature/add-phpunit-test-suites branch August 18, 2026 04:30
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