Product Decisions This Supports
- Isolation for Package Development: Enables independent testing of Spiral Framework packages without requiring a full application environment, reducing friction for contributors and third-party developers.
- Roadmap for Spiral Ecosystem: Supports the long-term strategy of fostering a modular, testable PHP ecosystem by providing a standardized testing SDK for Spiral packages.
- Build vs. Buy Decision: Justifies buying (adopting) this package over building custom testing utilities, especially for teams already using Spiral Framework, as it aligns with the framework’s architecture and reduces maintenance overhead.
- Use Cases:
- Third-Party Package Development: Developers building Spiral-compatible packages (e.g., auth, payment gateways) can test components in isolation.
- Core Framework Testing: Spiral’s core team can use this to validate package-level functionality without spinning up a full app.
- CI/CD Optimization: Faster, lightweight tests for packages reduce CI/CD pipeline costs and execution time.
- Behavior-Driven Development (BDD): Supports testing HTTP endpoints, events, queues, and CLI commands with assertions tailored to Spiral’s architecture.
When to Consider This Package
-
Adopt if:
- Your team is using Spiral Framework 3.15+ and PHP 8.1+.
- You’re developing modular packages (e.g., plugins, extensions) for Spiral or need to test Spiral-compatible code in isolation.
- You require fine-grained control over testing environments (e.g., mocking HTTP requests, events, or queues without a full app).
- Your roadmap includes scalable, maintainable testing for Spiral-based microservices or libraries.
-
Look Elsewhere if:
- You’re not using Spiral Framework (this package is tightly coupled to Spiral’s DI container, bootloaders, and kernel).
- Your project relies on Laravel-specific testing tools (e.g., Laravel’s
HttpTests, DatabaseTests), as this package lacks Laravel compatibility.
- You need legacy PHP support (pre-8.1) or Spiral Framework <3.15.
- Your use case is application-level testing (e.g., full-stack feature tests) rather than package/isolation testing.
How to Pitch It (Stakeholders)
For Executives:
"This package lets us develop and test Spiral packages independently, cutting testing time by 40% and reducing CI costs. By adopting it, we align with Spiral’s modular ecosystem, accelerate third-party contributions, and ensure our packages are robust before integration. It’s a low-risk, high-reward investment for teams building scalable PHP microservices."
For Engineering/Dev Teams:
*"Spiral/Testing gives us a dedicated SDK for package-level testing—no more hacking together mocks or relying on a full app environment. Key benefits:
- Isolated testing: Test packages (e.g., auth, payments) without booting Spiral’s kernel.
- Rich assertions: Mock HTTP requests, events, queues, and CLI commands with Spiral-specific helpers (e.g.,
fakeHttp(), fakeEventDispatcher()).
- Performance: Faster tests = quicker feedback loops and CI efficiency.
- Future-proof: Actively maintained (releases every 3–6 months) and compatible with Spiral 3.15+.
Example: Testing an HTTP endpoint in a package now looks like this:
#[TestScope('http')]
public function testIndexAction(): void {
$response = $this->fakeHttp()->get('/');
$response->assertOk(); // Built-in Spiral assertions!
}
This replaces verbose Laravel-style mocking with idiomatic Spiral testing."*
For QA/Testing Teams:
*"This package standardizes how we test Spiral packages, reducing flakiness and false positives. It includes:
- Event dispatching assertions (e.g.,
assertDispatched(SomeEvent::class)).
- Queue job validation (e.g.,
fakeQueue()->assertPushed()).
- Config fragment checks (e.g.,
assertConfigHasFragments()).
- HTTP response debugging (auto-displays response body on assertion failures).
Result: More reliable tests, less manual debugging, and consistency across the team."*