build_settings:
    verbose: false
    prefer_symlink: false
    ignore:
        - "vendor"
        - "tests"
    pgsql:
        host: 'localhost;dbname=template1'
        user: 'fhcomplete'
        pass: 'fhcomplete'

setup:
    composer:
        action: "install"
        prefer_dist: true
        no_dev: true
    pgsql:
        - "UPDATE pg_database SET datallowconn = 'false' WHERE datname = 'fhctest';" # Stops connections to database
        - "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid() AND datname = 'fhctest';" # Close previous connections to database
        - "DROP DATABASE IF EXISTS fhctest;" # Drops database
        - "CREATE DATABASE fhctest OWNER fhcomplete;" # Creates database
    shell:
        - "rm -f /var/www/html/build" # Remove the previous soft link, if exists, to the build directory
        - "ln -s %BUILD_PATH% /var/www/html/build" # Create a new soft link to the actual build directory
        # Copies configuration files
        - "cp /home/phpci/config/*.inc.php %BUILD_PATH%/config/"
        - "cp /home/phpci/config/*.php %BUILD_PATH%/application/config/"
        - "cd %BUILD_PATH% && php index.ci.php DBTools migrate" # Install Database
test:
    lint:
        directories:
            - "application/"
        recursive: true
    codeception:
        config: "tests/codeception/"
        path: "tests/codeception/_output/"
#    php_docblock_checker:
#        path: "application/controllers/"
#        allowed_warnings: 100
#        skip_classes: false
#    php_code_sniffer:
#        path: "application/controllers/"
#        standard: "tests/codesniffer/FHComplete"
#        allowed_errors: 200
#        allowed_warnings: 200
#    php_unit:
#        directory: "tests/phpunit/"

complete:
    pgsql:
        - "UPDATE pg_database SET datallowconn = 'false' WHERE datname = 'fhctest';" # Stops connections to database
        - "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid() AND datname = 'fhctest';" # Close previous connections to database
        - "DROP DATABASE IF EXISTS fhctest;" # Drops database
    shell:
        - "rm -f /var/www/html/build" # Remove the previous soft link, if exists, to the build directory