Add PHPUnit unit + integration test suites to all sub-plugins - #6
Merged
Conversation
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.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
community-listings,contentful-tables, andgraphql-shortcode-support— 148 tests total, none of which had any automated coverage beforephpunit.xmlandtests/Unit/tests/Integrationdirectories, extendingsilverassist/wp-plugin-kernel'sTesting\TestCase(already available via the existing runtime dependency from PR Adopt silverassist/wp-plugin-kernel across all sub-plugins #5)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 downloadsclass_exists('WPGraphQL') + markTestSkipped(), matching the pattern already proven insilver-assist-securityTableDataLoader::load_tables_from_database()selected atable_idcolumn that has never existed in the schema (Activatorcreatesentry_id) — this fallback path was previously untested and would have thrown a real SQL error the first time a site reached it in productionRelated
Completes PR B2 of the
contentful-wordpress-pluginsstandardization plan (follows #5, wp-plugin-kernel adoption). PR B3 (wiring these suites into CI) follows next.Test plan
composer run phpunitpasses in all 3 sub-plugins (38 + 92 + 18 tests)make phpcs && make phpstanclean across all 3 sub-pluginsmake buildstill packages correctly (tests/ excluded from shipped zips, confirmed pre-existing exclude pattern)