laravel-tdd
Laravel 测试策略,涵盖 PHPUnit、Pest、模型工厂、HTTP 测试、Sanctum 身份验证测试、模拟和覆盖率。适用于使用 PHPUnit 或 Pest 编写 Laravel 测试,或以测试先行的方式开发 Laravel 功能。
机器翻译查看英文原文
Laravel testing strategies with PHPUnit, Pest, model factories, HTTP tests, Sanctum authentication testing, mocking, and coverage. Use when writing Laravel tests with PHPUnit or Pest, or driving a Laravel feature test-first.
适用对象:软件开发与测试。自动收录 · 待核查。
原作者说明节选
从固定版本的 SKILL.md 提取,保留原文语言。以下内容属于作者说明,本站尚未验证安装、兼容或运行结果。
查看英文原文
原文涵盖的主题
- Laravel Testing with TDD
- When to Activate
- TDD Workflow for Laravel
- Red-Green-Refactor Cycle
- Setup
- PHPUnit Configuration
- Base TestCase Setup
- Model Factories
Test-driven development for Laravel applications using PHPUnit, Pest, Laravel factories, and testing helpers. Writing new Laravel applications or features Implementing API endpoints with Sanctum or Passport authentication Testing Eloquent models, relationships, scopes, and accessors Setting up testing infrastructure for Laravel projects Writing feature tests for HTTP controllers and form requests Mocking external services (queues, mail, notifications, HTTP) | Component | Target | |-----------|--------| | Models | 95%+ | | Actions/Services | 90%+ | | Form Requests | 90%+ | | Controllers | 85%+ | | Policies | 95%+ | | Overall | 80%+ | Use factories over manual create() calls One logical assertion per test Descriptive names: testguestscannotcreateproducts Test edge cases and authorization boundaries Mock external services with Http::fake(), Mail::fake() Use RefreshDatabase for clean state Don't test Laravel internals (trust the framework) Don't make tests dependent on each other Don't over-mock — mock only service boundaries Don't test private methods — test through the public interface Don't couple tests to HTML structure | Pattern | Usage | |---------|-------| | RefreshDatabase | Re
这里只展示节选,请以完整原文和当前要求为准。
- 来源仓库
- affaan-m/ECC
- 源文件
- pi/core/skills/laravel-tdd/SKILL.md
- 固定版本
- d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
来源与内容状态
本条为自动发现的元数据,尚未完成人工文档核查;适用性与运行结果待核查。
原作者:affaan-m/ECC · 原作者仓库元数据。文档核查:未核查。最近来源检查:2026-11-09T15:01:43.085Z。
分类由名称、说明与路径规则生成,分类不代表已核实适配。
许可与权利归属
MIT。第三方内容及版权归原作者,使用条件以原文为准。
许可原文 ↗本站没有因同步、复制或用户自报成功而将资源标为运行验证通过。
限制与注意事项
- 元数据收录不代表本站已经安装、适配、实测或进行安全审查。