Proje: Okul Platform · Hub: Okul Platform — Conventions
Test Altyapısı
- Framework: PHPUnit 11
- API Spec test:
hotmeteor/spectator(OpenAPI doğrulaması) - DB:
DatabaseTransactionstrait — her test sonrası rollback
Test Yapısı
tests/
├── Feature/Api/
│ ├── Admin/ — Admin endpoint testleri
│ ├── Customer/ — B2B portal testleri
│ ├── General/ — Public endpoint testleri
│ ├── MigrationWebhook/ — Webhook testleri
│ ├── ExternalWebhooks/
│ └── AuthTest.php, OtpAuthTest.php, NotificationIdTest.php
└── Unit/
├── Enums/
├── Helpers/
├── Http/
├── Jobs/
├── Models/
└── Services/
TestCase Base Sınıfı
Tests\TestCase — Tüm testlerin base class’ı.
Yardımcı Metodlar
Admin kullanıcı ile login:
$user = $this->loginAsTestUserWithPerms(PermissionType::VIEW_SCHOOL);
$user = $this->loginAsTestUserWithPerms([PermissionType::VIEW_SCHOOL, PermissionType::EDIT_SCHOOL]);B2B kullanıcı oluşturma:
[$user, $customerUserSchool] = $this->createUserWithCustomerSchool([
'has_lead_access' => StringEnumType::TRUE,
'school' => $school->id,
]);→ User + UserContact (telefon) + CustomerUser + CustomerUserSchool oluşturur.
CustomerIO Tests
CustomerIO/Tests/ — Ayrı dizin, hotmeteor/spectator ile OpenAPI spec doğrulama.
Test Tag’leri
[OKUL-XXX] ticket’larında test ekleme zorunluluğu görünüyor (recent commit’lerde test eklendi).
Spectator (OpenAPI Test)
Swagger dokümantasyonuna karşı istek/yanıt doğrulaması.
StoreMediaRequest, SendSchoolStatisticRequest gibi request’ler Swagger’da #[OA\...] attribute’larıyla belgelendi.
Related
- api-code-conventions — PHPStan ve Pint ile birlikte test zorunluluğu
- api-role-permission-system — Test’lerde permission setup