Update Composer and Travis config

PHPUnit and PHPCS test execution is now available using Composer.
This commit is contained in:
Stefan Kalscheuer 2017-12-03 12:36:43 +01:00
parent 012b9a0189
commit d82de3547b
4 changed files with 40 additions and 10 deletions

View File

@ -7,9 +7,6 @@ php:
- '7.1'
- '7.2'
before_script:
- composer install --no-interaction
- vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs
- composer install
script:
- vendor/bin/phpunit ./test/statifyblacklist-test.php
- vendor/bin/phpcs statify-blacklist.php --standard=phpcs.xml
- vendor/bin/phpcs ./inc/ --standard=phpcs.xml --extensions=php
- composer test-all

View File

@ -30,11 +30,15 @@ gulp.task('test', ['compose'], function () {
// Execute PHP Code Sniffer.
gulp.task('test-cs', function (cb) {
return exec('./vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs', function (err, stdout, stderr) {
return exec('./vendor/bin/phpcs --config-set installed_paths vendor/wimg/php-compatibility,vendor/wp-coding-standards/wpcs', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
if (null === err) {
console.log('Running PHP Code Sniffer tests ...');
// exec('./vendor/bin/phpcs --standard=phpcs.xml', function(err, stdout, stderr) {
// console.log(stdout);
// console.log(stderr);
// });
gulp.src(['statify-blacklist.php', 'inc/**/*.php'])
.pipe(phpcs({bin: './vendor/bin/phpcs', standard: 'phpcs.xml'}))
.pipe(phpcs.reporter('log'));

View File

@ -22,9 +22,28 @@
"composer/installers": "~1.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.4",
"php": ">=5.5",
"phpunit/phpunit": "*",
"phpunit/php-code-coverage": "*",
"wp-coding-standards/wpcs": "~0.14.0"
"slowprog/composer-copy-file": "~0.2",
"squizlabs/php_codesniffer": "^3.1",
"wimg/php-compatibility": "^8.0",
"wp-coding-standards/wpcs": "~0.14"
},
"scripts": {
"test-all": [
"@test",
"@test-cs"
],
"test": [
"phpunit"
],
"test-cs": [
"phpcs --standard=phpcs.xml -s"
],
"fix-cs": [
"phpcbf --standard=phpcs.xml"
]
}
}

View File

@ -2,10 +2,16 @@
<ruleset name="StatifyBlacklist">
<description>Derived from WordPress Coding Standard</description>
<rule ref="WordPress">
<!-- Type hint checks mess up PHP 7 checks, while this plugin has compatibility level 5.5 and above. -->
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
<arg value="psvn"/>
<arg name="colors"/>
<!-- Files to sniff -->
<file>inc</file>
<file>statify-blacklist.php</file>
<!-- Compliance with WordPress Coding Standard -->
<config name="minimum_supported_wp_version" value="4.4"/>
<rule ref="WordPress">
<!-- The plugin uses switch_to_blog for multisite handling. -->
<exclude name="WordPress.VIP.RestrictedFunctions.switch_to_blog"/>
<exclude name="WordPress.VIP.RestrictedFunctions.switch_to_blog_switch_to_blog"/>
@ -14,4 +20,8 @@
<exclude name="WordPress.VIP.DirectDatabaseQuery.DirectQuery"/>
<exclude name="WordPress.VIP.DirectDatabaseQuery.NoCaching"/>
</rule>
<!-- PHP compatibility level -->
<config name="testVersion" value="5.5-"/>
<rule ref="PHPCompatibility"/>
</ruleset>