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>
56 lines
1.7 KiB
PHP
56 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Pest PHP Architecture Test Suite (Enterprise Pro Level)
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Bộ kiểm thử kiến trúc toàn diện bảo vệ cấu trúc mã nguồn không bị suy thoái.
|
|
| Chạy bằng lệnh: ./test-runner.sh tests/Unit/ArchitectureTest.php
|
|
|
|
|
*/
|
|
|
|
describe('Architecture & Code Quality Gates', function () {
|
|
|
|
test('All files must use strict types')
|
|
->expect('App')
|
|
->toUseStrictTypes();
|
|
|
|
test('No debugging functions left behind in codebase')
|
|
->expect(['dd', 'dump', 'ray', 'var_dump', 'print_r', 'die', 'exit'])
|
|
->not->toBeUsed();
|
|
|
|
test('Controllers naming convention & inheritance')
|
|
->expect('App\Http\Controllers')
|
|
->toHaveSuffix('Controller');
|
|
|
|
test('Controllers should not directly query Eloquent Models')
|
|
->expect('App\Http\Controllers')
|
|
->not->toUse('App\Models')
|
|
->ignoring('App\Http\Controllers\Auth');
|
|
|
|
test('Services must be final or readonly')
|
|
->expect('App\Services')
|
|
->toHaveSuffix('Service');
|
|
|
|
test('DTOs and Value Objects must be immutable (readonly)')
|
|
->expect('App\DTOs')
|
|
->toBeReadonly();
|
|
|
|
test('Custom Validation Rules must implement ValidationRule contract')
|
|
->expect('App\Rules')
|
|
->toImplement('Illuminate\Contracts\Validation\ValidationRule');
|
|
|
|
test('Jobs must be queueable')
|
|
->expect('App\Jobs')
|
|
->toImplement('Illuminate\Contracts\Queue\ShouldQueue');
|
|
|
|
test('Events must not have dependencies injected')
|
|
->expect('App\Events')
|
|
->classes()
|
|
->not->toHaveConstructor();
|
|
|
|
});
|