@@ -1001,42 +1001,21 @@ public function getRulesWithPatternReturnsAllMatchingRules(
1001
1001
array $ matchingPropertyNames
1002
1002
): void {
1003
1003
$ rulesToSet = self ::createRulesFromPropertyNames ($ propertyNamesToSet );
1004
- $ matchingRules = \array_filter (
1005
- $ rulesToSet ,
1006
- static function (Rule $ rule ) use ($ matchingPropertyNames ): bool {
1007
- return \in_array ($ rule ->getRule (), $ matchingPropertyNames , true );
1008
- }
1004
+ // Use `array_values` to ensure canonical numeric array, since `array_filter` does not reindex.
1005
+ $ matchingRules = \array_values (
1006
+ \array_filter (
1007
+ $ rulesToSet ,
1008
+ static function (Rule $ rule ) use ($ matchingPropertyNames ): bool {
1009
+ return \in_array ($ rule ->getRule (), $ matchingPropertyNames , true );
1010
+ }
1011
+ )
1009
1012
);
1010
1013
$ this ->subject ->setRules ($ rulesToSet );
1011
1014
1012
1015
$ result = $ this ->subject ->getRules ($ searchPattern );
1013
1016
1014
- foreach ($ matchingRules as $ expectedMatchingRule ) {
1015
- self ::assertContains ($ expectedMatchingRule , $ result );
1016
- }
1017
- }
1018
-
1019
- /**
1020
- * @test
1021
- *
1022
- * @param list<string> $propertyNamesToSet
1023
- * @param list<string> $matchingPropertyNames
1024
- *
1025
- * @dataProvider providePropertyNamesAndSearchPatternAndMatchingPropertyNames
1026
- */
1027
- public function getRulesWithPatternFiltersNonMatchingRules (
1028
- array $ propertyNamesToSet ,
1029
- string $ searchPattern ,
1030
- array $ matchingPropertyNames
1031
- ): void {
1032
- $ this ->setRulesFromPropertyNames ($ propertyNamesToSet );
1033
-
1034
- $ result = $ this ->subject ->getRules ($ searchPattern );
1035
-
1036
- foreach ($ result as $ resultRule ) {
1037
- // 'expected' and 'actual' are transposed here due to necessity
1038
- self ::assertContains ($ resultRule ->getRule (), $ matchingPropertyNames );
1039
- }
1017
+ // `Rule`s without pre-set positions are returned in the order set. This is tested separately.
1018
+ self ::assertSame ($ matchingRules , $ result );
1040
1019
}
1041
1020
1042
1021
/**
0 commit comments