infection/abstract-testframework-adapter
Interfaces and base classes for building Infection test framework adapters. Provides a common abstraction layer to integrate different PHP test runners with Infection’s mutation testing, making adapters consistent, reusable, and easier to implement.
The infection/abstract-testframework-adapter package is a niche but critical abstraction layer for Infection’s mutation testing framework, designed to decouple Infection’s core logic from test framework-specific implementations (e.g., PHPUnit, Pest). The new HasSyntaxErrorDetection interface (0.5.0) addresses a real pain point—syntax error detection in test outputs—by providing a standardized way to identify and handle syntax failures (e.g., ParseError in PHPUnit). This aligns well with Laravel/PHP ecosystems where:
The package’s modular design (interfaces + abstract base class) ensures low coupling with Infection’s core, making it a viable candidate for extending Infection’s adapter ecosystem. However, its standalone utility is limited—it’s primarily useful for teams building or maintaining Infection adapters, not end-users.
High for Infection-based projects, but with caveats:
composer.json for dependencies—if Infection has internalized this adapter, the standalone package may be deprecated or redundant.HasSyntaxErrorDetection interface is a positive addition, but no guarantees exist for modern frameworks (e.g., Pest 2.0+, PHPUnit 10+ with attributes). Teams using these may need custom overrides.AbstractTestFrameworkAdapter reduces repetitive code for runTests(), getName(), etc., but syntax error handling remains manual (implement hasSyntaxError()).Moderate to High due to:
Throwable changes).phpunit/phpunit) may introduce vulnerabilities.hasSyntaxError() interface relies on framework-specific output parsing. Poor implementation could lead to misclassified errors (e.g., treating test failures as syntax errors).HasSyntaxErrorDetection handle modern test frameworks (e.g., Pest 2.0+, PHPUnit 10+)?phpunit/phpunit <9.6)?Best suited for:
Not ideal for:
composer why-not infection/abstract-testframework-adapter to check if Infection already includes this package.infection/PHPUnit-adapter), check if it already implements HasSyntaxErrorDetection.hasSyntaxError() in your adapter to parse test output for syntax errors (e.g., ParseError in PHPUnit’s JSON output).public function hasSyntaxError(TestOutput $output): bool {
return str_contains($output->getRawOutput(), 'ParseError');
}
| Component | Status | Risk Level |
|---|---|---|
| PHP | 8.0+ (0.3.1), 8.2+ untested | High |
| Infection | No version guarantees (test with v1.0+) | High |
| PHPUnit | Likely compatible with 9.5+, 10.0+ untested | Medium |
| PestPHP | No confirmation for 2.0+ | High |
| Laravel | Indirect (via Infection), no Laravel-specific features | Low |
HasSyntaxErrorDetection works with your primary test framework (e.g., PHPUnit).AbstractTestFrameworkAdapter for secondary frameworks (e.g., Pest).hasSyntaxError() with framework-specific logic.AbstractTestFrameworkAdapter requires minimal boilerplate.hasSyntaxError()) may need framework-specific tweaks.How can I help you explore Laravel packages today?