Skip to content

Commit

Permalink
Tests: make dataproviders static
Browse files Browse the repository at this point in the history
As of PHPUnit 10, data providers are (again) expected to be `static` methods.
While the test suite does not (yet) support PHPUnit 10, it's still not a bad idea to already start complying with this.
  • Loading branch information
jrfnl committed Jan 11, 2024
1 parent ed6cff1 commit 72a2ee0
Show file tree
Hide file tree
Showing 37 changed files with 82 additions and 82 deletions.
2 changes: 1 addition & 1 deletion tests/Core/Config/ReportWidthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public function testReportWidthInputHandling($input, $expected)
*
* @return array
*/
public function dataReportWidthInputHandling()
public static function dataReportWidthInputHandling()
{
return [
'No value (empty string)' => [
Expand Down
22 changes: 11 additions & 11 deletions tests/Core/ErrorSuppressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testSuppressError($before, $after, $expectedErrors=0)
*
* @return array
*/
public function dataSuppressError()
public static function dataSuppressError()
{
return [
'no suppression' => [
Expand Down Expand Up @@ -204,7 +204,7 @@ public function testSuppressSomeErrors($before, $between, $expectedErrors=1)
*
* @return array
*/
public function dataSuppressSomeErrors()
public static function dataSuppressSomeErrors()
{
return [
'no suppression' => [
Expand Down Expand Up @@ -296,7 +296,7 @@ public function testSuppressWarning($before, $after, $expectedWarnings=0)
*
* @return array
*/
public function dataSuppressWarning()
public static function dataSuppressWarning()
{
return [
'no suppression' => [
Expand Down Expand Up @@ -381,7 +381,7 @@ public function testSuppressLine($before, $after='', $expectedErrors=1)
*
* @return array
*/
public function dataSuppressLine()
public static function dataSuppressLine()
{
return [
'no suppression' => [
Expand Down Expand Up @@ -532,7 +532,7 @@ public function testNestedSuppressLine($before, $after)
*
* @return array
*/
public function dataNestedSuppressLine()
public static function dataNestedSuppressLine()
{
return [
// Process with disable/enable suppression and no single line suppression.
Expand Down Expand Up @@ -627,7 +627,7 @@ function myFunction() {
*
* @return array
*/
public function dataSuppressScope()
public static function dataSuppressScope()
{
return [
'no suppression' => [
Expand Down Expand Up @@ -722,7 +722,7 @@ class MyClass {}
*
* @return array
*/
public function dataSuppressFile()
public static function dataSuppressFile()
{
return [
'no suppression' => [
Expand Down Expand Up @@ -821,7 +821,7 @@ public function testDisableSelected($before, $expectedErrors=0, $expectedWarning
*
* @return array
*/
public function dataDisableSelected()
public static function dataDisableSelected()
{
return [
// Single sniff.
Expand Down Expand Up @@ -928,7 +928,7 @@ public function testEnableSelected($code, $expectedErrors, $expectedWarnings)
*
* @return array
*/
public function dataEnableSelected()
public static function dataEnableSelected()
{
return [
'disable/enable: a single sniff' => [
Expand Down Expand Up @@ -1108,7 +1108,7 @@ public function testIgnoreSelected($before, $expectedErrors, $expectedWarnings)
*
* @return array
*/
public function dataIgnoreSelected()
public static function dataIgnoreSelected()
{
return [
'no suppression' => [
Expand Down Expand Up @@ -1195,7 +1195,7 @@ public function testCommenting($code, $expectedErrors, $expectedWarnings)
*
* @return array
*/
public function dataCommenting()
public static function dataCommenting()
{
return [
'ignore: single sniff' => [
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/File/FindExtendedClassNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testFindExtendedClassName($identifier, $expected)
*
* @return array<string, array<string, string|false>>
*/
public function dataExtendedClass()
public static function dataExtendedClass()
{
return [
'class does not extend' => [
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/File/FindImplementedInterfaceNamesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testFindImplementedInterfaceNames($identifier, $expected)
*
* @return array<string, array<string, string|array<string>>>
*/
public function dataImplementedInterface()
public static function dataImplementedInterface()
{
return [
'interface declaration, no implements' => [
Expand Down
4 changes: 2 additions & 2 deletions tests/Core/File/GetClassPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testNotAClassException($testMarker, $tokenType)
*
* @return array<string, array<string, string|int>>
*/
public function dataNotAClassException()
public static function dataNotAClassException()
{
return [
'interface' => [
Expand Down Expand Up @@ -93,7 +93,7 @@ public function testGetClassProperties($testMarker, $expected)
*
* @return array<string, array<string, string|array<string, bool|int>>>
*/
public function dataGetClassProperties()
public static function dataGetClassProperties()
{
return [
'no-properties' => [
Expand Down
4 changes: 2 additions & 2 deletions tests/Core/File/GetMemberPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testGetMemberProperties($identifier, $expected)
*
* @return array<string, array<string|array<string, string|int|bool>>>
*/
public function dataGetMemberProperties()
public static function dataGetMemberProperties()
{
return [
'var-modifier' => [
Expand Down Expand Up @@ -1106,7 +1106,7 @@ public function testNotClassPropertyException($identifier)
*
* @return array<string, array<string>>
*/
public function dataNotClassProperty()
public static function dataNotClassProperty()
{
return [
'method parameter' => ['/* testMethodParam */'],
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/File/IsReferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function testIsReference($identifier, $expected)
*
* @return array<string, array<string, string|bool>>
*/
public function dataIsReference()
public static function dataIsReference()
{
return [
'issue-1971-list-first-in-file' => [
Expand Down
6 changes: 3 additions & 3 deletions tests/Core/Ruleset/RuleInclusionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function testRegisteredSniffCodes($key, $value)
*
* @return array
*/
public function dataRegisteredSniffCodes()
public static function dataRegisteredSniffCodes()
{
return [
[
Expand Down Expand Up @@ -364,7 +364,7 @@ public function testSettingProperties($sniffClass, $propertyName, $expectedValue
*
* @return array
*/
public function dataSettingProperties()
public static function dataSettingProperties()
{
return [
'Set property for complete standard: PSR2 ClassDeclaration' => [
Expand Down Expand Up @@ -455,7 +455,7 @@ public function testSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFail
*
* @return array
*/
public function dataSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFails()
public static function dataSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFails()
{
return [
'Set property for complete standard: PSR2 ClassDeclaration' => [
Expand Down
4 changes: 2 additions & 2 deletions tests/Core/Ruleset/SetSniffPropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testSniffPropertiesGetSetWhenAllowed($name)
*
* @return array
*/
public function dataSniffPropertiesGetSetWhenAllowed()
public static function dataSniffPropertiesGetSetWhenAllowed()
{
return [
'Property allowed as explicitly declared' => ['SetPropertyAllowedAsDeclared'],
Expand Down Expand Up @@ -315,7 +315,7 @@ public function testDirectCallWithOldArrayFormatSetsProperty($propertyValue)
*
* @return array
*/
public function dataDirectCallWithOldArrayFormatSetsProperty()
public static function dataDirectCallWithOldArrayFormatSetsProperty()
{
return [
'Property value is not an array (boolean)' => [false],
Expand Down
4 changes: 2 additions & 2 deletions tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function testAnonClassNoParenthesesNextOpenClose($testMarker)
*
* @return array
*/
public function dataAnonClassNoParentheses()
public static function dataAnonClassNoParentheses()
{
return [
['/* testNoParentheses */'],
Expand Down Expand Up @@ -131,7 +131,7 @@ public function testAnonClassWithParentheses($testMarker)
*
* @return array
*/
public function dataAnonClassWithParentheses()
public static function dataAnonClassWithParentheses()
{
return [
['/* testWithParentheses */'],
Expand Down
6 changes: 3 additions & 3 deletions tests/Core/Tokenizer/ArrayKeywordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testArrayKeyword($testMarker, $testContent='array')
*
* @return array
*/
public function dataArrayKeyword()
public static function dataArrayKeyword()
{
return [
'empty array' => ['/* testEmptyArray */'],
Expand Down Expand Up @@ -103,7 +103,7 @@ public function testArrayType($testMarker, $testContent='array')
*
* @return array
*/
public function dataArrayType()
public static function dataArrayType()
{
return [
'closure return type' => [
Expand Down Expand Up @@ -154,7 +154,7 @@ public function testNotArrayKeyword($testMarker, $testContent='array')
*
* @return array
*/
public function dataNotArrayKeyword()
public static function dataNotArrayKeyword()
{
return [
'class-constant-name' => [
Expand Down
6 changes: 3 additions & 3 deletions tests/Core/Tokenizer/AttributesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function ($token) use ($attribute, $length) {
*
* @return array
*/
public function dataAttribute()
public static function dataAttribute()
{
return [
[
Expand Down Expand Up @@ -345,7 +345,7 @@ function ($token) use ($attribute, $length) {
*
* @return array
*/
public function dataAttributeOnParameters()
public static function dataAttributeOnParameters()
{
return [
[
Expand Down Expand Up @@ -451,7 +451,7 @@ public function testAttributeContainingTextLookingLikeCloseTag($testMarker, $len
*
* @return array
*/
public function dataAttributeOnTextLookingLikeCloseTag()
public static function dataAttributeOnTextLookingLikeCloseTag()
{
return [
[
Expand Down
4 changes: 2 additions & 2 deletions tests/Core/Tokenizer/BackfillEnumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function testEnums($testMarker, $testContent, $openerOffset, $closerOffse
*
* @return array
*/
public function dataEnums()
public static function dataEnums()
{
return [
[
Expand Down Expand Up @@ -154,7 +154,7 @@ public function testNotEnums($testMarker, $testContent)
*
* @return array
*/
public function dataNotEnums()
public static function dataNotEnums()
{
return [
[
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Tokenizer/BackfillExplicitOctalNotationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testExplicitOctalNotation($marker, $value, $nextToken, $nextCont
*
* @return array
*/
public function dataExplicitOctalNotation()
public static function dataExplicitOctalNotation()
{
return [
[
Expand Down
4 changes: 2 additions & 2 deletions tests/Core/Tokenizer/BackfillFnTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ public function testInMatchValue($testMarker, $openerOffset, $closerOffset, $exp
*
* @return array
*/
public function dataInMatchValue()
public static function dataInMatchValue()
{
return [
'not_last_value' => [
Expand Down Expand Up @@ -671,7 +671,7 @@ public function testNotAnArrowFunction($testMarker, $testContent='fn')
*
* @return array
*/
public function dataNotAnArrowFunction()
public static function dataNotAnArrowFunction()
{
return [
['/* testFunctionName */'],
Expand Down
8 changes: 4 additions & 4 deletions tests/Core/Tokenizer/BackfillMatchTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testMatchExpression($testMarker, $openerOffset, $closerOffset, $
*
* @return array
*/
public function dataMatchExpression()
public static function dataMatchExpression()
{
return [
'simple_match' => [
Expand Down Expand Up @@ -243,7 +243,7 @@ public function testNotAMatchStructure($testMarker, $testContent='match')
*
* @return array
*/
public function dataNotAMatchStructure()
public static function dataNotAMatchStructure()
{
return [
'static_method_call' => ['/* testNoMatchStaticMethodCall */'],
Expand Down Expand Up @@ -346,7 +346,7 @@ public function testSwitchExpression($testMarker, $openerOffset, $closerOffset)
*
* @return array
*/
public function dataSwitchExpression()
public static function dataSwitchExpression()
{
return [
'switch_containing_match' => [
Expand Down Expand Up @@ -399,7 +399,7 @@ public function testSwitchCaseVersusMatch($testMarker, $openerOffset, $closerOff
*
* @return array
*/
public function dataSwitchCaseVersusMatch()
public static function dataSwitchCaseVersusMatch()
{
return [
'switch_with_nested_match_case_1' => [
Expand Down
4 changes: 2 additions & 2 deletions tests/Core/Tokenizer/BackfillNumericSeparatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testBackfill($testData)
*
* @return array
*/
public function dataTestBackfill()
public static function dataTestBackfill()
{
$testHexType = 'T_LNUMBER';
if (PHP_INT_MAX < 0xCAFEF00D) {
Expand Down Expand Up @@ -191,7 +191,7 @@ public function testNoBackfill($testMarker, $expectedTokens)
*
* @return array
*/
public function dataNoBackfill()
public static function dataNoBackfill()
{
return [
[
Expand Down
Loading

0 comments on commit 72a2ee0

Please sign in to comment.