From faaff0711d073b48640817068af49f98e667e60c Mon Sep 17 00:00:00 2001 From: Robert Hafner Date: Wed, 16 Apr 2014 00:28:38 -0700 Subject: [PATCH] Added code coverage and styling tests, refactored Added runTests.sh to wrap up a bunch of test starting functionality. Moved SetupEnvironment.sh out of Bootstrap.php and into the runTests.sh file. Added Coverall support for line coverage. Added php-cs-fixer for code styling testing. --- .coveralls.yml | 3 +++ .gitignore | 2 +- .travis.yml | 7 +++++-- composer.json | 6 +++++- phpunit.xml.dist | 5 +++-- tests/bootstrap.php | 5 +---- tests/runTests.sh | 17 +++++++++++++++++ 7 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 .coveralls.yml create mode 100755 tests/runTests.sh diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 0000000..cbd906c --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1,3 @@ +src_dir: src +coverage_clover: build/logs/clover.xml +json_path: build/logs/coveralls-upload.json \ No newline at end of file diff --git a/.gitignore b/.gitignore index 56f700e..75ec387 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .vagrant - /.idea /.settings /.buildpath @@ -7,3 +6,4 @@ /composer.lock /vendor /report +/build \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 9e11a95..7e6b7e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,11 @@ php: - 5.5 before_script: - - composer install --dev + - composer self-update && composer install --dev - vendor/tedivm/dovecottesting/SetupEnvironment.sh -script: phpunit --verbose --coverage-text \ No newline at end of file +script: ./tests/runTests.sh + +after_script: + - php vendor/bin/coveralls -v \ No newline at end of file diff --git a/composer.json b/composer.json index e9f85a0..3ae363f 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,11 @@ "php": ">=5.3.0" }, "require-dev": { - "tedivm/dovecottesting": "1.2.1" + "tedivm/dovecottesting": "1.2.1", + "phpunit/phpunit": "4.0.*", + "fabpot/php-cs-fixer": "0.4.0", + "satooshi/php-coveralls": "dev-master" + }, "autoload": { "psr-0": {"Fetch": "src/"} diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5eec1bf..26aa323 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -11,16 +11,17 @@ syntaxCheck="false" bootstrap="tests/bootstrap.php" > - ./tests - ./src/Fetch/ + + + diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 7597f3a..612a476 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -24,9 +24,6 @@ if(getenv('TRAVIS')) }else{ define('TESTING_ENVIRONMENT', 'VAGRANT'); define('TESTING_SERVER_HOST', '172.31.1.2'); - echo 'Initializing Environment using Vagrant' . PHP_EOL; - passthru('/bin/bash ' . __DIR__ . '/../vendor/tedivm/dovecottesting/SetupEnvironment.sh'); - echo 'Environment Initialized' . PHP_EOL . PHP_EOL . PHP_EOL; } $filename = __DIR__ .'/../vendor/autoload.php'; @@ -41,4 +38,4 @@ if (!file_exists($filename)) { }else{ $loader = require_once $filename; $loader->add('Fetch\\Test', __DIR__); -} \ No newline at end of file +} diff --git a/tests/runTests.sh b/tests/runTests.sh new file mode 100755 index 0000000..d4dc032 --- /dev/null +++ b/tests/runTests.sh @@ -0,0 +1,17 @@ +#/usr/bin/env/sh +set -e + +if [ ! -n "$TRAVIS" ]; then + ./vendor/tedivm/dovecottesting/SetupEnvironment.sh + sleep 5 +fi + +echo 'Running unit tests.' +phpunit --verbose --coverage-clover build/logs/clover.xml + +echo '' +echo '' +echo '' +echo 'Testing for Coding Styling Compliance.' +echo 'All code should follow PSR standards.' +./vendor/fabpot/php-cs-fixer/php-cs-fixer fix ./ --level="all" -vv --dry-run \ No newline at end of file