From a60f59259831e9a25c9165573dc879e453009774 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Mon, 28 Aug 2017 10:27:53 +1200 Subject: [PATCH] Update Travis configuration to be standalone, add codecov.io, update license year --- .travis.yml | 40 +++++++++++++++++++--------------------- README.md | 37 ++++++++++++++++++------------------- codecov.yml | 1 + license.md | 2 +- phpunit.xml.dist | 14 ++++++++++++++ 5 files changed, 53 insertions(+), 41 deletions(-) create mode 100644 codecov.yml create mode 100644 phpunit.xml.dist diff --git a/.travis.yml b/.travis.yml index 198f057..c73141d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,33 +1,31 @@ -# See https://github.com/silverstripe/silverstripe-travis-support for setup details - -sudo: false - language: php -php: - - 5.3 - - 5.4 - - 5.5 - env: - - DB=MYSQL CORE_RELEASE=3.5 + global: + - COMPOSER_ROOT_VERSION="4.0.x-dev" matrix: include: - php: 5.6 - env: DB=MYSQL CORE_RELEASE=3 - - php: 5.6 - env: DB=MYSQL CORE_RELEASE=3.1 - - php: 5.6 - env: DB=PGSQL CORE_RELEASE=3.2 + env: DB=MYSQL PHPCS_TEST=1 PHPUNIT_TEST=1 + - php: 7.0 + env: DB=PGSQL PHPUNIT_TEST=1 - php: 7.1 - env: DB=MYSQL CORE_RELEASE=3.6 + env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1 before_script: - - composer self-update || true - - git clone git://github.com/silverstripe/silverstripe-travis-support.git ~/travis-support - - php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require silverstripe/userforms - - cd ~/builds/ss + - phpenv rehash + - phpenv config-rm xdebug.ini + + - composer install --prefer-dist + - composer require --prefer-dist --no-update silverstripe/framework:4.0.x-dev + - if [[ $DB == PGSQL ]]; then composer require --prefer-dist --no-update silverstripe/postgresql:2.0.x-dev; fi + - composer update script: - - vendor/bin/phpunit spamprotection/tests + - if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests/; fi + - if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi + - if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs --standard=framework/phpcs.xml.dist src/ tests/ ; fi + +after_success: + - if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi diff --git a/README.md b/README.md index 15baff2..1f418cd 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ # SpamProtection Module [![Build Status](https://secure.travis-ci.org/silverstripe/silverstripe-spamprotection.png?branch=master)](http://travis-ci.org/silverstripe/silverstripe-spamprotection) -![helpfulrobot](https://helpfulrobot.io/silverstripe/spamprotection/badge) - +[![Code Coverage](https://codecov.io/gh/silverstripe/silverstripe-spamprotection/branch/master/graph/badge.svg)](https://codecov.io/gh/silverstripe/silverstripe-spamprotection) ## Maintainer Contact @@ -18,9 +17,9 @@ SilverStripe 3.0.0 or greater ## Documentation -This module provides a generic, consistent API for adding spam protection to -your SilverStripe Forms. This does not provide any spam protection out of the -box, for that, you must also download one of the spam protection +This module provides a generic, consistent API for adding spam protection to +your SilverStripe Forms. This does not provide any spam protection out of the +box, for that, you must also download one of the spam protection implementations. Currently available options are: * [Mollom](https://github.com/silverstripe/silverstripe-mollom) @@ -33,8 +32,8 @@ implements the `SpamProtector` interface. More on that below. ## Configuring -After installing this module and a protector of your choice (i.e mollom) you'll -need to rebuild your database through `dev/build` and set the default protector +After installing this module and a protector of your choice (i.e mollom) you'll +need to rebuild your database through `dev/build` and set the default protector via SilverStripe's config system. This will update any Form instances that have spam protection hooks with that protector. @@ -47,18 +46,18 @@ spam protection hooks with that protector. default_spam_protector: MollomSpamProtector To add spam protection to your form instance call `enableSpamProtection`. - + // your existing form code $form = new Form( .. ); $form->enableSpamProtection(); -The logic to perform the actual spam validation is controlled by each of the -individual `SpamProtector` implementation since they each require a different +The logic to perform the actual spam validation is controlled by each of the +individual `SpamProtector` implementation since they each require a different implementation client side or server side. ### Options -`enableSpamProtection` takes a hash of optional configuration values. +`enableSpamProtection` takes a hash of optional configuration values. $form->enableSpamProtection(array( 'protector' => 'MathSpamProtector', @@ -67,14 +66,14 @@ implementation client side or server side. Options to configure are: -*`protector`* a class name string or class instance which implements -`SpamProtector`. Defaults to your +*`protector`* a class name string or class instance which implements +`SpamProtector`. Defaults to your `FormSpamProtectionExtension.default_spam_protector` value. *`name`* the form field name argument for the Captcha. Defaults to `Catcha`. *`title`* title of the Captcha form field. Defaults to `''` *`insertBefore`* name of existing field to insert the spam protection field prior to -*`mapping`* an array mapping of the Form fields to the standardized list of +*`mapping`* an array mapping of the Form fields to the standardized list of field names. The list of standardized fields to pass to the spam protector are: title @@ -90,7 +89,7 @@ field names. The list of standardized fields to pass to the spam protector are: ## Defining your own `SpamProtector` Any class that implements `SpamProtector` and the `getFormField()` method can -be set as the spam protector. The `getFormField()` method returns the +be set as the spam protector. The `getFormField()` method returns the `FormField` to be inserted into the `Form`. The `FormField` returned should be in charge of the validation process. @@ -110,14 +109,14 @@ in charge of the validation process. This module provides an EditableSpamProtectionField wrapper which you can add to your UserForm instances. After installing this module and running /dev/build -to rebuild the database, your Form Builder interface will have an option for -`Spam Protection Field`. The type of spam protection used will be based on your +to rebuild the database, your Form Builder interface will have an option for +`Spam Protection Field`. The type of spam protection used will be based on your currently selected SpamProtector instance. ## Releasing code with Spam Protection support -Spam protection is useful to provide but in some cases we do not want to require -the developer to use spam protection. In that case, modules can provide the +Spam protection is useful to provide but in some cases we do not want to require +the developer to use spam protection. In that case, modules can provide the following pattern $form = new Form(..); diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..69cb760 --- /dev/null +++ b/codecov.yml @@ -0,0 +1 @@ +comment: false diff --git a/license.md b/license.md index 9445c8e..8794670 100644 --- a/license.md +++ b/license.md @@ -1,4 +1,4 @@ -Copyright (c) 2016, SilverStripe Limited +Copyright (c) 2017, SilverStripe Limited All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..d6d5263 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,14 @@ + + + tests + + + + + src/. + + tests/ + + + +