Skip to content

test: integrate ttt for PHPUnit test sandboxing - #100

Merged
konradmichalik merged 4 commits into
mainfrom
feature/ttt-integration
Jul 31, 2026
Merged

test: integrate ttt for PHPUnit test sandboxing#100
konradmichalik merged 4 commits into
mainfrom
feature/ttt-integration

Conversation

@konradmichalik

@konradmichalik konradmichalik commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Integrate konradmichalik/ttt (TYPO3 Testing Terrarium) as the unit-test sandbox, replacing hand-written TYPO3_CONF_VARS backup/restore boilerplate with declarative #[WithTypo3ConfVars] attributes (guaranteed restore, even on hard failures).
  • Register the ttt PHPUnit extension in the unit test configuration only; functional tests are untouched.
  • Migrate 8 test classes' TYPO3_CONF_VARS juggling to attributes, incidentally fixing several pre-existing state leaks (tests that mutated config without cleanup).

Changes

  • composer.json / composer.lock - add konradmichalik/ttt: ^0.2.0 as a dev dependency.
  • phpunit.xml - register <bootstrap class="KonradMichalik\Ttt\TttExtension"/> in the unit test config.
  • Tests/Unit/** (8 files) - migrate TYPO3_CONF_VARS setUp/tearDown and inline set/unset to #[WithTypo3ConfVars] class/method attributes; delete redundant tearDown cleanup; keep non-ttt state ($_SERVER['REMOTE_ADDR']) as-is.

Notes

  • 264 tests / 750 assertions green before and after; line coverage unchanged at 94.91% (615/648).
  • CI matrix is PHP 8.2/8.3/8.4/8.5 (all ≥ 8.2), so ttt's PHP requirement is satisfied — no matrix change.

Summary by CodeRabbit

  • Tests
    • Improved test reliability by switching to declarative TYPO3 configuration setup instead of manual runtime global mutations.
    • Updated test scenarios for configuration handling, maintainer checks, notification behavior, and encryption key management.
  • Infrastructure / Tooling
    • Added PHPUnit bootstrap support to load test configuration attributes.
    • Added test attribute helper dependency.
    • Updated secret scanning ignore rules for test fixtures.

Install konradmichalik/ttt and register its PHPUnit extension in the unit
config. Replace hand-rolled $GLOBALS['TYPO3_CONF_VARS'] setUp/tearDown
juggling with declarative #[WithTypo3ConfVars] attributes, giving a
guaranteed restore regardless of test outcome and fixing several leaks
that had no cleanup at all.
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f4c0acf-a9ff-4098-b465-62df0ae645b0

📥 Commits

Reviewing files that changed from the base of the PR and between 5b69809 and 3985acd.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • Tests/Unit/Configuration/DetectorConfigurationBuilderTest.php
  • Tests/Unit/Detector/NewIpDetectorTest.php
  • Tests/Unit/Notification/EmailNotificationTest.php
  • Tests/Unit/Security/LoginNotificationTest.php
  • composer.json

📝 Walkthrough

Walkthrough

Tests now use WithTypo3ConfVars attributes instead of direct TYPO3_CONF_VARS mutation. The supporting Composer dependency and PHPUnit extension are configured. Existing assertions remain unchanged.

Changes

Test configuration migration

Layer / File(s) Summary
Configure attribute-based test infrastructure
composer.json, phpunit.xml
Adds the konradmichalik/ttt development dependency and loads TttExtension in PHPUnit.
Migrate configuration and HMAC tests
Tests/Unit/Configuration/*, .gitleaksignore
Declares extension, timezone, email, encryption-key, and HMAC settings through WithTypo3ConfVars; adds allowlist entries for test-only encryption-key fixtures.
Migrate detector and notification configuration
Tests/Unit/Detector/*, Tests/Unit/Notification/*, Tests/Unit/Security/*, Tests/Unit/Utility/*
Moves maintainer, notification, extension, and date-format configuration from global mutations to attributes.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: integrating ttt to sandbox PHPUnit tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/ttt-integration

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 PHPStan (2.2.6)

Composer install failed: this project depends on private packages that require authentication (e.g. GitLab/GitHub, Laravel Nova, etc.).
CodeRabbit tooling environment cannot access private registries.
If your project requires private packages, disable the PHPStan tool in your coderabbit settings.

Instead, run PHPStan in a CI/CD pipeline where you can use custom packages — our pipeline remediation tool can use the PHPStan output from your CI/CD pipeline.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@konradmichalik

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@konradmichalik
konradmichalik merged commit 3091d8c into main Jul 31, 2026
29 checks passed
@konradmichalik
konradmichalik deleted the feature/ttt-integration branch July 31, 2026 08:09
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