I test backend sono organizzati per ambiente:
- GitHub Actions (CI): esegue solo test deterministici e CI-safe
- Locale: puoi eseguire tutti i test, inclusi quelli che richiedono DB/configurazioni specifiche
- Integration/External: test che richiedono servizi esterni (SOAP/HTTP) o Oracle (da eseguire solo in ambienti controllati)
Questi test vengono eseguiti automaticamente in GitHub (selezione tramite --filter):
./vendor/bin/phpunit --testsuite Unit --filter "testInsegamentiRelation|testQueryPrecontr|testReadStoreAttachment|testStatoCivile|testValidazioneSamlResponse"- Database MySQL (creato nella pipeline)
- Utente
enrico.oliva@uniurb.it(creato conphp artisan migrate --seed)
cd unicontract-backend
cp .env.example .env
php artisan key:generate
php artisan migrate --seed./vendor/bin/phpunit --testsuite Unit --filter "testInsegamentiRelation|testQueryPrecontr|testReadStoreAttachment|testStatoCivile|testValidazioneSamlResponse"Oppure un singolo test:
./vendor/bin/phpunit --testsuite Unit --filter "testInsegamentiRelation"./vendor/bin/phpunit --testsuite Unit --filter "testPrecontrattuale|testDateInsegnamento"./vendor/bin/phpunit --testsuite Unit --filter "testCalcoloNumeroRinnovi"Nota: richiede connessione a database Oracle configurata.
./vendor/bin/phpunitI test possono includere marker PHPDoc per indicare dipendenze:
@github-executable true@requires-database@requires-database-oracle@requires-user <email>@requires-service <name>
Esempio:
/**
* @github-executable true
* @requires-user enrico.oliva@uniurb.it
*/
public function testQueryPrecontr()
{
// ...
}La pipeline GitHub Actions esegue automaticamente:
- Setup PHP 8.2
- Installazione dipendenze Composer
- Configurazione database MySQL
- Migrazione e seeding
- Esecuzione dei test CI-safe (whitelist tramite
--filter) - Parallel test execution - Ogni test viene eseguito separatamente (se configurato nel workflow)
Nota: i dettagli esatti dipendono dal workflow presente nel repository (es. file in
.github/workflows/).
- MySQL non disponibile o credenziali errate in
.env - verificare
DB_HOST,DB_DATABASE,DB_USERNAME,DB_PASSWORD
Il test testValidazioneSamlResponse richiede response.xml in:
storage/app/
Eseguire:
php artisan migrate --seed