Testing

Aegis uses a multi-layered testing approach covering unit tests, performance audits, and accessibility validation. This ensures code quality, performance targets, and accessibility compliance are maintained across releases.

Updated 4 min read Atmostfear Entertainment

Testing Tools

Tool Type Purpose
PHPUnit Unit/Integration PHP logic testing
WPAudit Performance WordPress-specific performance audit
pa11y-ci Accessibility Automated WCAG2AA checking (threshold 0; see .pa11yci.json)

PHPUnit

PHPUnit coverage is the WPAudit suite in tools/wpaudit/. CI runs the same command. There is no separate tests/Unit tree in this theme.

Running PHPUnit

Copied!
Shell
# Same as CIcomposer test:wpaudit# Or from the package directorycomposer install --working-dir=tools/wpauditcomposer test --working-dir=tools/wpauditcomposer test:coverage --working-dir=tools/wpaudit

Configuration

PHPUnit is configured in tools/wpaudit/phpunit.xml (PHPUnit 10.5, bootstrap vendor/autoload.php).

Test Structure

Copied!
Directory tree
tools/wpaudit/├── phpunit.xml├── src/ # Analyzers, models, configuration└── tests/Unit/ # PHPUnit tests (WPAudit\Tests\)

Writing Tests

Add cases under tools/wpaudit/tests/Unit/ in the WPAudit\Tests\ namespace. See existing analyzer and model tests in that tree.

WPAudit

WPAudit is the PHPUnit package in tools/wpaudit/. It analyzes theme files for performance, SEO, and accessibility findings. Run it with composer test:wpaudit. Rule IDs and configuration are documented in tools/wpaudit/README.md.

pa11y-ci (Accessibility)

pa11y-ci runs automated accessibility tests against rendered pages (home, post, search, page, 404), checking for WCAG2AA violations with a zero-issue threshold.

Running pa11y

Copied!
Shell
npm run test:a11y # Uses .pa11yci.json (defaults to http://localhost:8080/)npm run test:a11y:env # Single URL against wp-env (http://localhost:8888/)

Prerequisites

A WordPress site must be reachable at the configured host:

Copied!
Shell
# CI-style host (8080) — match .pa11yci.jsonnpm run test:a11y# Local wp-envnpm run env:startnpm run test:a11y:env

Configuration

Defaults live in .pa11yci.json. The CI accessibility workflow (accessibility.yml) seeds a post and page, writes .pa11yci.ci.json with resolved ?p= / ?page_id= URLs (because php -S does not rewrite pretty permalinks), then runs pa11y-ci --threshold 0.

Copied!
JSON
{ "defaults": { "timeout": 60000, "wait": 1000, "standard": "WCAG2AA", "runners": ["axe", "htmlcs"], "ignore": ["warning"] }, "urls": [ "http://localhost:8080/", "http://localhost:8080/?p=1", "http://localhost:8080/?s=test", "http://localhost:8080/?page_id=2", "http://localhost:8080/?p=999999" ]}

.pa11yci.ci.json is gitignored. For wp-env, use npm run test:a11y:env or retarget the urls host to 8888.

What pa11y Checks

Category Examples
Color contrast Text against backgrounds
ARIA usage Correct roles, states, properties
Form labels Inputs with associated labels
Headings Logical heading hierarchy
Images Alt text presence
Links Distinguishable link text
Landmarks Proper page regions
Keyboard Focus order and visibility

Handling False Positives

If pa11y reports an issue that is a false positive:

  1. Verify the issue is genuinely a false positive by manual testing.
  2. Add the specific rule to the ignore list in the configuration.
  3. Document why the rule is ignored.

Running All Tests

To run the complete test suite:

Copied!
Shell
npm run test

This typically runs:

  1. PHPUnit tests.
  2. JavaScript tests (if any).
  3. Linting checks.

For a comprehensive check including accessibility:

Copied!
Shell
npm run test:a11ycomposer test:wpaudit

Continuous Integration

Tests run automatically on every pull request:

Check Trigger Must Pass
PHPUnit Every PR Yes
ESLint Every PR Yes
stylelint Every PR Yes
PHPCS Every PR Yes
pa11y-ci Every PR Yes
WPAudit Nightly / Release Advisory

PRs cannot be merged if any required check fails.

Test Coverage

To generate a code coverage report:

Copied!
Shell
./vendor/bin/phpunit --coverage-html coverage/

Open coverage/index.html in a browser to view the report.

Coverage targets:

Area Target
Service classes 80%+
Utility functions 90%+
Block registration 70%+
Overall 75%+

WordPress 7.1 Compatibility Checklist

Run this matrix before raising Tested up to to 7.1. Do not remove Aegis breakpoints; they complement Core responsive style states (see Enhanced Core Blocks).

Check How
Core responsive style states Edit Group/Columns/Image/Heading/Button with viewport styles; confirm front-end CSS
Aegis Display / visibility Toggle hide-on-mobile, display/order/width; confirm Landscape/Tablet buttons still work
Iframed editor Post Editor + Site Editor: Global Styles, overlays, icons, Aegis inspector panels
React 19 experiment Enable Gutenberg gutenberg-react-19; open theme blocks and Aegis Dash admin/editor UIs; watch console
Regression baseline Spot-check the same flows on WordPress 7.0

Static scan (theme + Aegis Dash sources): no __next40pxDefaultSize or useResizeCanvas usage found. Vendored map libraries in Aegis Pro may still reference legacy React APIs — retest those screens under the React 19 experiment and update upstream packages when available.

Next Steps

Was this article helpful?