📋 Commit iniziale con: - ✅ Documentazione unificata in docs/ - ✅ Codice Laravel in netgescon-laravel/ - ✅ Script automazione in scripts/ - ✅ Configurazione sync rsync - ✅ Struttura organizzata e pulita 🔄 Versione: 2025.07.19-1644 🎯 Sistema pronto per Git distribuito
503 lines
14 KiB
Markdown
503 lines
14 KiB
Markdown
# 🧪 PIANO TEST - NetGesCon Laravel
|
||
|
||
**📅 Creato**: 9 Luglio 2025 - **AGGIORNATO con scoperta test esistenti**
|
||
**🎯 Scopo**: Piano completo testing sistema
|
||
**👥 Team**: Michele + AI Assistant
|
||
**📊 Target Coverage**: >70%
|
||
|
||
## 🚨 **SCOPERTA CRITICA - Test già presenti nel sistema!**
|
||
|
||
**✅ TEST GIÀ IMPLEMENTATI**: 37 test cases nel framework Pest/PHPUnit
|
||
**🐛 PROBLEMA BLOCCANTE**: Conflitti database migrations in test environment
|
||
**📊 STATO**: 35 failed, 2 passed - tutti falliscono per conflitti SQLite
|
||
**⚠️ ERRORE**: `table "amministratori" already exists`
|
||
|
||
### 🔍 **Test Esistenti Scoperti**
|
||
- **Feature Tests**: Auth completo, Profile, RipartizioneSpesa, VoceSpesa, PianoRateizzazione
|
||
- **Unit Tests**: RataTest, RipartizioneSpesaServiceTest, PianoRateizzazioneTest
|
||
- **Test Environment**: Configurazione SQLite in-memory corretta in phpunit.xml
|
||
- **Framework**: Pest + PHPUnit con RefreshDatabase trait
|
||
|
||
### 🛠️ **PIANO CORREZIONE IMMEDIATA**
|
||
1. ✅ **Analizzare migrations conflicts**
|
||
2. 🔧 **Fixare test database setup**
|
||
3. 🧪 **Ripristinare test suite funzionante**
|
||
4. 📊 **Verificare coverage esistente**
|
||
5. 🚀 **Estendere test mancanti**
|
||
|
||
---
|
||
|
||
## 🎯 **OBIETTIVI TESTING**
|
||
|
||
### 🚀 **Obiettivi Primari**
|
||
- **Affidabilità**: Zero bug critici in produzione
|
||
- **Sicurezza**: Protezione multi-ruolo garantita
|
||
- **Performance**: Tempi risposta <2 secondi
|
||
- **Usabilità**: Interfaccia intuitiva per tutti i ruoli
|
||
|
||
### 📊 **Metriche Target**
|
||
- **Unit Test Coverage**: >80%
|
||
- **Feature Test Coverage**: >70%
|
||
- **Manual Test Coverage**: 100% funzionalità critiche
|
||
- **Bug Detection Rate**: >90% pre-produzione
|
||
|
||
---
|
||
|
||
## 🏗️ **STRATEGIA TESTING**
|
||
|
||
### 📋 **Piramide Test**
|
||
```
|
||
🔺 E2E Tests
|
||
🔺🔺🔺 Integration Tests
|
||
🔺🔺🔺🔺🔺 Feature Tests
|
||
🔺🔺🔺🔺🔺🔺🔺 Unit Tests
|
||
```
|
||
|
||
### 🎪 **Ambienti Test**
|
||
1. **Local Development** - Test sviluppatore
|
||
2. **CI/CD Pipeline** - Test automatici GitHub
|
||
3. **Staging** - Test pre-produzione
|
||
4. **Production** - Monitor e test post-deploy
|
||
|
||
---
|
||
|
||
## 🧪 **TIPI DI TEST**
|
||
|
||
### 1️⃣ **UNIT TESTS** *(Foundation)*
|
||
|
||
#### 🧮 **Modelli e Business Logic**
|
||
```php
|
||
// File: tests/Unit/Models/
|
||
- StabileTest.php # Test model Stabile
|
||
- UnitaTest.php # Test model Unità
|
||
- SoggettoTest.php # Test model Soggetto
|
||
- GestioneTest.php # Test model Gestione
|
||
- ContrattoTest.php # Test model Contratto
|
||
|
||
// Test: Relazioni, validazioni, accessors/mutators
|
||
public function test_stabile_has_many_unita()
|
||
public function test_calcolo_millesimi_distribuzione()
|
||
public function test_validazione_codice_fiscale()
|
||
```
|
||
|
||
#### 💰 **Services Contabili** `[CRITICO]`
|
||
```php
|
||
// File: tests/Unit/Services/
|
||
- ContabilitaServiceTest.php # Calcoli contabili
|
||
- MillesimiServiceTest.php # Ripartizioni millesimi
|
||
- FatturazioneServiceTest.php # Gestione fatture
|
||
|
||
// Test: Precisione calcoli, arrotondamenti, quadrature
|
||
public function test_ripartizione_senza_resto()
|
||
public function test_arrotondamento_millesimi_corretto()
|
||
public function test_bilancio_sempre_quadrato()
|
||
```
|
||
|
||
#### 🔐 **Autenticazione e Autorizzazioni**
|
||
```php
|
||
// File: tests/Unit/Auth/
|
||
- RolePermissionTest.php # Test ruoli e permessi
|
||
- UserAccessTest.php # Test accesso utenti
|
||
- SwitchUserTest.php # Test cambio utente
|
||
|
||
// Test: Permessi granulari, sicurezza multi-ruolo
|
||
public function test_admin_can_access_all_stabili()
|
||
public function test_condomino_sees_only_own_data()
|
||
```
|
||
|
||
### 2️⃣ **FEATURE TESTS** *(Integration)*
|
||
|
||
#### 🎨 **Interfaccia CRUD**
|
||
```php
|
||
// File: tests/Feature/Admin/
|
||
- StabileControllerTest.php # CRUD Stabili
|
||
- UnitaControllerTest.php # CRUD Unità
|
||
- SoggettoControllerTest.php # CRUD Soggetti
|
||
- GestioneControllerTest.php # CRUD Gestioni
|
||
|
||
// Test: HTTP responses, form validation, database persistence
|
||
public function test_admin_can_create_stabile()
|
||
public function test_stabile_validation_rules()
|
||
public function test_unauthorized_access_blocked()
|
||
```
|
||
|
||
#### 🔗 **Menu e Navigazione**
|
||
```php
|
||
// File: tests/Feature/Navigation/
|
||
- MenuNavigationTest.php # Test tutti i link menu
|
||
- ResponsiveLayoutTest.php # Test layout responsive
|
||
- BreadcrumbTest.php # Test breadcrumb navigation
|
||
|
||
// Test: Link funzionanti, pagine accessibili, UI responsive
|
||
public function test_all_menu_links_reachable()
|
||
public function test_mobile_navigation_works()
|
||
```
|
||
|
||
#### 📊 **API Endpoints** *(Quando implementate)*
|
||
```php
|
||
// File: tests/Feature/Api/
|
||
- AuthApiTest.php # API autenticazione
|
||
- StabileApiTest.php # API gestione stabili
|
||
- ContabilitaApiTest.php # API dati contabili
|
||
|
||
// Test: JSON responses, authentication, rate limiting
|
||
public function test_api_requires_authentication()
|
||
public function test_api_returns_correct_json_structure()
|
||
```
|
||
|
||
### 3️⃣ **INTEGRATION TESTS** *(End-to-End)*
|
||
|
||
#### 🔄 **Workflow Completi**
|
||
```php
|
||
// File: tests/Integration/
|
||
- CondominioWorkflowTest.php # Flusso gestione condominio
|
||
- FatturazioneWorkflowTest.php # Flusso fatturazione completo
|
||
- ComunicazioneWorkflowTest.php # Flusso comunicazioni
|
||
|
||
// Test: Flussi business completi, integrazione componenti
|
||
public function test_complete_condominio_setup()
|
||
public function test_fatturazione_end_to_end()
|
||
```
|
||
|
||
### 4️⃣ **E2E TESTS** *(Browser)*
|
||
|
||
#### 🌐 **Test Browser** *(Laravel Dusk)*
|
||
```php
|
||
// File: tests/Browser/
|
||
- AdminDashboardTest.php # Test dashboard completa
|
||
- CrudWorkflowTest.php # Test CRUD browser
|
||
- MobileResponsiveTest.php # Test mobile real browser
|
||
|
||
// Test: User interactions, JavaScript, real browser behavior
|
||
public function test_admin_login_and_navigate()
|
||
public function test_mobile_menu_interaction()
|
||
```
|
||
|
||
---
|
||
|
||
## 📋 **TEST CASES SPECIFICI**
|
||
|
||
### 💰 **Testing Contabilità** `[MASSIMA PRIORITÀ]`
|
||
|
||
#### 🧮 **Calcoli Precisione**
|
||
```php
|
||
// Test arrotondamenti millesimi
|
||
public function test_millesimi_no_resto_perduto()
|
||
{
|
||
// 1000€ / 3 proprietari
|
||
// Expected: 333.34€ + 333.33€ + 333.33€ = 1000.00€
|
||
// NOT: 333.33€ * 3 = 999.99€ ❌
|
||
}
|
||
|
||
public function test_distribuzione_resto_progressiva()
|
||
{
|
||
// Resto distribuito ai primi N soggetti
|
||
// Sempre bilancio quadrato al centesimo
|
||
}
|
||
|
||
public function test_calcoli_rate_condominiali()
|
||
{
|
||
// Calcolo rate basato su millesimi
|
||
// Verifica totale = budget previsto
|
||
}
|
||
```
|
||
|
||
#### 📊 **Quadrature Bilanci**
|
||
```php
|
||
public function test_bilancio_sempre_quadrato()
|
||
{
|
||
// Entrate - Uscite = Residuo
|
||
// Precisione decimale garantita
|
||
}
|
||
|
||
public function test_ripartizione_spese_corretta()
|
||
{
|
||
// Spese comuni + spese private = totale
|
||
// Distribuzione per millesimi corretta
|
||
}
|
||
```
|
||
|
||
### 🔐 **Testing Sicurezza Multi-Ruolo**
|
||
|
||
#### 👤 **Separazione Ruoli**
|
||
```php
|
||
public function test_admin_full_access()
|
||
{
|
||
// Amministratore: accesso a tutti gli stabili
|
||
}
|
||
|
||
public function test_condomino_limited_access()
|
||
{
|
||
// Condomino: solo proprio stabile e unità
|
||
}
|
||
|
||
public function test_fornitore_invoice_only()
|
||
{
|
||
// Fornitore: solo fatture proprie
|
||
}
|
||
|
||
public function test_switch_user_functionality()
|
||
{
|
||
// Test cambio utente per debug multi-ruolo
|
||
}
|
||
```
|
||
|
||
### 🔗 **Testing Menu e UI**
|
||
|
||
#### 🗺️ **Navigazione Completa**
|
||
```php
|
||
public function test_all_menu_items_accessible()
|
||
{
|
||
// Verifica ogni link in lang/it/menu.php
|
||
// Status 200 per pagine autorizzate
|
||
// Redirect login per pagine non autorizzate
|
||
}
|
||
|
||
public function test_responsive_design()
|
||
{
|
||
// Breakpoints: 320px, 768px, 1024px, 1440px
|
||
// Menu hamburger su mobile
|
||
// Tables scrollable su mobile
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
## 🚀 **ESECUZIONE TEST**
|
||
|
||
### 💻 **Comandi Base**
|
||
```bash
|
||
# Test completi
|
||
php artisan test
|
||
|
||
# Test specifici per categoria
|
||
php artisan test --testsuite=Unit
|
||
php artisan test --testsuite=Feature
|
||
php artisan test --group=contabilita
|
||
php artisan test --group=security
|
||
|
||
# Test con coverage
|
||
php artisan test --coverage
|
||
php artisan test --coverage-html coverage-report
|
||
|
||
# Test specifici file
|
||
php artisan test tests/Unit/Services/ContabilitaServiceTest.php
|
||
php artisan test --filter test_calcolo_millesimi
|
||
```
|
||
|
||
### 🔄 **CI/CD Pipeline**
|
||
```yaml
|
||
# .github/workflows/tests.yml
|
||
name: Tests
|
||
on: [push, pull_request]
|
||
jobs:
|
||
test:
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- uses: actions/checkout@v3
|
||
- name: Setup PHP
|
||
uses: shivammathur/setup-php@v2
|
||
with:
|
||
php-version: '8.1'
|
||
- name: Install dependencies
|
||
run: composer install
|
||
- name: Run tests
|
||
run: php artisan test --coverage
|
||
- name: Upload coverage
|
||
uses: codecov/codecov-action@v3
|
||
```
|
||
|
||
---
|
||
|
||
## 📊 **COVERAGE E METRICHE**
|
||
|
||
### 🎯 **Target Coverage**
|
||
```
|
||
Overall Coverage: >70%
|
||
Models: >90%
|
||
Controllers: >80%
|
||
Services: >95% (contabilità)
|
||
Middleware: >85%
|
||
Form Requests: >90%
|
||
```
|
||
|
||
### 📈 **Tracking Progress**
|
||
```bash
|
||
# Generazione report coverage
|
||
php artisan test --coverage-html public/coverage
|
||
|
||
# Accesso report: http://localhost:8000/coverage
|
||
# Monitoring: Uptime, performance, error rate
|
||
```
|
||
|
||
---
|
||
|
||
## 🧪 **TEST MANUALI**
|
||
|
||
### ✅ **Checklist Test Manuale**
|
||
|
||
#### 🎨 **UI/UX Testing**
|
||
- [ ] **Login/Logout** - Funzionalità base
|
||
- [ ] **Menu Navigation** - Tutti i link funzionanti
|
||
- [ ] **Form Validation** - Messaggi errore chiari
|
||
- [ ] **CRUD Operations** - Create/Read/Update/Delete
|
||
- [ ] **Responsive Design** - Mobile/tablet/desktop
|
||
- [ ] **Performance** - Tempi caricamento <2s
|
||
|
||
#### 🔐 **Security Testing**
|
||
- [ ] **Role Permissions** - Accesso corretto per ruolo
|
||
- [ ] **Data Isolation** - Utenti vedono solo propri dati
|
||
- [ ] **CSRF Protection** - Token presenti su form
|
||
- [ ] **XSS Prevention** - Input/output sanitized
|
||
- [ ] **SQL Injection** - Prepared statements used
|
||
|
||
#### 💰 **Business Logic Testing**
|
||
- [ ] **Calcoli Contabili** - Precisione e quadrature
|
||
- [ ] **Ripartizioni** - Millesimi distribuiti correttamente
|
||
- [ ] **Fatturazione** - Importi e tasse corrette
|
||
- [ ] **Comunicazioni** - Email/SMS funzionanti
|
||
|
||
### 📱 **Test Dispositivi**
|
||
```
|
||
Desktop: Chrome, Firefox, Safari, Edge
|
||
Mobile: iOS Safari, Android Chrome
|
||
Tablet: iPad, Android tablet
|
||
```
|
||
|
||
---
|
||
|
||
## 📊 **TEST DATA E FIXTURES**
|
||
|
||
### 🗃️ **Database Test**
|
||
```php
|
||
// File: database/factories/
|
||
- StabileFactory.php # Factory dati stabili
|
||
- UnitaFactory.php # Factory dati unità
|
||
- SoggettoFactory.php # Factory dati soggetti
|
||
|
||
// File: database/seeders/test/
|
||
- TestContabilitaSeeder.php # Dati test contabilità
|
||
- TestScenarioSeeder.php # Scenari test complessi
|
||
```
|
||
|
||
### 📊 **Scenari Test**
|
||
```php
|
||
// Scenario 1: Piccolo condominio
|
||
- 1 stabile, 8 unità, 12 soggetti
|
||
- Budget annuale: 20.000€
|
||
- Test: Calcoli base
|
||
|
||
// Scenario 2: Condominio complesso
|
||
- 3 stabili, 45 unità, 60 soggetti
|
||
- Budget annuale: 150.000€
|
||
- Test: Performance, calcoli complessi
|
||
|
||
// Scenario 3: Edge cases
|
||
- Unità con millesimi 0
|
||
- Soggetti con quote multiple
|
||
- Test: Gestione eccezioni
|
||
```
|
||
|
||
---
|
||
|
||
## 🚨 **GESTIONE ERRORI E BUG**
|
||
|
||
### 🐛 **Bug Tracking**
|
||
```
|
||
Priorità 1 (CRITICO): Calcoli sbagliati, data loss, security
|
||
Priorità 2 (ALTO): UI broken, performance issues
|
||
Priorità 3 (MEDIO): Minor UI glitches, usability
|
||
Priorità 4 (BASSO): Enhancement, nice-to-have
|
||
```
|
||
|
||
### 📊 **Issue Template**
|
||
```markdown
|
||
## Bug Report
|
||
**Priorità**: [1-4]
|
||
**Ambiente**: [dev/staging/prod]
|
||
**Browser**: [Chrome/Firefox/Safari/Mobile]
|
||
**Utente**: [admin/condomino/fornitore]
|
||
|
||
**Descrizione**:
|
||
Cosa è successo vs cosa ci si aspettava
|
||
|
||
**Passi per riprodurre**:
|
||
1. Step 1
|
||
2. Step 2
|
||
3. Step 3
|
||
|
||
**Screenshot/Log**:
|
||
[Allegare se possibile]
|
||
```
|
||
|
||
---
|
||
|
||
## 📅 **CRONOGRAMA TESTING**
|
||
|
||
### 📋 **Settimana 1** *(Corrente)*
|
||
- [x] Setup base PHPUnit
|
||
- [x] Primi test models
|
||
- [ ] Test contabilità base
|
||
- [ ] Test menu navigation
|
||
|
||
### 📋 **Settimana 2**
|
||
- [ ] Test controllers CRUD
|
||
- [ ] Test authorization
|
||
- [ ] Test responsive design
|
||
- [ ] Setup CI/CD pipeline
|
||
|
||
### 📋 **Settimana 3**
|
||
- [ ] Integration tests
|
||
- [ ] Performance testing
|
||
- [ ] Security testing
|
||
- [ ] Browser testing (Dusk)
|
||
|
||
### 📋 **Settimana 4**
|
||
- [ ] User acceptance testing
|
||
- [ ] Load testing
|
||
- [ ] Documentation test coverage
|
||
- [ ] Production deploy testing
|
||
|
||
---
|
||
|
||
## 📞 **TOOLS E RISORSE**
|
||
|
||
### 🔧 **Testing Tools**
|
||
- **PHPUnit**: Unit e Feature tests
|
||
- **Laravel Dusk**: Browser testing
|
||
- **Pest**: Alternativa a PHPUnit (opzionale)
|
||
- **Faker**: Generazione dati fake
|
||
- **Mockery**: Mocking objects
|
||
|
||
### 📊 **Coverage Tools**
|
||
- **Xdebug**: Code coverage PHP
|
||
- **Codecov**: Coverage tracking online
|
||
- **PHPStorm Coverage**: IDE integration
|
||
|
||
### 🌐 **Frontend Testing**
|
||
- **Laravel Mix**: Asset compilation
|
||
- **Jest**: JavaScript unit tests
|
||
- **Cypress**: E2E frontend testing
|
||
|
||
---
|
||
|
||
## 🎯 **PROSSIMI PASSI**
|
||
|
||
### 🚀 **Immediato** *(Oggi)*
|
||
1. ✅ **Setup** PHPUnit configurazione base
|
||
2. 🧮 **Creare** test contabilità critici
|
||
3. 🔗 **Test** navigation menu principale
|
||
4. 📊 **Documentare** risultati primi test
|
||
|
||
### 📅 **Questa Settimana**
|
||
1. 🎨 **Test** CRUD controllers base
|
||
2. 🔐 **Test** sistema autorizzazioni
|
||
3. 📱 **Test** responsive layout
|
||
4. 🤖 **Setup** automazione CI/CD
|
||
|
||
---
|
||
|
||
*🔄 Aggiornare piano test settimanalmente*
|
||
*📊 Review coverage ogni milestone*
|
||
*🎯 Focus qualità prima di quantità*
|