2045c856e9
- Add 10 core testing guides (setup, AAA principles, PHPUnit/Pest, mocking, anti-patterns, PHP 8.4+, debugging, data factories, advanced edge cases) - Add 13 component testing guides covering all Laravel layers - Add standard templates for PHPUnit 10/11 and Pest v2/v3 including ArchitectureTest - Add Docker smart test runner, dependency installer, and CI/CD templates (GitHub Actions, GitLab CI) - Add 4 Claude Code skills (laravel-test-setup, laravel-unit-test with --all mode, laravel-test-review, laravel-mock-helper) - Add single unified installer script (sg-install-unit-testing.sh) with global support, CLI runners, and 1-click updater (sg-test-update) - Add comprehensive documentation (README.md, USAGE-GUIDE.md) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Test Case Configuration
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Định cấu hình TestCase mặc định cho Unit và Feature tests trong Pest PHP.
|
|
|
|
|
*/
|
|
|
|
uses(
|
|
Tests\TestCase::class,
|
|
// Illuminate\Foundation\Testing\RefreshDatabase::class, // Chỉ bật trong Feature Test
|
|
)->in('Feature');
|
|
|
|
uses(
|
|
Tests\TestCase::class,
|
|
)->in('Unit');
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Expectations Custom Helpers
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Tạo các custom expectation mở rộng của Pest nếu cần.
|
|
|
|
|
*/
|
|
|
|
expect()->extend('toBeValidEmail', function () {
|
|
return $this->toBeString()->toMatch('/^.+@.+\..+$/');
|
|
});
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Functions Helpers
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Hàm global hỗ trợ khởi tạo dữ liệu giả lập cho test.
|
|
|
|
|
*/
|
|
|
|
// function asUser($user = null) {
|
|
// return test()->actingAs($user ?? User::factory()->create());
|
|
// }
|