Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Commit c6c3bd5

Browse files
committed
Initial commit
0 parents  commit c6c3bd5

12 files changed

Lines changed: 271 additions & 0 deletions

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.php_cs
2+
/.php_cs.cache
3+
/composer.lock
4+
/phpunit.xml
5+
/vendor/

.php_cs.dist

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
$header = <<<'EOF'
4+
This file is part of PHPUnit Good Practices.
5+
6+
(c) Dariusz Rumiński <dariusz.ruminski@gmail.com>
7+
8+
This source file is subject to the MIT license that is bundled
9+
with this source code in the file LICENSE.
10+
EOF;
11+
12+
return PhpCsFixer\Config::create()
13+
->setRiskyAllowed(true)
14+
->setRules(array(
15+
'@Symfony' => true,
16+
'@Symfony:risky' => true,
17+
'array_syntax' => array('syntax' => 'long'),
18+
'combine_consecutive_unsets' => true,
19+
'header_comment' => array('header' => $header),
20+
'heredoc_to_nowdoc' => true,
21+
'no_extra_consecutive_blank_lines' => array('break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'),
22+
'no_short_echo_tag' => true,
23+
'no_unreachable_default_argument_value' => true,
24+
'no_useless_else' => true,
25+
'no_useless_return' => true,
26+
'ordered_class_elements' => true,
27+
'ordered_imports' => true,
28+
'phpdoc_add_missing_param_annotation' => true,
29+
'phpdoc_order' => true,
30+
'semicolon_after_instruction' => true,
31+
'strict_comparison' => true,
32+
'strict_param' => true,
33+
))
34+
->setFinder(
35+
PhpCsFixer\Finder::create()
36+
->in(__DIR__)
37+
)
38+
;

.travis.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
sudo: false
2+
3+
git:
4+
depth: 1
5+
6+
cache:
7+
directories:
8+
- $HOME/.composer
9+
10+
language: php
11+
12+
php:
13+
- 5.5
14+
- 5.6
15+
- 7.0
16+
- 7.1
17+
- nightly
18+
19+
env:
20+
global:
21+
- DEFAULT_COMPOSER_FLAGS="--no-interaction --no-progress"
22+
23+
before_install:
24+
# turn off XDebug
25+
- phpenv config-rm xdebug.ini || return 0
26+
27+
# Composer: boost installation
28+
- composer global show -ND 2>&1 | grep "hirak/prestissimo" || travis_retry composer global require $DEFAULT_COMPOSER_FLAGS hirak/prestissimo
29+
30+
install: skip
31+
32+
script:
33+
- ./run-tests.sh 4.8.35 || travis_terminate 1
34+
- ./run-tests.sh ~5.4.0 || travis_terminate 1
35+
- ./run-tests.sh ~5.5.0 || travis_terminate 1
36+
- ./run-tests.sh ~5.6.0 || travis_terminate 1
37+
- ./run-tests.sh ~5.7.0 || travis_terminate 1
38+
39+
jobs:
40+
include:
41+
-
42+
stage: Static Code Analysis
43+
php: 7.1
44+
install:
45+
- travis_retry composer update -d dev-tools $DEFAULT_COMPOSER_FLAGS
46+
- composer info -d dev-tools -D | sort
47+
script:
48+
- ./check_trailing_spaces.sh || travis_terminate 1
49+
- ./dev-tools/vendor/bin/phpmd src,tests text phpmd.xml || travis_terminate 1
50+
- ./dev-tools/vendor/bin/php-cs-fixer fix --diff --dry-run -v || travis_terminate 1

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2012-2017 Dariusz Rumiński
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
PHPUnit Good Practices
2+
======================
3+
4+
Highly opinionated PHPUnit good practices enforcer.

check_trailing_spaces.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
# Copied from https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v2.3.0/check_trailing_spaces.sh .
4+
5+
files_with_trailing_spaces=$(find . -type f -not -path "./.git/*" -not -path "./dev-tools/vendor/*" -not -path "./vendor/*" -exec egrep -nH " $" {} \;)
6+
7+
if [[ $files_with_trailing_spaces ]]
8+
then
9+
echo -e "\e[97;41mTrailing spaces detected:\e[0m"
10+
e=$(printf '\033')
11+
echo "${files_with_trailing_spaces}" | sed -E "s/^\.\/([^:]+):([0-9]+):(.*[^ ])( +)$/${e}[0;31m - in ${e}[0;33m\1${e}[0;31m at line ${e}[0;33m\2\n ${e}[0;31m>${e}[0m \3${e}[41m\4${e}[0m/"
12+
13+
exit 1
14+
fi
15+
16+
echo -e "\e[0;32mNo trailing spaces detected.\e[0m"

composer.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "phpunitgoodpractices/phpunit-good-practices",
3+
"type": "library",
4+
"description": "Highly opinionated PHPUnit good practices enforcer.",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Dariusz Rumiński",
9+
"email": "dariusz.ruminski@gmail.com"
10+
}
11+
],
12+
"require": {
13+
"php": "^5.3.6 || ^7.0"
14+
},
15+
"require-dev": {
16+
"phpunit/phpunit": "^4.8.35 || ^5.4.3"
17+
},
18+
"conflict": {
19+
"hhvm": "*"
20+
},
21+
"config": {
22+
"optimize-autoloader": true,
23+
"sort-packages": true
24+
},
25+
"autoload": {
26+
"psr-4": { "PHPUnitGoodPractices\\": "src/" }
27+
},
28+
"autoload-dev": {
29+
"psr-4": { "PHPUnitGoodPractices\\Tests\\": "tests/" }
30+
}
31+
}

dev-tools/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/composer.lock
2+
/vendor/

dev-tools/composer.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"require": {
3+
"php": "^7.0"
4+
},
5+
"require-dev": {
6+
"mi-schi/phpmd-extension": "^4.2",
7+
"friendsofphp/php-cs-fixer": "^2.3",
8+
"phpmd/phpmd": "^2.4.3"
9+
},
10+
"conflict": {
11+
"hhvm": "*"
12+
},
13+
"config": {
14+
"optimize-autoloader": true,
15+
"sort-packages": true
16+
}
17+
}

phpmd.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="friendsofphp/php-cs-fixer"
3+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
6+
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
7+
>
8+
<rule ref="rulesets/controversial.xml/CamelCaseClassName" />
9+
<rule ref="rulesets/controversial.xml/CamelCaseMethodName" />
10+
<rule ref="rulesets/controversial.xml/CamelCaseParameterName" />
11+
<rule ref="rulesets/controversial.xml/CamelCasePropertyName" />
12+
<rule ref="rulesets/controversial.xml/CamelCaseVariableName" />
13+
14+
<rule ref="rulesets/design.xml/DevelopmentCodeFragment" />
15+
<rule ref="rulesets/design.xml/EvalExpression" />
16+
<rule ref="rulesets/design.xml/ExitExpression" />
17+
<rule ref="rulesets/design.xml/GotoStatement" />
18+
19+
<rule ref="rulesets/naming.xml/ConstantNamingConventions" />
20+
21+
<rule ref="../../../../../mi-schi/phpmd-extension/rulesets/cleancode.xml/DataStructureMethods" />
22+
<rule ref="../../../../../mi-schi/phpmd-extension/rulesets/cleancode.xml/SwitchStatement" />
23+
24+
<rule ref="../../../../../mi-schi/phpmd-extension/rulesets/naming.xml/CommentDescription">
25+
<properties>
26+
<property name="percent" value="70" />
27+
</properties>
28+
</rule>
29+
</ruleset>

0 commit comments

Comments
 (0)