Skip to content

Commit 8c7419c

Browse files
committed
Add separate test for non-matching patterns
1 parent b7c90b1 commit 8c7419c

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

tests/Unit/RuleSet/RuleSetTest.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,9 +1182,6 @@ public function getRulesAssocWithPatternReturnsAllMatchingPropertyNames(
11821182

11831183
$result = $this->subject->getRulesAssoc($searchPattern);
11841184

1185-
if ($matchingPropertyNames === []) {
1186-
self::assertSame([], $result);
1187-
}
11881185
foreach ($matchingPropertyNames as $expectedMatchingPropertyName) {
11891186
self::assertContains($expectedMatchingPropertyName, \array_keys($result));
11901187
}
@@ -1207,15 +1204,30 @@ public function getRulesAssocWithPatternFiltersNonMatchingRules(
12071204

12081205
$result = $this->subject->getRulesAssoc($searchPattern);
12091206

1210-
if ($result === []) {
1211-
self::expectNotToPerformAssertions();
1212-
}
12131207
foreach ($result as $resultRule) {
12141208
// 'expected' and 'actual' are transposed here due to necessity
12151209
self::assertContains($resultRule->getRule(), $matchingPropertyNames);
12161210
}
12171211
}
12181212

1213+
/**
1214+
* @test
1215+
*
1216+
* @param list<string> $propertyNamesToSet
1217+
*
1218+
* @dataProvider providePropertyNamesAndNonMatchingSearchPattern
1219+
*/
1220+
public function getRulesAssocWithNonMatchingPatternReturnsEmptyArray(
1221+
array $propertyNamesToSet,
1222+
string $searchPattern
1223+
): void {
1224+
$this->setRulesFromPropertyNames($propertyNamesToSet);
1225+
1226+
$result = $this->subject->getRulesAssoc($searchPattern);
1227+
1228+
self::assertSame([], $result);
1229+
}
1230+
12191231
/**
12201232
* @test
12211233
*/

0 commit comments

Comments
 (0)