name: Run tests

on: [push]

jobs:
  tests:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: true
      matrix:
        php: [ 8.5 ]

    name: PHP ${{ matrix.php }}

    steps:
      - uses: actions/checkout@v5

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
          coverage: none

      - name: Copy env file
        run:
          cp .env.test .env

      - name: Run composer install
        run: composer install --prefer-dist --no-interaction --no-progress --no-scripts
        env:
          COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GITHUB_TOKEN }}"}}'

      - name: Generate app key
        run: |
          APP_KEY=$(php -r "echo 'base64:' . base64_encode(random_bytes(32));")
          sed -i "s|APP_KEY=.*|APP_KEY=$APP_KEY|" .env

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