phpunit

Solid

PHPUnit test structure, naming, assertions, and factory conventions for Laravel feature and unit tests.

Testing & QA 183 stars 39 forks Updated 1 months ago MIT

Install

View on GitHub

Quality Score: 88/100

Stars 20%
75
Recency 20%
75
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

**Name:** PHPUnit **Description:** PHPUnit test structure, naming, assertions, and factory conventions for Laravel feature and unit tests. **Compatible Agents:** general-purpose, testing **Tags:** tests/**/*.php, laravel, php, testing, phpunit, unit-test, feature-test ## Rules - **Feature tests** go in `tests/Feature/` and extend `Tests\TestCase` - **Unit tests** go in `tests/Unit/` and extend `PHPUnit\Framework\TestCase` - Always use `Illuminate\Foundation\Testing\RefreshDatabase` in feature tests that touch the database - Unit tests have no Laravel bootstrap — pure PHP tests only - Use `test_` method prefix with snake_case names: `test_user_can_create_resource` - All test methods must have `: void` return type - One assertion concern per test method — keep tests focused - Prefer `assertSame` over `assertEquals` for strict type + value comparison - Assert specific values, not just truthiness - Every new model **must** have a corresponding factory in `database/factories/` - Use factories in tests instead of manual `create()` / `insert()` calls - Define meaningful default factory values; use states for variations ## Examples ```php // Feature test use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; class InvoiceControllerTest extends TestCase { use RefreshDatabase; public function test_user_can_create_invoice(): void { $user = User::factory()->create(); $order = Order::factory()->create(['user_id' => $user->id]); $...

Details

Author
majiayu000
Repository
majiayu000/claude-skill-registry
Created
5 months ago
Last Updated
1 months ago
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category