Skip to content

Commit b2894ce

Browse files
committed
Tests: data set keys should match parameter names
Initially to prevent issues with a few PHPUnit versions which were around in the early days of PHP 8.0, where these would accidentally be seen as parameter names. So, as a best practice, when using keys in data sets, the keys should match the parameter names of the receiving test method. An ulterior reason to make this change is that PHPUnit 11 will always treat the keys as parameter names, so this can be seen as a preparation step for allowing for PHPUnit 11 support in PHPCS 4.0.
1 parent 263cdef commit b2894ce

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

tests/Core/Config/ReportWidthTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,18 @@ public function testReportWidthInputHandlingForAuto()
234234
/**
235235
* Test that the report width will be set correctly for various types of input.
236236
*
237-
* @param mixed $input Input value received.
237+
* @param mixed $value Input value received.
238238
* @param int $expected Expected report width.
239239
*
240240
* @dataProvider dataReportWidthInputHandling
241241
* @covers \PHP_CodeSniffer\Config::__set
242242
*
243243
* @return void
244244
*/
245-
public function testReportWidthInputHandling($input, $expected)
245+
public function testReportWidthInputHandling($value, $expected)
246246
{
247247
$config = new Config();
248-
$config->reportWidth = $input;
248+
$config->reportWidth = $value;
249249

250250
$this->assertSame($expected, $config->reportWidth);
251251

tests/Core/ErrorSuppressionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,9 +665,9 @@ public static function dataSuppressFile()
665665
{
666666
return [
667667
'no suppression' => [
668-
'before' => '',
669-
'after' => '',
670-
'expectedErrors' => 1,
668+
'before' => '',
669+
'after' => '',
670+
'expectedWarnings' => 1,
671671
],
672672

673673
// Process with suppression.

tests/Core/File/IsReferenceTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ public function testNotBitwiseAndToken()
3636
/**
3737
* Test correctly identifying whether a "bitwise and" token is a reference or not.
3838
*
39-
* @param string $identifier Comment which precedes the test case.
39+
* @param string $testMarker Comment which precedes the test case.
4040
* @param bool $expected Expected function output.
4141
*
4242
* @dataProvider dataIsReference
4343
*
4444
* @return void
4545
*/
46-
public function testIsReference($identifier, $expected)
46+
public function testIsReference($testMarker, $expected)
4747
{
48-
$bitwiseAnd = $this->getTargetToken($identifier, T_BITWISE_AND);
48+
$bitwiseAnd = $this->getTargetToken($testMarker, T_BITWISE_AND);
4949
$result = self::$phpcsFile->isReference($bitwiseAnd);
5050
$this->assertSame($expected, $result);
5151

0 commit comments

Comments
 (0)