From be1465d3fc105461c5481f1f91b56549800714f3 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 26 May 2022 05:16:27 +0200 Subject: [PATCH] Tests: use strict assertions `assertEquals()` comes down to a loose type `==` comparison, while `assertSame()` does a strict type `===` comparison, so if at all possible, one should always use `assertSame()` instead of `assertEquals()`. --- .../ArrayAssignmentShortcutTest.php | 10 +- .../ArrowFunctionTest.php | 4 +- .../ClosingPhpTagsTest.php | 10 +- .../VariableAnalysisSniff/GlobalScopeTest.php | 6 +- .../VariableAnalysisSniff/IfConditionTest.php | 8 +- Tests/VariableAnalysisSniff/IssetTest.php | 2 +- Tests/VariableAnalysisSniff/UnsetTest.php | 6 +- .../UnusedFollowedByRequireTest.php | 6 +- .../VariableAnalysisTest.php | 162 +++++++++--------- .../VariableArgumentListTest.php | 4 +- Tests/VariableAnalysisSniff/WhileLoopTest.php | 2 +- 11 files changed, 110 insertions(+), 110 deletions(-) diff --git a/Tests/VariableAnalysisSniff/ArrayAssignmentShortcutTest.php b/Tests/VariableAnalysisSniff/ArrayAssignmentShortcutTest.php index 3d28fe50..d42b601e 100644 --- a/Tests/VariableAnalysisSniff/ArrayAssignmentShortcutTest.php +++ b/Tests/VariableAnalysisSniff/ArrayAssignmentShortcutTest.php @@ -16,7 +16,7 @@ public function testArrayAssignmentReportsCorrectLines() { 28, 29, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testArrayAssignmentHasCorrectSniffCodes() { @@ -25,9 +25,9 @@ public function testArrayAssignmentHasCorrectSniffCodes() { $phpcsFile->process(); $warnings = $phpcsFile->getWarnings(); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[21][5][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[27][5][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[28][5][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[29][10][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[21][5][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[27][5][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[28][5][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[29][10][0]['source']); } } diff --git a/Tests/VariableAnalysisSniff/ArrowFunctionTest.php b/Tests/VariableAnalysisSniff/ArrowFunctionTest.php index 78115375..9bc57656 100644 --- a/Tests/VariableAnalysisSniff/ArrowFunctionTest.php +++ b/Tests/VariableAnalysisSniff/ArrowFunctionTest.php @@ -27,7 +27,7 @@ public function testArrowFunctions() { 67, 71, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testArrowFunctionsWithoutUnusedBeforeUsed() { @@ -55,6 +55,6 @@ public function testArrowFunctionsWithoutUnusedBeforeUsed() { 67, 71, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } } diff --git a/Tests/VariableAnalysisSniff/ClosingPhpTagsTest.php b/Tests/VariableAnalysisSniff/ClosingPhpTagsTest.php index e7856fbd..f276217d 100644 --- a/Tests/VariableAnalysisSniff/ClosingPhpTagsTest.php +++ b/Tests/VariableAnalysisSniff/ClosingPhpTagsTest.php @@ -15,7 +15,7 @@ public function testVariableWarningsWhenClosingTagsAreUsed() { 13, 16, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testVariableWarningsHaveCorrectSniffCodesWhenClosingTagsAreUsed() { @@ -23,9 +23,9 @@ public function testVariableWarningsHaveCorrectSniffCodesWhenClosingTagsAreUsed( $phpcsFile = $this->prepareLocalFileForSniffs($fixtureFile); $phpcsFile->process(); $warnings = $phpcsFile->getWarnings(); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[6][1][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[8][6][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[13][1][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[16][6][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[6][1][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[8][6][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[13][1][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[16][6][0]['source']); } } diff --git a/Tests/VariableAnalysisSniff/GlobalScopeTest.php b/Tests/VariableAnalysisSniff/GlobalScopeTest.php index 44240e16..20bb9c2f 100644 --- a/Tests/VariableAnalysisSniff/GlobalScopeTest.php +++ b/Tests/VariableAnalysisSniff/GlobalScopeTest.php @@ -20,7 +20,7 @@ public function testGlobalScopeWarnings() { 10, 13, ]; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testGlobalScopeWarningsWithAllowUndefinedVariablesInFileScope() { @@ -38,7 +38,7 @@ public function testGlobalScopeWarningsWithAllowUndefinedVariablesInFileScope() 10, 13, ]; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testGlobalScopeWarningsWithAllowUnusedVariablesInFileScope() { @@ -55,6 +55,6 @@ public function testGlobalScopeWarningsWithAllowUnusedVariablesInFileScope() { 7, 10, ]; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } } diff --git a/Tests/VariableAnalysisSniff/IfConditionTest.php b/Tests/VariableAnalysisSniff/IfConditionTest.php index ad6e7c83..d703c8a4 100644 --- a/Tests/VariableAnalysisSniff/IfConditionTest.php +++ b/Tests/VariableAnalysisSniff/IfConditionTest.php @@ -33,7 +33,7 @@ public function testIfConditionWarnings() { 176, 179, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testIfConditionWarningsWithValidUndefinedVariableNames() { @@ -64,7 +64,7 @@ public function testIfConditionWarningsWithValidUndefinedVariableNames() { 176, 179, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testInlineIfConditionWarnings() { @@ -96,7 +96,7 @@ public function testInlineIfConditionWarnings() { 152, 154, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testInlineIfConditionWarningsWithValidUndefinedVariableNames() { @@ -127,6 +127,6 @@ public function testInlineIfConditionWarningsWithValidUndefinedVariableNames() { 152, 154, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } } diff --git a/Tests/VariableAnalysisSniff/IssetTest.php b/Tests/VariableAnalysisSniff/IssetTest.php index 736dcf97..ee8aead3 100644 --- a/Tests/VariableAnalysisSniff/IssetTest.php +++ b/Tests/VariableAnalysisSniff/IssetTest.php @@ -13,6 +13,6 @@ public function testIssetVariableUse() { 4, 23, // ideally this should not be a warning, but will be because it is difficult to know: https://github.com/sirbrillig/phpcs-variable-analysis/issues/202#issuecomment-688507314 ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } } diff --git a/Tests/VariableAnalysisSniff/UnsetTest.php b/Tests/VariableAnalysisSniff/UnsetTest.php index d34d01a2..97b16dcb 100644 --- a/Tests/VariableAnalysisSniff/UnsetTest.php +++ b/Tests/VariableAnalysisSniff/UnsetTest.php @@ -14,7 +14,7 @@ public function testUnsetReportsUndefinedVariables() { 6, 11, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testUnsetHasCorrectSniffCodes() { @@ -23,7 +23,7 @@ public function testUnsetHasCorrectSniffCodes() { $phpcsFile->process(); $warnings = $phpcsFile->getWarnings(); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedUnsetVariable', $warnings[6][7][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedUnsetVariable', $warnings[11][9][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedUnsetVariable', $warnings[6][7][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedUnsetVariable', $warnings[11][9][0]['source']); } } diff --git a/Tests/VariableAnalysisSniff/UnusedFollowedByRequireTest.php b/Tests/VariableAnalysisSniff/UnusedFollowedByRequireTest.php index 701ddcfd..c1948351 100644 --- a/Tests/VariableAnalysisSniff/UnusedFollowedByRequireTest.php +++ b/Tests/VariableAnalysisSniff/UnusedFollowedByRequireTest.php @@ -23,7 +23,7 @@ public function testUnusedFollowedByRequireWarnsByDefault() { 21, 22, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testUnusedFollowedByRequireDoesNotWarnWhenSet() { @@ -42,7 +42,7 @@ public function testUnusedFollowedByRequireDoesNotWarnWhenSet() { 16, 22, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testUnusedFollowedByRequireDoesNotBreakOtherThingsWhenSet() { @@ -69,6 +69,6 @@ public function testUnusedFollowedByRequireDoesNotBreakOtherThingsWhenSet() { 18, 19, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } } diff --git a/Tests/VariableAnalysisSniff/VariableAnalysisTest.php b/Tests/VariableAnalysisSniff/VariableAnalysisTest.php index 2020e86e..322d2e37 100644 --- a/Tests/VariableAnalysisSniff/VariableAnalysisTest.php +++ b/Tests/VariableAnalysisSniff/VariableAnalysisTest.php @@ -10,7 +10,7 @@ public function testFunctionWithoutParamsErrors() { $phpcsFile->process(); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testFunctionWithoutParamsWarnings() { @@ -32,7 +32,7 @@ public function testFunctionWithoutParamsWarnings() { 18, 19, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testFunctionWithUseReferenceWarnings() { @@ -41,7 +41,7 @@ public function testFunctionWithUseReferenceWarnings() { $phpcsFile->process(); $lines = $this->getWarningLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testFunctionWithDefaultParamErrors() { @@ -55,7 +55,7 @@ public function testFunctionWithDefaultParamErrors() { $phpcsFile->process(); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testFunctionWithDefaultParamWarnings() { @@ -72,7 +72,7 @@ public function testFunctionWithDefaultParamWarnings() { 3, 14, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testFunctionWithGlobalVarErrors() { @@ -81,7 +81,7 @@ public function testFunctionWithGlobalVarErrors() { $phpcsFile->process(); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testFunctionWithGlobalVarWarnings() { @@ -99,7 +99,7 @@ public function testFunctionWithGlobalVarWarnings() { 39, 54, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testFunctionWithForeachErrors() { @@ -108,7 +108,7 @@ public function testFunctionWithForeachErrors() { $phpcsFile->process(); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testFunctionWithForeachWarnings() { @@ -136,7 +136,7 @@ public function testFunctionWithForeachWarnings() { 54, 67, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testClassWithMembersErrors() { @@ -145,7 +145,7 @@ public function testClassWithMembersErrors() { $phpcsFile->process(); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testTraitWithMembersWarnings() { @@ -167,7 +167,7 @@ public function testTraitWithMembersWarnings() { 19, 64, ]; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testClassWithMembersWarnings() { @@ -189,7 +189,7 @@ public function testClassWithMembersWarnings() { 19, 66, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testFunctionsOutsideClassErrors() { @@ -198,7 +198,7 @@ public function testFunctionsOutsideClassErrors() { $phpcsFile->process(); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testFunctionsOutsideClassWarnings() { @@ -209,7 +209,7 @@ public function testFunctionsOutsideClassWarnings() { $expectedWarnings = [ 3, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testFunctionWithClosureErrors() { @@ -226,7 +226,7 @@ public function testFunctionWithClosureErrors() { 58, 70, ]; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testFunctionWithClosureWarnings() { @@ -255,7 +255,7 @@ public function testFunctionWithClosureWarnings() { 35, 64, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testFunctionWithReferenceErrors() { @@ -264,7 +264,7 @@ public function testFunctionWithReferenceErrors() { $phpcsFile->process(); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testFunctionWithReferenceWarnings() { @@ -288,7 +288,7 @@ public function testFunctionWithReferenceWarnings() { 64, 81, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testFunctionWithReferenceWarningsAllowsCustomFunctions() { @@ -315,7 +315,7 @@ public function testFunctionWithReferenceWarningsAllowsCustomFunctions() { 64, 81, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testFunctionWithReferenceWarningsAllowsWordPressFunctionsIfSet() { @@ -343,7 +343,7 @@ public function testFunctionWithReferenceWarningsAllowsWordPressFunctionsIfSet() 60, 81, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testFunctionWithTryCatchErrors() { @@ -352,7 +352,7 @@ public function testFunctionWithTryCatchErrors() { $phpcsFile->process(); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testFunctionWithTryCatchWarnings() { @@ -364,7 +364,7 @@ public function testFunctionWithTryCatchWarnings() { 3, 7, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testFunctionWithInlineAssignErrors() { @@ -373,7 +373,7 @@ public function testFunctionWithInlineAssignErrors() { $phpcsFile->process(); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testFunctionWithInlineAssignWarnings() { @@ -385,7 +385,7 @@ public function testFunctionWithInlineAssignWarnings() { 3, 6, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testFunctionWithRedeclarationsErrors() { @@ -394,7 +394,7 @@ public function testFunctionWithRedeclarationsErrors() { $phpcsFile->process(); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testFunctionWithRedeclarationsWarnings() { @@ -417,7 +417,7 @@ public function testFunctionWithRedeclarationsWarnings() { 36, 37, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testHeredocErrors() { @@ -426,7 +426,7 @@ public function testHeredocErrors() { $phpcsFile->process(); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testHeredocWarnings() { @@ -440,7 +440,7 @@ public function testHeredocWarnings() { 10, 12, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testClassReferenceErrors() { @@ -449,7 +449,7 @@ public function testClassReferenceErrors() { $phpcsFile->process(); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testClassReferenceWarnings() { @@ -467,7 +467,7 @@ public function testClassReferenceWarnings() { 24, 25 ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testCompactErrors() { @@ -481,7 +481,7 @@ public function testCompactErrors() { $phpcsFile->process(); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testCompactWarnings() { @@ -504,7 +504,7 @@ public function testCompactWarnings() { 26, 36, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testCompactWarningsHaveCorrectSniffCodes() { @@ -518,15 +518,15 @@ public function testCompactWarningsHaveCorrectSniffCodes() { $phpcsFile->process(); $warnings = $phpcsFile->getWarnings(); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[2][49][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[7][23][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[10][54][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[14][52][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[19][5][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[23][23][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[26][66][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[36][5][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[36][23][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[2][49][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[7][23][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[10][54][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[14][52][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[19][5][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[23][23][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[26][66][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[36][5][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable', $warnings[36][23][0]['source']); } public function testTraitAllowsThis() { @@ -535,10 +535,10 @@ public function testTraitAllowsThis() { $phpcsFile->process(); $lines = $this->getWarningLineNumbersFromFile($phpcsFile); $expectedWarnings = []; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testAnonymousClassAllowsThis() { @@ -547,10 +547,10 @@ public function testAnonymousClassAllowsThis() { $phpcsFile->process(); $lines = $this->getWarningLineNumbersFromFile($phpcsFile); $expectedWarnings = []; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testVariableFunctionCallsCountAsUsage() { @@ -564,10 +564,10 @@ public function testVariableFunctionCallsCountAsUsage() { $phpcsFile->process(); $lines = $this->getWarningLineNumbersFromFile($phpcsFile); $expectedWarnings = [18]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testVariableVariables() { @@ -588,10 +588,10 @@ public function testVariableVariables() { 52, 53, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testTraitsAllowPropertyDefinitions() { @@ -600,10 +600,10 @@ public function testTraitsAllowPropertyDefinitions() { $phpcsFile->process(); $lines = $this->getWarningLineNumbersFromFile($phpcsFile); $expectedWarnings = []; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testAnonymousClassAllowPropertyDefinitions() { @@ -616,10 +616,10 @@ public function testAnonymousClassAllowPropertyDefinitions() { 26, 38, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); $lines = $this->getErrorLineNumbersFromFile($phpcsFile); $expectedErrors = []; - $this->assertEquals($expectedErrors, $lines); + $this->assertSame($expectedErrors, $lines); } public function testUnusedParamsAreReported() { @@ -640,7 +640,7 @@ public function testUnusedParamsAreReported() { 72, 73, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testUnusedParamsHaveCorrectSniffCodes() { @@ -654,13 +654,13 @@ public function testUnusedParamsHaveCorrectSniffCodes() { $phpcsFile->process(); $warnings = $phpcsFile->getWarnings(); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[4][43][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[16][52][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[27][60][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[39][42][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[39][51][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[72][5][0]['source']); - $this->assertEquals('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[73][5][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[4][43][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[16][52][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[27][60][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[39][42][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[39][51][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[72][5][0]['source']); + $this->assertSame('VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable', $warnings[73][5][0]['source']); } public function testValidUnusedVariableNamesIgnoresUnusedVariables() { @@ -685,7 +685,7 @@ public function testValidUnusedVariableNamesIgnoresUnusedVariables() { 72, 73, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testAllowUnusedFunctionParametersIgnoresUnusedVariables() { @@ -704,7 +704,7 @@ public function testAllowUnusedFunctionParametersIgnoresUnusedVariables() { $phpcsFile->process(); $lines = $this->getWarningLineNumbersFromFile($phpcsFile); $expectedWarnings = []; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testAllowUnusedCaughtExceptionsIgnoresUnusedVariablesIfSet() { @@ -730,7 +730,7 @@ public function testAllowUnusedCaughtExceptionsIgnoresUnusedVariablesIfSet() { 72, 73, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testAllowUnusedCaughtExceptionsDoesNotIgnoreUnusedVariablesIfFalse() { @@ -757,7 +757,7 @@ public function testAllowUnusedCaughtExceptionsDoesNotIgnoreUnusedVariablesIfFal 72, 73, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testIgnoreUnusedRegexpIgnoresUnusedVariables() { @@ -782,7 +782,7 @@ public function testIgnoreUnusedRegexpIgnoresUnusedVariables() { 39, 72, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testAllowDestructuringAssignment() { @@ -798,7 +798,7 @@ public function testAllowDestructuringAssignment() { 43, 45, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testValidUndefinedVariableNamesIgnoresVarsInGlobalScope() { @@ -818,7 +818,7 @@ public function testValidUndefinedVariableNamesIgnoresVarsInGlobalScope() { 39, 54, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testValidUndefinedVariableNamesIgnoresUndefinedProperties() { @@ -839,7 +839,7 @@ public function testValidUndefinedVariableNamesIgnoresUndefinedProperties() { 24, 25 ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testValidUndefinedVariableRegexpIgnoresUndefinedProperties() { @@ -858,7 +858,7 @@ public function testValidUndefinedVariableRegexpIgnoresUndefinedProperties() { 24, 25 ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testUnusedArgumentsBeforeUsedArgumentsAreFoundIfFalse() { @@ -879,7 +879,7 @@ public function testUnusedArgumentsBeforeUsedArgumentsAreFoundIfFalse() { 28, 34, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testUnusedArgumentsBeforeUsedArgumentsAreIgnoredByDefault() { @@ -893,7 +893,7 @@ public function testUnusedArgumentsBeforeUsedArgumentsAreIgnoredByDefault() { 28, 34, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testPregReplaceIgnoresNumericVariables() { @@ -905,7 +905,7 @@ public function testPregReplaceIgnoresNumericVariables() { 15, 20, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testUnusedForeachVariablesAreIgnoredByDefault() { @@ -926,7 +926,7 @@ public function testUnusedForeachVariablesAreIgnoredByDefault() { 33, 34, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testUnusedForeachVariablesAreNotIgnoredIfDisabled() { @@ -953,7 +953,7 @@ public function testUnusedForeachVariablesAreNotIgnoredIfDisabled() { 33, 34, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testUnusedForeachVariablesAreIgnoredIfSet() { @@ -979,7 +979,7 @@ public function testUnusedForeachVariablesAreIgnoredIfSet() { 33, 34, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testGetDefinedVarsCountsAsRead() { @@ -993,7 +993,7 @@ public function testGetDefinedVarsCountsAsRead() { 22, 29, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testThisWithinNestedClosedScope() { @@ -1011,7 +1011,7 @@ public function testThisWithinNestedClosedScope() { 47, 61, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testUnusedVarWithValueChange() { @@ -1027,7 +1027,7 @@ public function testUnusedVarWithValueChange() { 11, 12, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testAssignmentByReference() { @@ -1042,7 +1042,7 @@ public function testAssignmentByReference() { 43, 70, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testAssignmentByReferenceWithIgnoreUnusedMatch() { @@ -1061,6 +1061,6 @@ public function testAssignmentByReferenceWithIgnoreUnusedMatch() { 35, 70, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } } diff --git a/Tests/VariableAnalysisSniff/VariableArgumentListTest.php b/Tests/VariableAnalysisSniff/VariableArgumentListTest.php index 7023a6c8..0fb3ad11 100644 --- a/Tests/VariableAnalysisSniff/VariableArgumentListTest.php +++ b/Tests/VariableAnalysisSniff/VariableArgumentListTest.php @@ -21,7 +21,7 @@ public function testVariableArgumentList() { 33, 38, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } public function testVariableArgumentListWithoutUnusedBeforeUsed() { @@ -43,6 +43,6 @@ public function testVariableArgumentListWithoutUnusedBeforeUsed() { 38, 43, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } } diff --git a/Tests/VariableAnalysisSniff/WhileLoopTest.php b/Tests/VariableAnalysisSniff/WhileLoopTest.php index 3609521e..bc6d779f 100644 --- a/Tests/VariableAnalysisSniff/WhileLoopTest.php +++ b/Tests/VariableAnalysisSniff/WhileLoopTest.php @@ -13,6 +13,6 @@ public function testFunctionWithWhileLoopWarnings() { 38, 46, ]; - $this->assertEquals($expectedWarnings, $lines); + $this->assertSame($expectedWarnings, $lines); } }