name: Tests

on:
  push:
    branches: [master, v4]
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        php:
        - '8.2'
        - '8.1'
        - '8.0'
        deps:
        - highest
        include:
          - {php: '8.0', deps: lowest}
          - {php: '8.0', deps: dingo}

    name: Tests (PHP ${{ matrix.php }} - ${{ matrix.deps }})

    steps:
      - uses: actions/checkout@v2
      - name: Setup PHP ${{ matrix.php }}
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
          coverage: xdebug

      - name: Install dependencies
        if: ${{ matrix.deps == 'highest' }}
        run: composer update

      - name: Install dependencies (Dingo)
        if: ${{ matrix.deps == 'dingo' }}
        run: COMPOSER=composer.dingo.json composer update --prefer-stable

      - name: Install dependencies (lowest)
        if: ${{ matrix.deps == 'lowest' }}
        run: COMPOSER=composer.lowest.json composer update --prefer-stable


      - name: Execute tests (Laravel/Lumen)
        run: composer test-ci
        if: ${{ matrix.deps == 'highest' }}

      - name: Execute tests (Lowest)
        run: COMPOSER=composer.lowest.json composer test-ci
        if: ${{ matrix.deps == 'lowest' }}

      - name: Execute tests (Dingo)
        run: COMPOSER=composer.dingo.json composer test-ci
        if: ${{ matrix.deps == 'dingo' }}
