Skip to content

Automated Tests - #259

Draft
jkrrv wants to merge 44 commits into
nextfrom
tests3
Draft

jkrrv wants to merge 44 commits into
nextfrom
tests3

Conversation

@jkrrv

@jkrrv jkrrv commented Oct 12, 2026

Copy link
Copy Markdown
Member

No description provided.

jkrrv and others added 30 commits September 30, 2026 15:55
Brings over the test infrastructure from copilot/add-unit-tests: PHPUnit 9.6 with the Yoast polyfills, a bootstrap that
stubs the few WordPress functions the tests need (including the filter system) without loading WordPress, a base
TestCase, and the tests for Utilities, StringableArray, Geo, TouchPointWP_Exception, and the color functions.

The GitHub Actions workflow runs the suite on PHP 8.0 through 8.5.  TESTING.md documents running and writing tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…tions

Coverage is now measured on PHP 8.4.  A new step prints the overall line and method coverage in the log, as a run
notice, and in the run summary.  Updates actions/checkout to v7, actions/cache to v6, and actions/upload-artifact to v7,
which removes the Node 20 deprecation warnings.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Covers how meetings are arranged into Editions and Clusters: gaps (and their inclusive edges), spanning meetings,
per-child Clusters within Editions, titles, and ordering, and how a MeetingArray presents a group as a single meeting.
MeetingFixtures builds API-shaped meetings and involvements, and describes a plan as nested meeting IDs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The PHP 8.4 job now sends its Clover coverage report to coveralls.io.  Clover is named explicitly because the
reporter would otherwise try to read it as Cobertura.  A problem submitting doesn't fail the run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
jkrrv and others added 12 commits October 7, 2026 22:22
standardizeHtml now reads the HTML with a parser (DOMDocument) instead of
relying on strip_tags alone:

- Elements in tp_standardize_strip_content_tags (script, style, iframe,
  object, embed, head by default) are removed along with their contents.
- Event handler attributes (on*), srcdoc, and malformed attribute names are
  removed from all elements.
- URL attributes (href, src, srcset, action, ...) with a protocol that isn't
  allowed are removed.  The allowed protocols are set with the new
  tp_standardize_allowed_protocols filter.
- The default allowed tags now include img, figure, figcaption, blockquote,
  code, pre, span, and div.

Also adds tests for stringToSlug edge punctuation, uppercase heading tags,
and orderHierarchicalTerms (the latter still fail and are marked
known-issue), documents Utilities::getClientIp's intended use, and adds
ext-libxml to the requirements.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The method only includes top-level terms and their direct children, which
fits its one use (Programs and Divisions in the division filter).  Terms
that are deeper, or whose parent isn't in the list, are left out.  Replace
the known-issue tests that expected otherwise with tests of this behavior.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…tes together

A second suite, in tests/WordPress, loads WordPress (from the wp-phpunit and
johnpbloch/wordpress-core packages) with a database, and loads the plugin the
way WordPress does.  It covers what the unit tests can't: writing meeting
grouping plans as posts, the grouping settings' defaults and legacy
detection, the division term sync and dropdown queries, creating and updating
users from TouchPoint data, media helpers, and featured image inheritance.

- phpunit.wordpress.xml, tests/WordPress/bootstrap.php, wp-tests-config.php:
  the database is configured with TP_TESTS_DB_* environment variables.
- bin/test-wp.sh (composer test-wp): starts a temporary MariaDB on a socket,
  runs the tests, and always stops it and deletes its data.  Uses the
  environment's database instead when TP_TESTS_DB_HOST is set.
- tests/Support/ReflectionHelpers: shared by both base test cases.
- .gitattributes: shell scripts keep LF line endings.
- CI: a WordPress job (PHP 8.0, 8.4, 8.5, MySQL service), and a coverage job
  that records each suite with --coverage-php, merges them with phpcov, and
  posts the combined result to Coveralls.  The matrix jobs no longer measure
  coverage.
- BlocksController::init() no longer requires the built blocks manifest,
  which a source checkout doesn't have.
- Tests that describe bugs they found are marked known-issue: the division
  sync losing divisions after the first in a new program, people with no
  resident code or campus getting the first one, Person::rescode throwing
  when unset, forceSlugUpdate leaving WordPress's post cache stale, and
  getPostContentWithShortcode not escaping its search.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…Press tests

The coverage job's WordPress step ran for more than 18 minutes, where the unit
tests' step takes 30 seconds.  Xdebug was recording coverage, with path
coverage, for all of WordPress, which the unit tests don't load.  The
WordPress bootstrap now sets Xdebug's coverage filter to the plugin's src
folder before coverage starts.

The WordPress and coverage jobs also get timeouts, so a hang fails in minutes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…has a default

Person::fromId() returned a Person with no user when the user didn't exist,
though its docblock said it could return null.  It now returns null.  The
Person constructor also no longer remembers such a Person under user ID 0.
The avatar and current-user code that uses it already handled null.

The people_ev_custom setting's default (an empty list) came from a field that
only exists while People Lists is enabled, so on a site that uses TouchPoint
for sign-in without People Lists, importing a person threw a TypeError.
Settings now has defaults for settings that other features read.

Adds WordPress tests for both, and for avatars, current-user lookups, and
settings defaults.  Two more problems the tests found are marked known-issue:
Person::pictureFilter() drops WordPress's own avatar for people with no
TouchPoint picture, and mc_archive_days has no default when the Meeting
Calendar is off.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…gram

Taxonomies::termExists() remembers what it found, including that a term wasn't
there.  The division sync looks for a program (under parent 0, the top level),
doesn't find it, and makes it, but insertTerm() recorded the new term under a
different key (no parent), so the next division in the program found the
remembered miss, tried to make the program again, was refused by WordPress,
and was skipped.  A program's other divisions only appeared on a later sync.

insertTerm() now records the term under the parent it was made with (0 if
none), and forgets any remembered miss for that name.  Looking for a term under
any parent (null) and at the top level (0) have separate keys, as they mean
different things in term_exists().

Adds tests for the cache and for syncing, including twice in one request.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Taxonomies::getTaxTermId() looks a term up by name or slug.  With a null value
the query had no name to match, so it returned every term, and the first was
used.  A person with no resident code or campus in TouchPoint was assigned the
first one in WordPress, and a code or campus TouchPoint had removed was never
removed.  A blank value now finds nothing.

Person::rescode and Person::campus threw a TypeError for a person without one,
because they checked for null where an unset value reads as an empty string, and
did not allow for the term having been deleted.  They now return null.

Adds tests for both, with blank, unknown, changed, removed, and deleted terms.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…endar is on

The checkbox for a type to import all of its meetings is only shown while the
Meeting Calendar is enabled, but the saved choice was still used after the
calendar was turned off, where it couldn't be seen or changed.  Involvement
Post Type settings now treat it as off while the calendar is off, without
changing what's saved, so it applies again if the calendar is turned back on.

mc_archive_days (default 7) has a default while the Meeting Calendar is off,
because involvements shown in sites still use it.  Settings returns it as a
whole number.

The cached Involvement Post Type settings and the archive cutoff can be
forgotten, so tests can reload them.

Adds WordPress tests for the type settings, for which involvements get posts
for their meetings, and for the default number of days to archive after.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…volvement is shown in sites or its type imports them

Meeting posts, and groups of them, were made for any involvement that was shown
in sites, even while the Meeting Calendar was off, from the window of meetings
that is only meant for describing schedules.  Meetings are now imported when the
calendar is enabled and either the involvement is shown in sites or its Post
Type is set to import all of its meetings.

Meeting Grouping is part of importing meetings, so while the calendar is off the
API isn't asked for structures of involvements, and no involvement is made the
owner or child of another, whatever the saved grouping settings say.  A child
that was claimed by an owner would otherwise have had no post of its own.

Adds tests for each combination, and for grouping and the API's parameters.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Utilities::forceSlugUpdate() writes the slug straight to the database, which left
WordPress's cached copy of the post with the old one.  Until the next request,
get_post() returned the old slug, and a later wp_update_post() in the same request
wrote it back over the forced one, so numeric slugs the grouping writer had
forced (WordPress turns "11" into "11-2") flipped back when a plan was written
twice in a request.  It now clears the post's cache after the write.

Adds tests, including the grouping writer running twice in one request.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… Avatars"

Person::pictureFilter() returned null for anyone without a TouchPoint picture,
which WordPress uses in place of the address it chose, so those people (and
commenters who aren't users) got no avatar, and a plugin that ran before the
filter lost its avatar for them.  It now returns the address it was given when
there's no TouchPoint picture.  It stays at the default priority, so other
plugins can come before it or after it, and the docblock says how.

getPictureForPerson() treated a WP_Post's ID as a user's, so a post's avatar
could be the picture of whichever user had the same ID number.  A post's avatar
is its author's.

WordPress only checks "Show Avatars" in get_avatar(), not get_avatar_url(), so
People Lists could show Gravatars on a site with avatars turned off.  A new
filter, at the lowest priority so that it only discards the Gravatar WordPress
made and every plugin can still provide a picture after it, makes
get_avatar_url() follow the setting.  TouchPoint pictures are still shown.

Adds tests for the filters, the priorities other plugins can use, posts and
comments, and the People List item.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 12, 2026 22:24
@jkrrv
jkrrv marked this pull request as draft October 12, 2026 22:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The change bundles a new plugin version, a new multi-language test/CI infrastructure, and supporting source behavior whose full cross-cutting impact warrants final human review.

0 open findings

What changed in this PR

This PR, titled "Automated Tests," introduces a PHPUnit-based automated test suite for the TouchPoint-WP WordPress plugin. It adds a WordPress-integration test layer (built on wp-phpunit/johnpbloch/wordpress-core) alongside the existing standalone unit tests, with a shared base WPTestCase that resets the plugin's static caches and settings fields between tests so that each test runs in isolation. It also bumps the plugin version to 0.2.1 and wires in the new Meeting_GroupingSettings class that the tests exercise.

Changes:

  • Add a WordPress-integration test harness (WPTestCase base class, wp-tests-config.php) that rebuilds settings fields and resets plugin/Utilities static caches per test.
  • Add integration test cases for Utilities (slug updates, shortcode discovery, featured-image helpers, image-from-URL replacement) and for Settings default/override resolution.
  • Bump the plugin version 0.0.97 → 0.2.1 and require_once the new Meeting_GroupingSettings.php.
File Description
touchpoint-wp.php Bumps the plugin version to 0.2.1 and loads Meeting_GroupingSettings.php.
tests/​WordPress/​WPTestCase.php New base test case resetting plugin/Utilities static caches, rebuilding settings fields, and providing settings/time/slug helpers.
tests/​WordPress/​wp-tests-config.php New WordPress test-library config sourcing DB settings from environment variables.
tests/​WordPress/​Utilities_Test.php New integration tests for forceSlugUpdate, getPostContentWithShortcode, featured-image helpers, and updatePostImageFromUrl.
tests/​WordPress/​Settings_Test.php New integration tests for settings defaults and saved-value resolution (people extra values, mc_archive_days).

I reviewed the visible test and configuration files and spot-checked the referenced source APIs (Utilities, Settings::get/DEFAULTS_WITHOUT_FIELD, Meeting_GroupingSettings, MeetingArray). The test code is well-structured and internally consistent, settings-default resolution matches the asserted behavior, and the ^7.1 WordPress-core/wp-phpunit constraints resolve to real published versions (7.1.3/7.1.1) per composer.lock, so they are not a nonexistent-version concern. I found no concrete, in-scope defects to flag in the reviewed changes.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@jkrrv

jkrrv commented Oct 13, 2026

Copy link
Copy Markdown
Member Author

#254 should be merged first

jkrrv and others added 2 commits October 13, 2026 10:11

This branch has not been deployed

No deployments
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