Skip to content

Commit

Permalink
[#9] Fix CS tools so tests will pass
Browse files Browse the repository at this point in the history
- Added PHPUnit and php-cs-fixer as dev dependencies; modified Travis
  configuration to use these tools to run CI tasks.
  • Loading branch information
weierophinney committed Jul 15, 2014
1 parent 27d1759 commit 8ed44a7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
35 changes: 35 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
printf("Executing php_cs!!!\n\n");
$finder = Symfony\CS\Finder\DefaultFinder::create()
->in(__DIR__)
->ignoreDotFiles(true)
->filter(function (SplFileInfo $file) {
$path = $file->getPathname();

switch (true) {
case (strrpos($path, '/test/Bootstrap.php')):
return false;
case (strrpos($path, '/vendor/')):
return false;
default:
return true;
}
});

return Symfony\CS\Config\Config::create()
->fixers(array(
'controls_spaces',
'braces',
'elseif',
'eof_ending',
'function_declaration',
'include',
'indentation',
'linefeed',
'php_closing_tag',
'short_tag',
'trailing_spaces',
'unused_use',
'visibility',
))
->finder($finder);
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ php:
- "5.4"
- "5.5"

before_install:
- wget http://cs.sensiolabs.org/get/php-cs-fixer.phar

before_script:
- composer install --dev
- composer self-update
- composer install --dev --prefer-source

script:
- (cd test ; phpunit -c phpunit.xml)
- output=$(php php-cs-fixer.phar fix -v --dry-run --level=psr2 .); if [[ $output ]]; then while read -r line; do echo -e "\e[00;31m$line\e[00m"; done <<< "$output"; false; fi;
- (cd test ; ../vendor/bin/phpunit -c phpunit.xml)
- ./vendor/bin/php-cs-fixer -v fix . --dry-run --config-file ./.php_cs
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"zendframework/zend-view": "2.*"
},
"require-dev": {
"fabpot/php-cs-fixer": "*@dev",
"phpunit/PHPUnit": "~3.7.0",
"zendframework/zend-servicemanager": "2.*"
}
}

0 comments on commit 8ed44a7

Please sign in to comment.