---
name: class-test-case-generator
description: Generate test cases for a specific class on demand. Use when asked to write tests for one class/file (service, controller, request, model, command, or helper), including happy path, validation, edge cases, and failure behavior.
---

# Class Test Case Generator

## Overview
Create targeted, maintainable tests for a requested class by mapping its public behavior and writing focused test cases for each branch.

## Inputs Required
- Class path or FQCN (required)
- Test type preference: `Feature` or `Unit` (optional)
- Expected framework conventions (PHPUnit in this project)

## Workflow
1. Read the target class and direct dependencies used inside methods.
2. Identify public methods and behavior branches:
- success path
- validation/path guards
- exceptions/failure handling
- side effects (DB writes, events, queue, notifications)
3. Choose test location:
- `tests/Feature/...` for request/HTTP/integration behavior
- `tests/Unit/...` for pure class behavior
4. Create test file with clear naming:
- `test_it_<expected_behavior>()`
- use one assertion theme per test where possible
5. Cover the minimum complete matrix:
- happy path
- invalid input or boundary case
- failure/exception path
- authorization or permission behavior (if applicable)
6. Use factories/mocks/fakes based on dependency type:
- DB models: factories and refresh database traits
- external services: mocks/fakes
- events/notifications/jobs: framework fakes
7. Run only relevant tests first, then expand as needed.

## Output Requirements
- Add or update a dedicated test file for the target class.
- Keep tests deterministic and isolated.
- Do not assert implementation details when behavior assertions are enough.
- Include regression test(s) for known bug scenarios when provided.

## Project Conventions
- Prefer explicit assertions and readable arrangement (`arrange/act/assert` structure).
- Keep fixtures minimal.
- Follow existing test style in neighboring files.
- If behavior is unclear, infer from existing patterns in similar classes.
