trigger: none

pool:
  vmImage: 'ubuntu-latest'

strategy:
  matrix:
    PHP 5.6:
      phpVersion: 5.6
    PHP 7.2:
      phpVersion: 7.2

steps:
- script: |
    sudo update-alternatives --set php /usr/bin/php$(phpVersion)
    sudo update-alternatives --set phar /usr/bin/phar$(phpVersion)
    sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpVersion)
    sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpVersion)
    sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpVersion)
    php -version
  displayName: 'Use PHP version $(phpVersion)'

- script: |
    composer install --no-interaction --prefer-dist 
  displayName: 'Install dependencies'

- script: |
    sudo rm -r /usr/local/bin/phpunit
    wget -O phpunit https://phar.phpunit.de/phpunit-5.phar
    chmod +x phpunit
    sudo mv phpunit /usr/local/bin/phpunit
  displayName: 'install PHPUnit 5'
  condition: eq(variables['phpVersion'], '5.6')

- script: |
    phpunit --log-junit test-results.xml
  displayName: 'Run tests with phpunit'
  
# Publish Test Results to Azure Pipelines/TFS
- task: PublishTestResults@2
  inputs:
    testRunner: 'JUnit'
    testResultsFiles: '**/test-results.xml'
    searchFolder: '$(System.DefaultWorkingDirectory)'
    mergeTestResults: false
    testRunTitle: '$(phpVersion)'
  condition: always()