rushphp / testing
Testing kit for RUSH tools: fixtures, harness and contract conformance.
v0.1.0
2026-11-23 18:33 UTC
Requires
- php: ^8.3
- rushphp/contract: ^0.2.0
- rushphp/rush: ^0.2.0
- rushphp/support: ^0.2.0
Requires (Dev)
- pestphp/pest: ^3.8
- phpstan/phpstan: ^2.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
RUSH Testing
RUSH — Registry-driven Unified Shell Helper.
Testing kit for tools built for RUSH. It provides fixtures, a runtime harness and a contract conformance suite so every tool is tested the same way.
Pre-1.0: minor releases may include breaking changes. Development-only: never add this package to runtime dependencies.
✨ Features
- Fixtures:
FakeTool,ConfigurableFakeTool,RecordingCommand,RecordingOutput,ProjectFixture,OperatorFixture. - Harness: run a tool through the real runtime or a command in isolation.
- Conformance: assert that a tool respects
ToolInterface/CommandInterfaceand the registry rules (command scoping, reserved names, option coherence).
All types are framework-agnostic (plain PHP). Pest/PHPUnit integration is left to the caller.
📦 Installation
composer require --dev rushphp/testing
🚀 Quick start
use Rush\Testing\Fixtures\ProjectFixture; use Rush\Testing\Harness\ToolHarness; use Rush\Testing\Conformance\ToolConformance; $project = ProjectFixture::create(['composer.json' => '{}'])->operator(); $result = ToolHarness::run(new MyTool(), ['my', 'status'], $project); expect($result->code)->toBe(0); expect($result->stdout)->toContain('ok'); ToolConformance::assert(new MyTool(), $project->path());
🧪 Testing a command in isolation
use Rush\Testing\Harness\ToolHarness; $result = ToolHarness::runCommand($command, ['--target=staging']); expect($result->code)->toBe(0);
✅ Good practices
- Run
ToolConformance::assert()in its own test for every tool. - Use
ToolHarness::run()to test wiring (registry -> Application -> command). - Use
ToolHarness::runCommand()to test command logic without the runtime. - Prefer
RecordingOutputand structured assertions over exact help layout. - Test both operator paths (
withOperator: true/false) when policy varies. - Keep domain-specific fakes (SSH, database, HTTP) inside the tool; build them
on top of
ProjectFixture. - Always clean up temp projects (
ProjectFixturedoes it automatically).
🤝 Contributions
Contributions are welcome. Open an issue or submit a pull request.
📄 License
MIT. See LICENSE.