<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
         bootstrap="bootstrap.php"
         cacheResultFile=".phpunit.result.cache"
         executionOrder="depends,defects"
         forceCoversAnnotation="false"
         beStrictAboutCoversAnnotation="true"
         beStrictAboutOutputDuringTests="true"
         beStrictAboutTodoAnnotatedTests="true"
         convertDeprecationsToExceptions="true"
         failOnRisky="true"
         failOnWarning="true"
         verbose="true">
    
    <!-- Test Suites -->
    <testsuites>
        <testsuite name="OAuth Integration">
            <file>OAuthIntegrationTest.php</file>
        </testsuite>
        
        <testsuite name="API Client Integration">
            <file>ApiClientIntegrationTest.php</file>
        </testsuite>
        
        <testsuite name="API Contract">
            <file>MoloniApiContractTest.php</file>
        </testsuite>
        
        <testsuite name="All Tests">
            <directory>.</directory>
        </testsuite>
    </testsuites>

    <!-- Code Coverage -->
    <coverage cacheDirectory=".phpunit.cache"
              processUncoveredFiles="true">
        <include>
            <directory suffix=".php">../libraries</directory>
            <directory suffix=".php">../controllers</directory>
        </include>
        
        <exclude>
            <directory>.</directory>
            <file>../libraries/vendor</file>
        </exclude>
        
        <report>
            <html outputDirectory="coverage-html"/>
            <text outputFile="coverage.txt"/>
            <clover outputFile="coverage.xml"/>
        </report>
    </coverage>

    <!-- Logging -->
    <logging>
        <junit outputFile="test-results.xml"/>
        <teamcity outputFile="teamcity.txt"/>
        <testdoxHtml outputFile="testdox.html"/>
        <testdoxText outputFile="testdox.txt"/>
    </logging>

    <!-- PHP Settings -->
    <php>
        <!-- Environment Variables for Testing -->
        <env name="ENVIRONMENT" value="testing"/>
        <env name="MOLONI_TEST_MODE" value="true"/>
        <env name="MOLONI_TEST_CLIENT_ID" value="test_client_id"/>
        <env name="MOLONI_TEST_CLIENT_SECRET" value="test_client_secret"/>
        <env name="MOLONI_TEST_COMPANY_ID" value="12345"/>
        
        <!-- PHP Configuration -->
        <ini name="error_reporting" value="E_ALL"/>
        <ini name="display_errors" value="1"/>
        <ini name="display_startup_errors" value="1"/>
        <ini name="memory_limit" value="512M"/>
        <ini name="date.timezone" value="Europe/Lisbon"/>
        
        <!-- Test Database Configuration -->
        <env name="CI_ENV" value="testing"/>
        <env name="database.tests.hostname" value="localhost"/>
        <env name="database.tests.database" value="desk_moloni_test"/>
        <env name="database.tests.username" value="test_user"/>
        <env name="database.tests.password" value="test_password"/>
    </php>

    <!-- Test Execution -->
    <extensions>
        <!-- Add any PHPUnit extensions here -->
    </extensions>
    
    <!-- Test Listeners -->
    <listeners>
        <!-- Add custom test listeners here -->
    </listeners>
</phpunit>