Skip to content

Commit be92edd

Browse files
committed
File/Get*Tests: work round removal of assertArraySubset()
The `assertArraySubset()` method was deprecated in PHPUnit 8.x and removed in PHPUnit 9.0.0 without replacement. The `assertArraySubset()` assertion was being used as not all token array indexes are being tested - to be specific: any index which is a token offset is not tested -. As the `assertArraySubset()` has been removed, I'm electing to unset the token offset array indexes and replacing the assertion with a strict type `assertSame()` comparison.
1 parent 11669f7 commit be92edd

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

tests/Core/File/GetMemberPropertiesTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ public function testGetMemberProperties($identifier, $expected)
3030
$variable = $this->getTargetToken($identifier, T_VARIABLE);
3131
$result = self::$phpcsFile->getMemberProperties($variable);
3232

33-
$this->assertArraySubset($expected, $result, true);
33+
// Unset those indexes which are not being tested.
34+
unset($result['type_token'], $result['type_end_token']);
35+
36+
$this->assertSame($expected, $result);
3437

3538
}//end testGetMemberProperties()
3639

tests/Core/File/GetMethodParametersTest.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,23 @@ private function getMethodParametersTestHelper($commentString, $expected)
11421142
$function = $this->getTargetToken($commentString, [T_FUNCTION, T_CLOSURE, T_FN]);
11431143
$found = self::$phpcsFile->getMethodParameters($function);
11441144

1145-
$this->assertArraySubset($expected, $found, true);
1145+
// Unset those indexes which are not being tested.
1146+
foreach ($found as $i => $param) {
1147+
unset(
1148+
$found[$i]['token'],
1149+
$found[$i]['reference_token'],
1150+
$found[$i]['variadic_token'],
1151+
$found[$i]['type_hint_token'],
1152+
$found[$i]['type_hint_end_token'],
1153+
$found[$i]['comma_token'],
1154+
$found[$i]['default_token'],
1155+
$found[$i]['default_equal_token'],
1156+
$found[$i]['visibility_token'],
1157+
$found[$i]['readonly_token']
1158+
);
1159+
}
1160+
1161+
$this->assertSame($expected, $found);
11461162

11471163
}//end getMethodParametersTestHelper()
11481164

tests/Core/File/GetMethodPropertiesTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,10 @@ private function getMethodPropertiesTestHelper($commentString, $expected)
902902
$function = $this->getTargetToken($commentString, [T_FUNCTION, T_CLOSURE, T_FN]);
903903
$found = self::$phpcsFile->getMethodProperties($function);
904904

905-
$this->assertArraySubset($expected, $found, true);
905+
// Unset those indexes which are not being tested.
906+
unset($found['return_type_token'], $found['return_type_end_token']);
907+
908+
$this->assertSame($expected, $found);
906909

907910
}//end getMethodPropertiesTestHelper()
908911

0 commit comments

Comments
 (0)