machine:
  php:
    version: 5.4.21

  environment:
    CIRCLE_ENV: test
    WP_MULTISITE: 0
    WP_CORE_DIR: /home/ubuntu/wordpress-develop
    WP_TESTS_DIR: /home/ubuntu/wordpress-develop/tests/phpunit
    plugin_loc: /home/ubuntu/$CIRCLE_PROJECT_REPONAME
    plugin_slug: $CIRCLE_PROJECT_REPONAME
    plugin_dir: /home/ubuntu/wordpress-develop/src/wp-content/plugins/$plugin_slug
    plugin_tests_dir: /home/ubuntu/wordpress-develop/src/wp-content/plugins/$plugin_slug/tests

dependencies:
  pre: #enable xdebug. LINE 1/2 to uncomment if you want to run a code coverage report.
  # - sed -i 's/^;//' ~/.phpenv/versions/$(phpenv global)/etc/conf.d/xdebug.ini
  #setup WP install
  - git clone git://develop.git.wordpress.org/ $WP_CORE_DIR;
  - cd $WP_CORE_DIR && cp wp-tests-config-sample.php wp-tests-config.php && sed -i "s/youremptytestdbnamehere/wordpress_test/" wp-tests-config.php && sed -i "s/yourusernamehere/root/" wp-tests-config.php && sed -i "s/yourpasswordhere//" wp-tests-config.php;
  # move plugin into tests/src
  - mv $plugin_loc $plugin_dir;
  # set up database
  - mysql -e 'CREATE DATABASE wordpress_test;' -uroot;
  #- wget https://phar.phpunit.de/phpunit.phar && chmod +x phpunit.phar && mv phpunit.phar /home/ubuntu/.phpenv/shims/phpunit 
  - pear install PHP_CodeSniffer
  override:
    - cd $plugin_dir; composer install --prefer-source --no-interaction --no-dev

## tests override
test:
  override:
    # comment out the below line to run a code coverage report.
    # - cd $plugin_tests_dir; phpunit
    - cd $plugin_dir; ./test.sh
    ## LINE 2/2 to uncomment if you want to run a code coverage report.
    # - cd $plugin_tests_dir; phpunit --coverage-html $CIRCLE_ARTIFACTS




    
