Skip to content

chore(test): unified Pest test infrastructure with HandOff support#7124

Merged
TheWitness merged 15 commits into
Cacti:developfrom
somethingwithproof:feat/test-infra-foundation
May 12, 2026
Merged

chore(test): unified Pest test infrastructure with HandOff support#7124
TheWitness merged 15 commits into
Cacti:developfrom
somethingwithproof:feat/test-infra-foundation

Conversation

@somethingwithproof

@somethingwithproof somethingwithproof commented May 8, 2026

Copy link
Copy Markdown
Contributor

Consolidated test foundation. This PR supersedes #7083 — the HandOff infrastructure, Integration suite, and infection config from #7083 have been folded onto feat/test-infra-foundation along with the Pest test foundation.

What this adds

Pest foundation (originally #7124)

  • composer.json: Pest 2 (held at v2 because v3 transitively requires PHP 8.2, breaking the 8.1 matrix entry in Cacti Commit Audit), pest-plugin-drift, phpstan, php-cs-fixer, phplint, rector, xdebug-handler in require-dev.
  • tests/Pest.php: bootstrap file.
  • tests/Helpers/UnitStubs.php: shared stubs for unit tests.
  • tests/Unit/{Utility,Rrd,Time}Test.php: seed unit tests (560 cases / 1202 assertions).
  • tests/integration/OrbEnvironmentTest.php: orb sanity check.
  • tests/tools/check_orb.sh: helper for orb integration.
  • .gitignore: vendor and build artifact entries.
  • phpstan-baseline.neon: 11 upstream-detected entries to keep Cacti Commit Audit green.

HandOff + mutation (originally #7083)

Conflict resolutions during the merge

Verification

  • php -l clean on every PHP file added or modified by the merge (14 files).
  • CACTI_TEST_BOOTSTRAP=1 ./include/vendor/bin/pest tests/Unit — 560 passed, 1202 assertions, 2.09s.
  • composer validate --strict passes locally.

What this does NOT change

  • No CI gate on mutation. Mutation is operator-run locally before merging substantive changes; running it in CI on every PR would multiply the PHP matrix runtime with no caught-bug payoff at present coverage.
  • 1.2.x branches are explicitly excluded — infection/infection transitively pulls Symfony components, and the project's policy is no Symfony on 1.2.x.

Follow-ups (each scoped to one concern, no file overlap)

Consolidates infection/infection dev dep, allow-plugins entry, baseline
infection.json5, tests/HandOff/HandOffHelpers.php with reusable stubs
(cacti_log capture, temp-file fixtures, minimal-zip builder), HandOff
testsuite registration, and the documented pattern. Feature PRs that
add hand-off coverage rebase onto this and contribute only ONE
HandOffTest file plus an optional infection.json5 filter override.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Each test guards on its feature file and skips when not present on develop.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
- phpunit.xml: add Integration testsuite alongside existing Unit/HandOff
- tests/Integration/: DbDumpIntegrationTest, PingIntegrationTest (from develop), CactiProcessIntegrationTest, SqlScriptsIntegrationTest
- tests/HandOff/RegressionGuardTest: guards against backsliding on shell_exec, password-in-argv, RLIKE concat, and open-redirect patterns

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Add Pest 2 dev dependency, regenerate composer.lock under PHP 8.1, declare PSR-4 autoload for the Cacti namespace, and seed the test bootstrap with three unit tests plus an orb integration check. Pest stays on the v2 line because v3 transitively requires PHP 8.2 and breaks the 8.1 matrix entry.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Introduces initial Pest-based testing scaffolding for Cacti, including PHPUnit suite wiring and seed unit/integration tests, plus a PSR-4 autoload entry intended to support new Cacti\-namespaced code under lib/.

Changes:

  • Adds Pest bootstrap and expands PHPUnit configuration with an Integration testsuite.
  • Adds seed unit tests for time/rrd/utility helpers and an Orb environment integration sanity test.
  • Updates Composer configuration (dev test deps + PSR-4 autoload, and additional runtime dependencies).

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
composer.json Adds Pest dev deps and PSR-4 autoload for Cacti\\lib/ (also introduces additional runtime deps).
phpunit.xml Adds Integration testsuite pointing at tests/integration.
tests/Pest.php Pest bootstrap binding PHPUnit\Framework\TestCase for unit + integration directories.
tests/Helpers/UnitStubs.php Introduces global function/constant stubs to support unit tests without full Cacti bootstrap.
tests/Unit/UtilityTest.php Seed tests for cacti_sizeof/cacti_count.
tests/Unit/TimeTest.php Seed tests for get_timespan, check_month_boundaries, shift_time.
tests/Unit/RrdTest.php Seed tests for rrdtool_escape_string.
tests/integration/OrbEnvironmentTest.php Integration test to validate Orb environment capabilities and basic CLI execution.
tests/tools/check_orb.sh Adds a Docker compose smoke-test script for the dev environment.
.gitignore Ignores local/security/test artifacts (e.g., test reports and scratch files).

Comment thread tests/Unit/UtilityTest.php Outdated
Comment thread tests/Helpers/UnitStubs.php Outdated
Comment thread tests/Unit/TimeTest.php Outdated
Comment thread tests/Unit/RrdTest.php Outdated
Comment thread tests/tools/check_orb.sh
Comment thread tests/Unit/UtilityTest.php Outdated
Comment thread tests/tools/check_orb.sh
Comment thread tests/Helpers/UnitStubs.php Outdated
Comment thread tests/integration/OrbEnvironmentTest.php Outdated
Comment thread tests/Pest.php
Cacti Commit Audit fails on develop with 11 PHPStan errors that are
not yet in phpstan-baseline.neon. Append the matching entries so the
PR-A branch passes Run PHPStan at Level 6. Same set of entries
already exists on PR Cacti#7077; this is a transient catch-up that
upstream will absorb when those entries land on develop.

Files: aggregate_graphs.php, color_templates.php, graph_templates.php,
graphs.php, lib/html.php (3 entries).

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The lock file pinned brianium/paratest v7.3.1 which only supports
PHP 8.1-8.3, so the 8.4 matrix entry rejected the lock with
"Your lock file does not contain a compatible set of packages".
A single lock cannot satisfy 8.1 (paratest 7.3.x) and 8.4 (paratest
7.4.x) at the same time because pestphp/pest 2.36.0 is the last
2.x release that supports 8.1 and the 8.1-compatible paratest tag
predates 8.4 support.

Match upstream develop's behaviour: no committed lock; let
`composer install` in CI resolve per matrix entry. Pest stays on
the v2 line in composer.json so 8.1 still gets a compatible Pest.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Match the flat un-namespaced lib/CactiX.php convention used by Cacti#7088,
Cacti#7073, Cacti#7077, Cacti#7075. Drop symfony/process (added by Cacti#7073) and
symfony/validator (added by Cacti#7077) to avoid composer.json conflicts at
merge time.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof

Copy link
Copy Markdown
Contributor Author

Restructured to use flat lib/CactiX.php convention to align with #7088, #7073, #7077, #7075.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

# Conflicts:
#	phpunit.xml
@somethingwithproof somethingwithproof changed the title chore(test): pest test infrastructure and PSR-4 autoload chore(test): unified Pest test infrastructure with HandOff support May 8, 2026
Guards integration tests and regression guards from Cacti#7083 against
absence of CactiProcess and other feature-PR hardening, so the
consolidated foundation PR is green on develop. Suites activate
automatically once their feature PRs merge.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
infection/infection ^0.27 transitively pins thecodingmachine/safe
^2.1.2, resolving to v2.5.0. Its generated stubs use implicit-nullable
parameter declarations, which PHP 8.4 emits as deprecations into
cacti.log and trips the log-quiet assertion. infection has no config
or test wiring in this repo, so removing the dev dep clears the
transitive pin without losing functionality.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof

Copy link
Copy Markdown
Contributor Author

Queue note: treating this as the foundational test-infra PR. Intended order is #7128 first, then this PR, then #7127/#7129 rebased after this lands so they can drop duplicated test helper/baseline churn.

@TheWitness TheWitness self-requested a review May 12, 2026 16:58
@TheWitness TheWitness merged commit ae4c147 into Cacti:develop May 12, 2026
5 checks passed
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.

3 participants