sudo: false
language: php
php:
    - 7.2
env:
    global:
        - DB=sqlite
    matrix:
        - CORE_BRANCH=stable19 REPO=nextcloud/server

matrix:
    fast_finish: true

before_install:
    - wget https://phar.phpunit.de/phpunit-5.7.phar
    - chmod +x phpunit-5.7.phar
    - mkdir bin
    - mv phpunit-5.7.phar bin/phpunit
    - phpunit --version
    - cd ../
    - git clone https://github.com/$REPO.git --recursive --depth 1 -b $CORE_BRANCH mainrepo
    - mv apporder mainrepo/apps/

before_script:
    # fill owncloud with default configs and enable apporder
    - cd mainrepo
    - mkdir data
    - ./occ maintenance:install --database-name oc_autotest --database-user oc_autotest --admin-user admin --admin-pass admin --database $DB --database-pass=''
    - ./occ app:enable apporder
    - ./occ app:check-code apporder
    - php -S localhost:8080 &
    - cd apps/apporder
    - export PATH="$PWD/bin:$PATH"


script:
    - make test

after_failure:
    - cat ../../data/owncloud.log

after_success:
    - wget https://scrutinizer-ci.com/ocular.phar
    - php ocular.phar code-coverage:upload --format=php-clover build/php-unit.clover
