<?xml version="1.0" encoding="UTF-8"?>
<!--
  phpunit.xml — configurazione per test Commerce checkout in DDEV.
  Richiede PHPUnit 11.x (installato via drupal/core-dev ^11.3).

  Esecuzione BrowserTestBase (circa 2 minuti, nessun Chrome):
    ddev exec env SIMPLETEST_DB="sqlite://localhost//tmp/drupal_test.sqlite" \
      vendor/bin/phpunit -c phpunit.xml -testsuite alemilani_checkout_functional -testdox

  Esecuzione FunctionalJavascript (richiede ddev-selenium-standalone-chrome):
    ddev add-on get ddev/ddev-selenium-standalone-chrome
    ddev restart
    ddev exec env SIMPLETEST_DB="sqlite://localhost//tmp/drupal_test_js.sqlite" \
      vendor/bin/phpunit -c phpunit.xml -testsuite alemilani_checkout_js -testdox
-->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         bootstrap="web/core/tests/bootstrap.php"
         colors="true"
         cacheResult="false"
         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd">

  <php>
    <ini name="error_reporting" value="32767"/>
    <ini name="memory_limit" value="-1"/>

    <!-- "http://web" e' l'hostname interno Docker del container DDEV.
         I BrowserKit tests lo usano come base URL dell'installazione Drupal.
         Chrome (nel container Selenium) lo raggiunge senza SSL, evitando
         l'InvalidCookieDomain causato dal certificato DDEV non fidato. -->
    <env name="SIMPLETEST_BASE_URL" value="http://web"/>

    <!-- URL mostrato nei link di output (PhpStorm, terminale) -->
    <env name="BROWSERTEST_OUTPUT_BASE_URL" value="https://schoool.ddev.site"/>

    <!-- DB isolato. Sovrascrivibile da riga di comando (no force). -->
    <env name="SIMPLETEST_DB" value="sqlite://localhost//tmp/drupal_test.sqlite"/>

    <!-- ChromeDriver per FunctionalJavascript.
         Il servizio si chiama "selenium__standalone-chrome" nella rete DDEV.
         ignore-certificate-errors: protezione extra per eventuali redirect HTTPS. -->
    <env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["chrome", {"browserName":"chrome","goog:chromeOptions":{"args":["--disable-gpu","--headless","--no-sandbox","--disable-dev-shm-usage","--window-size=1920,1080","--ignore-certificate-errors"]}}, "http://selenium__standalone-chrome:4444/wd/hub"]'/>

    <!-- Silenzia i deprecation notice di Drupal/Commerce durante i test -->
    <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>
  </php>

  <testsuites>
    <!-- Solo BrowserTestBase — niente Chrome -->
    <testsuite name="alemilani_checkout_functional">
      <directory>web/modules/custom/commerce_checkout_tests/tests/src/Functional</directory>
    </testsuite>

    <!-- Solo FunctionalJavascript — richiede Chrome e Selenium -->
    <testsuite name="alemilani_checkout_js">
      <directory>web/modules/custom/commerce_checkout_tests/tests/src/FunctionalJavascript</directory>
    </testsuite>

    <!-- Suite completa (Functional + FunctionalJavascript) -->
    <testsuite name="alemilani_checkout">
      <directory>web/modules/custom/commerce_checkout_tests/tests/src</directory>
    </testsuite>
  </testsuites>

</phpunit>
