@@ -1001,42 +1001,21 @@ public function getRulesWithPatternReturnsAllMatchingRules(
10011001 array $ matchingPropertyNames
10021002 ): void {
10031003 $ 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+ )
10091012 );
10101013 $ this ->subject ->setRules ($ rulesToSet );
10111014
10121015 $ result = $ this ->subject ->getRules ($ searchPattern );
10131016
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 );
10401019 }
10411020
10421021 /**
0 commit comments