Skip to content
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

Tests: always use type strict assertions #876

Merged
merged 1 commit into from
Mar 13, 2025
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
8 changes: 4 additions & 4 deletions tests/Core/Autoloader/DetermineLoadedClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testOrdered()
];

$className = Autoload::determineLoadedClass($classesBeforeLoad, $classesAfterLoad);
$this->assertEquals('PHP_CodeSniffer\Tests\Core\Autoloader\Sub\C', $className);
$this->assertSame('PHP_CodeSniffer\Tests\Core\Autoloader\Sub\C', $className);

}//end testOrdered()

Expand Down Expand Up @@ -90,7 +90,7 @@ public function testUnordered()
];

$className = Autoload::determineLoadedClass($classesBeforeLoad, $classesAfterLoad);
$this->assertEquals('PHP_CodeSniffer\Tests\Core\Autoloader\Sub\C', $className);
$this->assertSame('PHP_CodeSniffer\Tests\Core\Autoloader\Sub\C', $className);

$classesAfterLoad = [
'classes' => [
Expand All @@ -104,7 +104,7 @@ public function testUnordered()
];

$className = Autoload::determineLoadedClass($classesBeforeLoad, $classesAfterLoad);
$this->assertEquals('PHP_CodeSniffer\Tests\Core\Autoloader\Sub\C', $className);
$this->assertSame('PHP_CodeSniffer\Tests\Core\Autoloader\Sub\C', $className);

$classesAfterLoad = [
'classes' => [
Expand All @@ -118,7 +118,7 @@ public function testUnordered()
];

$className = Autoload::determineLoadedClass($classesBeforeLoad, $classesAfterLoad);
$this->assertEquals('PHP_CodeSniffer\Tests\Core\Autoloader\Sub\C', $className);
$this->assertSame('PHP_CodeSniffer\Tests\Core\Autoloader\Sub\C', $className);

}//end testUnordered()

Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Filters/Filter/AcceptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testExcludePatterns($inputPaths, $expectedOutput)
$fakeDI = new RecursiveArrayIterator($inputPaths);
$filter = new Filter($fakeDI, '/', self::$config, self::$ruleset);

$this->assertEquals($expectedOutput, $this->getFilteredResultsAsArray($filter));
$this->assertSame($expectedOutput, $this->getFilteredResultsAsArray($filter));

}//end testExcludePatterns()

Expand Down
4 changes: 2 additions & 2 deletions tests/Core/Filters/GitModifiedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testFileNamePassesAsBasePathWillTranslateToDirname()
->method('exec')
->willReturn(['autoload.php']);

$this->assertEquals([$rootFile], $this->getFilteredResultsAsArray($mockObj));
$this->assertSame([$rootFile], $this->getFilteredResultsAsArray($mockObj));

}//end testFileNamePassesAsBasePathWillTranslateToDirname()

Expand Down Expand Up @@ -76,7 +76,7 @@ public function testAcceptOnlyGitModified($inputPaths, $outputGitModified, $expe
->method('exec')
->willReturn($outputGitModified);

$this->assertEquals($expectedOutput, $this->getFilteredResultsAsArray($mockObj));
$this->assertSame($expectedOutput, $this->getFilteredResultsAsArray($mockObj));

}//end testAcceptOnlyGitModified()

Expand Down
4 changes: 2 additions & 2 deletions tests/Core/Filters/GitStagedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testFileNamePassesAsBasePathWillTranslateToDirname()
->method('exec')
->willReturn(['autoload.php']);

$this->assertEquals([$rootFile], $this->getFilteredResultsAsArray($mockObj));
$this->assertSame([$rootFile], $this->getFilteredResultsAsArray($mockObj));

}//end testFileNamePassesAsBasePathWillTranslateToDirname()

Expand Down Expand Up @@ -76,7 +76,7 @@ public function testAcceptOnlyGitStaged($inputPaths, $outputGitStaged, $expected
->method('exec')
->willReturn($outputGitStaged);

$this->assertEquals($expectedOutput, $this->getFilteredResultsAsArray($mockObj));
$this->assertSame($expectedOutput, $this->getFilteredResultsAsArray($mockObj));

}//end testAcceptOnlyGitStaged()

Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Ruleset/RegisterSniffsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function testRegisteredSniffsBothRestrictionsAndExclusions()

self::$ruleset->registerSniffs(self::$psr1SniffAbsolutePaths, $restrictions, $exclusions);

$this->assertEquals($expected, array_keys(self::$ruleset->sniffs));
$this->assertSame($expected, array_keys(self::$ruleset->sniffs));

}//end testRegisteredSniffsBothRestrictionsAndExclusions()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ public function testOtherColonsInTernary($testMarker)
// Third colon should be T_COLON for the return type.
$colonCount = 0;
for ($i = ($startOfStatement + 1); $tokens[$i]['line'] === $tokens[$startOfStatement]['line']; $i++) {
$this->assertNotEquals(T_PARAM_NAME, $tokens[$i]['code'], "Token $i is tokenized as parameter label");
$this->assertNotSame(T_PARAM_NAME, $tokens[$i]['code'], "Token $i is tokenized as parameter label");

if ($tokens[$i]['content'] === ':') {
++$colonCount;
Expand Down