#!/usr/bin/env bash
  #
  # @project       : Domuscan App
  # @filename      : test_php.sh
  # @author        : Damiano | <dagneni@gmail.com>
  # @description   : Esegue i test dell'applicazione PHP (test/php/esegui_test.php) sul database
  #                  di test DB_NOME_TEST. Richiede PHP, il file .env e MariaDB in esecuzione.
  # @creation date : 15-10-2026
  # @last update   : 15-10-2026
  #
  # @version: 0.1.0
  #

source "$(dirname "$0")/libreria_test.sh"

echo "test_php"

if ! command -v php > /dev/null 2>&1; then
  verificaCondizione "interprete PHP disponibile" 1
  concludiTest
fi
if [ ! -f "$CARTELLA_PROGETTO/.env" ]; then
  verificaCondizione "file .env presente (copiare configurazione/.env.esempio)" 1
  concludiTest
fi

php "$CARTELLA_PROGETTO/test/php/esegui_test.php" | sed 's/^/  /'
verificaCondizione "test PHP superati" "${PIPESTATUS[0]}"

concludiTest
