build: false
platform:
  - x64
clone_folder: C:\projects\migrations
clone_depth: 1

cache:
  - C:\ProgramData\chocolatey\bin -> .appveyor.yml
  - C:\ProgramData\chocolatey\lib -> .appveyor.yml
  - C:\tools\php -> .appveyor.yml
  - C:\tools\composer -> .appveyor.yml
  - '%LOCALAPPDATA%\Composer\files -> composer.json'

environment:
  matrix:
    - php: 7.2.25
    - php: 7.3.12

init:
  - SET PATH=C:\Program Files\OpenSSL;c:\tools\php;C:\tools\composer;%PATH%
  - SET COMPOSER_NO_INTERACTION=1
  - SET ANSICON=121x90 (121x90)

## Install PHP and composer, and run the appropriate composer command
install:
    - ps: |
        # Check if installation is cached
        if (!(Test-Path c:\tools\php)) {
          appveyor-retry cinst --params '""/InstallDir:C:\tools\php""' --no-progress --ignore-checksums -y php --version $env:php
          # install sqlite
          appveyor-retry cinst -y sqlite  --no-progress
          Get-ChildItem -Path c:\tools\php
          cd c:\tools\php

          # Set PHP environment items that are always needed
          copy php.ini-production php.ini

          Add-Content php.ini "`n date.timezone=UTC"
          Add-Content php.ini "`n extension_dir=ext"
          Add-Content php.ini "`n memory_limit=1G"
          Add-Content php.ini "`n extension=php_openssl.dll"
          Add-Content php.ini "`n extension=php_mbstring.dll"
          Add-Content php.ini "`n extension=php_fileinfo.dll"
          Add-Content php.ini "`n extension=php_pdo_sqlite.dll"
          Add-Content php.ini "`n extension=php_sqlite3.dll"
          Add-Content php.ini "`n extension=php_curl.dll"

        }
    - ps: |
        # download Composer
        if (!(Test-Path C:\tools\composer)) {
          New-Item -path c:\tools -name composer -itemtype directory
        }
        if (!(Test-Path c:\tools\composer\composer.phar)) {
          appveyor-retry appveyor DownloadFile https://getcomposer.org/composer.phar -Filename C:\tools\composer\composer.phar
          Set-Content -path 'C:\tools\composer\composer.bat' -Value ('@php C:\tools\composer\composer.phar %*')
        }

    # install composer dependencies
    - cd C:\projects\migrations
    - appveyor-retry composer self-update
    - appveyor-retry composer update --no-progress --prefer-dist

test_script:
  - vendor\bin\phpunit
