name: tests

on:
  push:
  pull_request:

jobs:
  windows_tests:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: true
      matrix:
        php: [8.5, 8.4, 8.3, 8.2]
        laravel: ['11.*', '12.*']
        stability: [prefer-lowest, prefer-stable]
        exclude:
          - php: 8.5
            laravel: 11.*
        include:
          - laravel: 11.*
            testbench: ^9.2
          - laravel: 12.*
            testbench: 10.*

    name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.stability }}

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Get Composer cache directory
        id: composer-cache
        run: |
          echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

      - uses: actions/cache@v4
        with:
          path: ${{ steps.composer-cache.outputs.dir }}
          key: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.laravel }}-${{ matrix.testbench }}-${{ matrix.stability }}-composer
          restore-keys: |
            ${{ runner.os }}-${{ matrix.php }}-${{ matrix.laravel }}-${{ matrix.testbench }}-${{ matrix.stability }}-composer

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: curl
          coverage: xdebug

      - name: Install dependencies
        run: |
          composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
          composer update --${{ matrix.stability }} --prefer-dist --no-interaction

      - name: Run tests
        run: vendor/bin/phpunit
