Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 39 additions & 16 deletions tests/Unit/RuleSet/RuleSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -949,16 +949,6 @@ public static function providePropertyNamesAndSearchPatternAndMatchingPropertyNa
'color',
['color'],
],
'no match in empty list' => [
[],
'color',
[],
],
'no match for property not in list' => [
['color', 'display'],
'width',
[],
],
'shorthand rule matched' => [
['font'],
'font-',
Expand Down Expand Up @@ -1021,9 +1011,6 @@ static function (Rule $rule) use ($matchingPropertyNames): bool {

$result = $this->subject->getRules($searchPattern);

if ($matchingRules === []) {
self::assertSame([], $result);
}
foreach ($matchingRules as $expectedMatchingRule) {
self::assertContains($expectedMatchingRule, $result);
}
Expand All @@ -1046,15 +1033,51 @@ public function getRulesWithPatternFiltersNonMatchingRules(

$result = $this->subject->getRules($searchPattern);

if ($result === []) {
self::expectNotToPerformAssertions();
}
foreach ($result as $resultRule) {
// 'expected' and 'actual' are transposed here due to necessity
self::assertContains($resultRule->getRule(), $matchingPropertyNames);
}
}

/**
* @return array<string, array{0: list<string>, 1: string}>
*/
public static function providePropertyNamesAndNonMatchingSearchPattern(): array
{
return [
'no match in empty list' => [
[],
'color',
],
'no match for different property' => [
['color'],
'display',
],
'no match for property not in list' => [
['color', 'display'],
'width',
],
];
}

/**
* @test
*
* @param list<string> $propertyNamesToSet
*
* @dataProvider providePropertyNamesAndNonMatchingSearchPattern
*/
public function getRulesWithNonMatchingPatternReturnsEmptyArray(
array $propertyNamesToSet,
string $searchPattern
): void {
$this->setRulesFromPropertyNames($propertyNamesToSet);

$result = $this->subject->getRules($searchPattern);

self::assertSame([], $result);
}

/**
* @test
*/
Expand Down