# Laravel:controller Tests

> Write focused controller tests using HTTP assertions; keep heavy logic in Actions/Services and unit test them

- Skill: `jpcaparas/laravel-controller-tests` (Agent Skill)
- Install (CLI): `npx skillmds@latest add jpcaparas/laravel-controller-tests`
- Raw SKILL.md: https://api.skillmd.com/api/skills/jpcaparas/laravel-controller-tests/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: jpcaparas (https://skillmd.com/u/jpcaparas)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/jpcaparas/laravel-controller-tests

---


# Controller Tests

## Feature tests for endpoints

```php
it('rejects empty email', function () {
  $this->post('/register', ['email' => ''])->assertSessionHasErrors('email');
});
```

## Better tests

- Move validation to Form Requests; assert errors from the request class
- Extract business logic into Actions; unit test them directly
- Use factories for realistic data; avoid heavy mocking


