Skip to content

Commit

Permalink
travis: tested using Nette Coding Standard
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jul 21, 2017
1 parent 21154f9 commit f6984a9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
25 changes: 18 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,43 @@ matrix:
include:
- php: 7.0
env: coverage=on
- php: 7.1
env: codingStandard=on

allow_failures:
- php: 7.0
env: coverage=on

script:
- vendor/bin/tester tests -s -c tests/php-unix.ini $coverageArgs
- php temp/code-checker/src/code-checker.php --short-arrays --strict-types -i tests/Utils/fixtures.reflection
- >
if [ "$codingStandard" ]; then
php temp/code-checker/src/code-checker.php --short-arrays --strict-types -i tests/Utils/fixtures.reflection
&& php temp/coding-standard/ecs check src tests --config tests/coding-standard.neon;
fi
after_failure:
# Print *.actual content
- for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done

before_script:
# Install Nette Tester & Code Checker
# Install Nette Tester
- travis_retry composer install --no-interaction --prefer-dist
- travis_retry composer create-project nette/code-checker temp/code-checker ~2.8 --no-interaction
- if [ "$coverage" == "on" ]; then coverageArgs="-p phpdbg --coverage ./coverage.xml --coverage-src ./src"; fi
# Install Code Checkers
- >
if [ "$codingStandard" ]; then
travis_retry composer create-project nette/code-checker temp/code-checker ~2 --no-interaction;
travis_retry composer create-project nette/coding-standard temp/coding-standard --no-interaction;
fi
- if [ "$coverage" ]; then coverageArgs="-p phpdbg --coverage ./coverage.xml --coverage-src ./src"; fi

after_script:
# Report Code Coverage
- >
if [ "$coverage" == "on" ]; then
if [ "$coverage" ]; then
wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar
&& php coveralls.phar --verbose --config tests/.coveralls.yml
|| true; fi
&& php coveralls.phar --verbose --config tests/.coveralls.yml;
fi
sudo: false

Expand Down
2 changes: 1 addition & 1 deletion src/Utils/Arrays.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static function flatten(array $arr, bool $preserveKeys = false): array
$res = [];
$cb = $preserveKeys
? function ($v, $k) use (&$res) { $res[$k] = $v; }
: function ($v) use (&$res) { $res[] = $v; };
: function ($v) use (&$res) { $res[] = $v; };
array_walk_recursive($arr, $cb);
return $res;
}
Expand Down
13 changes: 13 additions & 0 deletions tests/coding-standard.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
includes:
- ../temp/coding-standard/coding-standard-php70.neon

parameters:
skip:
PHP_CodeSniffer\Standards\PSR1\Sniffs\Methods\CamelCapsMethodNameSniff:
- tests/Utils/FileSystem.phpt # RemoteStream extends streamWrapper

PhpCsFixer\Fixer\Import\SingleImportPerStatementFixer:
- src/Utils/Arrays.php # use function
- src/Utils/Callback.php # use function
- src/Utils/Html.php # use function
- src/Utils/Strings.php # use function

0 comments on commit f6984a9

Please sign in to comment.