Add PHP 7.2 to Travis, ensure phpcs passes stricter standard

This commit is contained in:
Robbie Averill 2017-12-13 21:00:56 +13:00
parent bf5076f2df
commit b1f5ef184b
7 changed files with 113 additions and 38 deletions

3
.gitattributes vendored
View File

@ -1,6 +1,7 @@
/tests export-ignore /tests export-ignore
/docs export-ignore
/.gitattributes export-ignore /.gitattributes export-ignore
/.gitignore export-ignore /.gitignore export-ignore
/.travis.yml export-ignore /.travis.yml export-ignore
/.scrutinizer.yml export-ignore /.scrutinizer.yml export-ignore
/codecov.yml export-ignore
/phpunit.xml.dist export-ignore

View File

@ -12,6 +12,8 @@ matrix:
env: DB=PGSQL PHPUNIT_TEST=1 env: DB=PGSQL PHPUNIT_TEST=1
- php: 7.1 - php: 7.1
env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1 env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1
- php: 7.2
env: DB=MYSQL PHPUNIT_TEST=1
before_script: before_script:
- phpenv rehash - phpenv rehash
@ -25,7 +27,7 @@ before_script:
script: script:
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi - if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi - if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs --standard=vendor/silverstripe/framework/phpcs.xml.dist src/ tests/ ; fi - if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src/ tests/ *.php; fi
after_success: after_success:
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi - if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi

View File

@ -1,23 +1,70 @@
<?php <?php
//
// use SilverStripe\EnvironmentCheck\EnvironmentCheckSuite; //use SilverStripe\EnvironmentCheck\EnvironmentCheckSuite;
//
// // These power dev/health, which can be used by load balancers and other such systems //// These power dev/health, which can be used by load balancers and other such systems
// EnvironmentCheckSuite::register('health', 'DatabaseCheck'); //EnvironmentCheckSuite::register('health', 'DatabaseCheck');
//
// // These power dev/check, which is used for diagnostics and for deployment //// These power dev/check, which is used for diagnostics and for deployment
// EnvironmentCheckSuite::register('check', 'DatabaseCheck("Member")', "Is the database accessible?"); //EnvironmentCheckSuite::register('check', 'DatabaseCheck("Member")', "Is the database accessible?");
// EnvironmentCheckSuite::register('check', 'URLCheck("")', "Is the homepage accessible?"); //EnvironmentCheckSuite::register('check', 'URLCheck("")', "Is the homepage accessible?");
//
// EnvironmentCheckSuite::register('check', 'HasFunctionCheck("curl_init")', "Does PHP have CURL support?"); //EnvironmentCheckSuite::register(
// EnvironmentCheckSuite::register('check', 'HasFunctionCheck("imagecreatetruecolor")', "Does PHP have GD2 support?"); // 'check',
// EnvironmentCheckSuite::register('check', 'HasFunctionCheck("xml_set_object")', "Does PHP have XML support?"); // 'HasFunctionCheck("curl_init")',
// EnvironmentCheckSuite::register('check', 'HasFunctionCheck("token_get_all")', "Does PHP have tokenizer support?"); // "Does PHP have CURL support?"
// EnvironmentCheckSuite::register('check', 'HasFunctionCheck("iconv")', "Does PHP have iconv support?"); //);
// EnvironmentCheckSuite::register('check', 'HasFunctionCheck("hash")', "Does PHP have hash support?"); //
// EnvironmentCheckSuite::register('check', 'HasFunctionCheck("session_start")', "Does PHP have session support?"); //EnvironmentCheckSuite::register(
// EnvironmentCheckSuite::register('check', 'HasClassCheck("DOMDocument")', "Does PHP have DOMDocument support?"); // 'check',
// 'HasFunctionCheck("imagecreatetruecolor")',
// EnvironmentCheckSuite::register('check', 'FileWriteableCheck("assets")', "Is assets/ writeable?"); // "Does PHP have GD2 support?"
// EnvironmentCheckSuite::register('check', 'FileWriteableCheck("' . TEMP_FOLDER . '")', "Is the temp folder writeable?"); //);
//
//EnvironmentCheckSuite::register(
// 'check',
// 'HasFunctionCheck("xml_set_object")',
// "Does PHP have XML support?"
//);
//
//EnvironmentCheckSuite::register(
// 'check',
// 'HasFunctionCheck("token_get_all")',
// "Does PHP have tokenizer support?"
//);
//
//EnvironmentCheckSuite::register(
// 'check',
// 'HasFunctionCheck("iconv")',
// "Does PHP have iconv support?"
//);
//
//EnvironmentCheckSuite::register(
// 'check',
// 'HasFunctionCheck("hash")',
// "Does PHP have hash support?"
//);
//
//EnvironmentCheckSuite::register(
// 'check',
// 'HasFunctionCheck("session_start")',
// "Does PHP have session support?"
//);
//
//EnvironmentCheckSuite::register(
// 'check',
// 'HasClassCheck("DOMDocument")',
// "Does PHP have DOMDocument support?"
//);
//
//EnvironmentCheckSuite::register(
// 'check',
// 'FileWriteableCheck("assets")',
// "Is assets/ writeable?"
//);
//
//EnvironmentCheckSuite::register(
// 'check',
// 'FileWriteableCheck("' . TEMP_FOLDER . '")',
// "Is the temp folder writeable?"
//);

View File

@ -15,10 +15,10 @@
} }
], ],
"require": { "require": {
"silverstripe/framework": "^4.0" "silverstripe/framework": "^4.0",
"silverstripe/versioned": "^1.0"
}, },
"require-dev": { "require-dev": {
"silverstripe/versioned": "^1.0",
"phpunit/phpunit": "^5.7", "phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "^3.0" "squizlabs/php_codesniffer": "^3.0"
}, },

9
phpcs.xml.dist Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="SilverStripe">
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>
<rule ref="PSR2" >
<!-- Current exclusions -->
<exclude name="PSR1.Methods.CamelCapsMethodName" />
</rule>
</ruleset>

View File

@ -10,9 +10,13 @@ use SilverStripe\EnvironmentCheck\EnvironmentCheck;
* it can still fail if the URL in question is requested by the client, e.g. through an iframe. * it can still fail if the URL in question is requested by the client, e.g. through an iframe.
* *
* Requires curl to present, so ensure to check it before with the following: * Requires curl to present, so ensure to check it before with the following:
* <code>EnvironmentCheckSuite::register('check', 'HasFunctionCheck("curl_init")', "Does PHP have CURL support?");</code> * <code>
* * EnvironmentCheckSuite::register(
* @package environmentcheck * 'check',
* 'HasFunctionCheck("curl_init")',
* "Does PHP have CURL support?"
* );
* </code>
*/ */
class ExternalURLCheck implements EnvironmentCheck class ExternalURLCheck implements EnvironmentCheck
{ {

View File

@ -3,28 +3,40 @@
namespace SilverStripe\EnvironmentCheck\Checks; namespace SilverStripe\EnvironmentCheck\Checks;
use SilverStripe\EnvironmentCheck\EnvironmentCheck; use SilverStripe\EnvironmentCheck\EnvironmentCheck;
use SilverStripe\ORM\Versioning\Versioned; use SilverStripe\Versioned\Versioned;
/** /**
* Checks for the accessibility and file type validation of one or more files or folders. * Checks for the accessibility and file type validation of one or more files or folders.
* *
* Examples: * Examples:
* // Checks /assets/calculator_files has .json files and all files are valid json files. * // Checks /assets/calculator_files has .json files and all files are valid json files.
* EnvironmentCheckSuite::register('check', 'FileAccessibilityAndValidationCheck("' . BASE_PATH . '/assets/calculator_files/*.json", * EnvironmentCheckSuite::register(
* "jsonValidate", '.FileAccessibilityAndValidationCheck::CHECK_ALL.')', 'Check a json file exist and are all valid json files' * 'check',
* 'FileAccessibilityAndValidationCheck(
* "' . BASE_PATH . '/assets/calculator_files/*.json",
* "jsonValidate",
* '.FileAccessibilityAndValidationCheck::CHECK_ALL.'
* )',
* 'Check a json file exist and are all valid json files'
* ); * );
* *
* // Checks /assets/calculator_files/calculator.json exists and is valid json file. * // Checks /assets/calculator_files/calculator.json exists and is valid json file.
* EnvironmentCheckSuite::register('check', 'FileAccessibilityAndValidationCheck("' . BASE_PATH . '/assets/calculator_files/calculator.json", * EnvironmentCheckSuite::register(
* "jsonValidate", '.FileAccessibilityAndValidationCheck::CHECK_SINGLE.')', 'Check a calculator.json exists and is valid json file' * 'check',
* 'FileAccessibilityAndValidationCheck(
* "' . BASE_PATH . '/assets/calculator_files/calculator.json",
* "jsonValidate",
* '.FileAccessibilityAndValidationCheck::CHECK_SINGLE.'
* )',
* 'Check a calculator.json exists and is valid json file'
* ); * );
* *
* // Check only existence * // Check only existence
* EnvironmentCheckSuite::register('check', 'FileAccessibilityAndValidationCheck("' . BASE_PATH . '/assets/calculator_files/calculator.json")', * EnvironmentCheckSuite::register(
* 'check',
* 'FileAccessibilityAndValidationCheck("' . BASE_PATH . '/assets/calculator_files/calculator.json")',
* 'Check a calculator.json exists only' * 'Check a calculator.json exists only'
* ); * );
*
* @package environmentcheck
*/ */
class FileAccessibilityAndValidationCheck implements EnvironmentCheck class FileAccessibilityAndValidationCheck implements EnvironmentCheck
{ {