Skip to content

[CLEANUP] Split data provider for search pattern #1281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2025
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