-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathphpunit-code-quality.php
More file actions
130 lines (116 loc) · 7.2 KB
/
phpunit-code-quality.php
File metadata and controls
130 lines (116 loc) · 7.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddParamTypeFromDependsRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddReturnTypeToDependedRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\ConstructClassMethodToSetUpTestCaseRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\NarrowUnusedSetUpDefinedPropertyRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\SingleMockPropertyTypeRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\TestWithToDataProviderRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\TypeWillReturnCallableArrowFunctionRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector;
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector;
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\DataProviderArrayItemsNewLinedRector;
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\EntityDocumentCreateMockToDirectNewRector;
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\RemoveEmptyTestMethodRector;
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\ReplaceTestAnnotationWithPrefixedFunctionRector;
use Rector\PHPUnit\CodeQuality\Rector\Expression\AssertArrayCastedObjectToAssertSameRector;
use Rector\PHPUnit\CodeQuality\Rector\Foreach_\SimplifyForeachInstanceOfRector;
use Rector\PHPUnit\CodeQuality\Rector\FuncCall\AssertFuncCallToPHPUnitAssertRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertCompareOnCountableWithMethodToAssertCountRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertComparisonToSpecificMethodRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertEmptyNullableObjectToAssertInstanceofRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertEqualsOrAssertSameFloatParameterToSpecificMethodsTypeRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertFalseStrposToContainsRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertInstanceOfComparisonRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertIssetToSpecificMethodRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertNotOperatorRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertRegExpRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertSameBoolNullToSpecificMethodRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertSameTrueFalseToAssertTrueFalseRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertTrueFalseToSpecificMethodRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\FlipAssertRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\MatchAssertSameExpectedTypeRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\MergeWithCallableAndWillReturnRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\NarrowIdenticalWithConsecutiveRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\NarrowSingleWillReturnCallbackRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\RemoveExpectAnyFromMockRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\ScalarArgumentToExpectedParamTypeRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\SimplerWithIsInstanceOfRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\SingleWithConsecutiveToWithRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\StringCastAssertStringContainsStringRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\UseSpecificWillMethodRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\UseSpecificWithMethodRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\WithCallbackIdenticalToStandaloneAssertsRector;
use Rector\PHPUnit\CodeQuality\Rector\StmtsAwareInterface\DeclareStrictTypesTestsRector;
use Rector\PHPUnit\PHPUnit60\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector;
use Rector\PHPUnit\PHPUnit90\Rector\MethodCall\ReplaceAtMethodWithDesiredMatcherRector;
use Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rules([
ConstructClassMethodToSetUpTestCaseRector::class,
AssertSameTrueFalseToAssertTrueFalseRector::class,
MatchAssertSameExpectedTypeRector::class,
AssertEqualsToSameRector::class,
PreferPHPUnitThisCallRector::class,
YieldDataProviderRector::class,
RemoveEmptyTestMethodRector::class,
ReplaceTestAnnotationWithPrefixedFunctionRector::class,
TestWithToDataProviderRector::class,
AssertEqualsOrAssertSameFloatParameterToSpecificMethodsTypeRector::class,
DataProviderArrayItemsNewLinedRector::class,
FlipAssertRector::class,
// narrow with consecutive
NarrowIdenticalWithConsecutiveRector::class,
NarrowSingleWillReturnCallbackRector::class,
SingleWithConsecutiveToWithRector::class,
// type declarations
TypeWillReturnCallableArrowFunctionRector::class,
StringCastAssertStringContainsStringRector::class,
AddParamTypeFromDependsRector::class,
AddReturnTypeToDependedRector::class,
ScalarArgumentToExpectedParamTypeRector::class,
NarrowUnusedSetUpDefinedPropertyRector::class,
// specific asserts
AssertCompareOnCountableWithMethodToAssertCountRector::class,
AssertComparisonToSpecificMethodRector::class,
AssertNotOperatorRector::class,
AssertTrueFalseToSpecificMethodRector::class,
AssertSameBoolNullToSpecificMethodRector::class,
AssertFalseStrposToContainsRector::class,
AssertIssetToSpecificMethodRector::class,
AssertInstanceOfComparisonRector::class,
AssertRegExpRector::class,
AssertFuncCallToPHPUnitAssertRector::class,
SimplifyForeachInstanceOfRector::class,
UseSpecificWillMethodRector::class,
UseSpecificWithMethodRector::class,
AssertEmptyNullableObjectToAssertInstanceofRector::class,
// avoid call on nullable object
AddInstanceofAssertForNullableInstanceRector::class,
AssertArrayCastedObjectToAssertSameRector::class,
/**
* Improve direct testing of your code, without mock creep. Make it simple, clear and easy to maintain:
*
* @see https://blog.frankdejonge.nl/testing-without-mocking-frameworks/
* @see https://maksimivanov.com/posts/dont-mock-what-you-dont-own/
* @see https://dev.to/mguinea/stop-using-mocking-libraries-2f2k
* @see https://mnapoli.fr/anonymous-classes-in-tests/
* @see https://steemit.com/php/@crell/don-t-use-mocking-libraries
* @see https://davegebler.com/post/php/better-php-unit-testing-avoiding-mocks
*/
RemoveExpectAnyFromMockRector::class,
SingleMockPropertyTypeRector::class,
SimplerWithIsInstanceOfRector::class,
FinalizeTestCaseClassRector::class,
DeclareStrictTypesTestsRector::class,
WithCallbackIdenticalToStandaloneAssertsRector::class,
MergeWithCallableAndWillReturnRector::class,
// prefer simple mocking
GetMockBuilderGetMockToCreateMockRector::class,
EntityDocumentCreateMockToDirectNewRector::class,
ReplaceAtMethodWithDesiredMatcherRector::class,
]);
};