Skip to content

Tests: use strict assertions #247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Tests/VariableAnalysisSniff/ArrayAssignmentShortcutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function testArrayAssignmentReportsCorrectLines() {
28,
29,
];
$this->assertEquals($expectedWarnings, $lines);
$this->assertSame($expectedWarnings, $lines);
}

public function testArrayAssignmentHasCorrectSniffCodes() {
Expand All @@ -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']);
}
}
4 changes: 2 additions & 2 deletions Tests/VariableAnalysisSniff/ArrowFunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testArrowFunctions() {
67,
71,
];
$this->assertEquals($expectedWarnings, $lines);
$this->assertSame($expectedWarnings, $lines);
}

public function testArrowFunctionsWithoutUnusedBeforeUsed() {
Expand Down Expand Up @@ -55,6 +55,6 @@ public function testArrowFunctionsWithoutUnusedBeforeUsed() {
67,
71,
];
$this->assertEquals($expectedWarnings, $lines);
$this->assertSame($expectedWarnings, $lines);
}
}
10 changes: 5 additions & 5 deletions Tests/VariableAnalysisSniff/ClosingPhpTagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ public function testVariableWarningsWhenClosingTagsAreUsed() {
13,
16,
];
$this->assertEquals($expectedWarnings, $lines);
$this->assertSame($expectedWarnings, $lines);
}

public function testVariableWarningsHaveCorrectSniffCodesWhenClosingTagsAreUsed() {
$fixtureFile = $this->getFixture('ClosingPhpTagsFixture.php');
$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']);
}
}
6 changes: 3 additions & 3 deletions Tests/VariableAnalysisSniff/GlobalScopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function testGlobalScopeWarnings() {
10,
13,
];
$this->assertEquals($expectedErrors, $lines);
$this->assertSame($expectedErrors, $lines);
}

public function testGlobalScopeWarningsWithAllowUndefinedVariablesInFileScope() {
Expand All @@ -38,7 +38,7 @@ public function testGlobalScopeWarningsWithAllowUndefinedVariablesInFileScope()
10,
13,
];
$this->assertEquals($expectedErrors, $lines);
$this->assertSame($expectedErrors, $lines);
}

public function testGlobalScopeWarningsWithAllowUnusedVariablesInFileScope() {
Expand All @@ -55,6 +55,6 @@ public function testGlobalScopeWarningsWithAllowUnusedVariablesInFileScope() {
7,
10,
];
$this->assertEquals($expectedErrors, $lines);
$this->assertSame($expectedErrors, $lines);
}
}
8 changes: 4 additions & 4 deletions Tests/VariableAnalysisSniff/IfConditionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testIfConditionWarnings() {
176,
179,
];
$this->assertEquals($expectedWarnings, $lines);
$this->assertSame($expectedWarnings, $lines);
}

public function testIfConditionWarningsWithValidUndefinedVariableNames() {
Expand Down Expand Up @@ -64,7 +64,7 @@ public function testIfConditionWarningsWithValidUndefinedVariableNames() {
176,
179,
];
$this->assertEquals($expectedWarnings, $lines);
$this->assertSame($expectedWarnings, $lines);
}

public function testInlineIfConditionWarnings() {
Expand Down Expand Up @@ -96,7 +96,7 @@ public function testInlineIfConditionWarnings() {
152,
154,
];
$this->assertEquals($expectedWarnings, $lines);
$this->assertSame($expectedWarnings, $lines);
}

public function testInlineIfConditionWarningsWithValidUndefinedVariableNames() {
Expand Down Expand Up @@ -127,6 +127,6 @@ public function testInlineIfConditionWarningsWithValidUndefinedVariableNames() {
152,
154,
];
$this->assertEquals($expectedWarnings, $lines);
$this->assertSame($expectedWarnings, $lines);
}
}
2 changes: 1 addition & 1 deletion Tests/VariableAnalysisSniff/IssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
6 changes: 3 additions & 3 deletions Tests/VariableAnalysisSniff/UnsetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testUnsetReportsUndefinedVariables() {
6,
11,
];
$this->assertEquals($expectedWarnings, $lines);
$this->assertSame($expectedWarnings, $lines);
}

public function testUnsetHasCorrectSniffCodes() {
Expand All @@ -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']);
}
}
6 changes: 3 additions & 3 deletions Tests/VariableAnalysisSniff/UnusedFollowedByRequireTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testUnusedFollowedByRequireWarnsByDefault() {
21,
22,
];
$this->assertEquals($expectedWarnings, $lines);
$this->assertSame($expectedWarnings, $lines);
}

public function testUnusedFollowedByRequireDoesNotWarnWhenSet() {
Expand All @@ -42,7 +42,7 @@ public function testUnusedFollowedByRequireDoesNotWarnWhenSet() {
16,
22,
];
$this->assertEquals($expectedWarnings, $lines);
$this->assertSame($expectedWarnings, $lines);
}

public function testUnusedFollowedByRequireDoesNotBreakOtherThingsWhenSet() {
Expand All @@ -69,6 +69,6 @@ public function testUnusedFollowedByRequireDoesNotBreakOtherThingsWhenSet() {
18,
19,
];
$this->assertEquals($expectedWarnings, $lines);
$this->assertSame($expectedWarnings, $lines);
}
}
Loading