Http::fake(), UploadedFile) and integrates seamlessly with Pest/PHPUnit, FormRequests, and routes. No invasive changes to application architecture required.extends or factory overrides).UploadedFile::fake() integration).| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Test Coverage Gaps | May not cover edge cases (e.g., conditional validation, dynamic rules). | Supplement with manual overrides or hybrid tests. |
| Factory Complexity | Over-engineering for simple APIs (e.g., single-field requests). | Use only for routes with ≥3 validated fields; keep simple tests as-is. |
| Dependency Bloat | Adds minor overhead (~100KB) for a testing utility. | Justify with ROI from cleaner tests; no runtime impact. |
| Pest/PHPUnit Lock-in | Examples use Pest, but PHPUnit support is claimed. | Verify compatibility in CI; write adapters if needed. |
| Validation Logic Drift | Factories may diverge from actual FormRequest rules over time. | Enforce CI checks (e.g., test all FormRequests against factories). |
Rule::when()) that factories can’t handle natively?createRequestFactory() helper).app/Testing/RequestFactories.php) for team-wide reuse.use Worksome\RequestFactories\Factories\FormRequestFactory;
$factory = new FormRequestFactory(RegisterUserRequest::class);
$request = $factory->make(['phone' => '+123']);
| Component | Compatibility Notes |
|---|---|
| Laravel | 9.x, 10.x (PHP 8.0+). Test with Laravel 11 if adopting early. |
| PHPUnit | Works but requires helper methods (e.g., createRequestFactory()). |
| Pest | Native support; preferred for new projects. |
| Custom Validation | Supports FormRequest subclasses; extend Worksome\RequestFactories\Factories\FormRequestFactory. |
| File Uploads | Uses UploadedFile::fake(); no additional setup. |
| Localization | Handles phone/address formats via Laravel’s validation; no extra config. |
->ignoreMissing().dd($factory->getValidationRules()) to inspect generated rules.| Failure Scenario | Impact | Detection/Recovery |
|---|---|---|
| Factory-FormRequest mismatch | Tests pass but validation fails in prod. | CI check: Run tests with real validation. |
| Incomplete factory coverage | Some validation rules untouched. | Static analysis: Compare FormRequest rules vs. factories. |
| Over-reliance on factories | Tests become brittle (e.g., hardcoded values). | Enforce manual overrides for critical paths. |
| Package abandonment | Worksome stops maintaining the package. | Fork or rewrite critical |
How can I help you explore Laravel packages today?