@@ -51,38 +51,38 @@ public function implementsRuleContainer(): void
51
51
}
52
52
53
53
/**
54
- * @return array<string, array{0: list<Rule >, 1: string, 2: list<string>}>
54
+ * @return array<string, array{0: list<string >, 1: string, 2: list<string>}>
55
55
*/
56
- public static function provideRulesAndPropertyNameToRemoveAndExpectedRemainingPropertyNames (): array
56
+ public static function providePropertyNamesAndPropertyNameToRemoveAndExpectedRemainingPropertyNames (): array
57
57
{
58
58
return [
59
59
'removing single rule ' => [
60
- [new Rule ( 'color ' ) ],
60
+ ['color ' ],
61
61
'color ' ,
62
62
[],
63
63
],
64
64
'removing first rule ' => [
65
- [new Rule ( 'color ' ), new Rule ( 'display ' ) ],
65
+ ['color ' , 'display ' ],
66
66
'color ' ,
67
67
['display ' ],
68
68
],
69
69
'removing last rule ' => [
70
- [new Rule ( 'color ' ), new Rule ( 'display ' ) ],
70
+ ['color ' , 'display ' ],
71
71
'display ' ,
72
72
['color ' ],
73
73
],
74
74
'removing middle rule ' => [
75
- [new Rule ( 'color ' ), new Rule ( 'display ' ), new Rule ( 'width ' ) ],
75
+ ['color ' , 'display ' , 'width ' ],
76
76
'display ' ,
77
77
['color ' , 'width ' ],
78
78
],
79
79
'removing multiple rules ' => [
80
- [new Rule ( 'color ' ), new Rule ( 'color ' ) ],
80
+ ['color ' , 'color ' ],
81
81
'color ' ,
82
82
[],
83
83
],
84
84
'removing multiple rules with another kept ' => [
85
- [new Rule ( 'color ' ), new Rule ( 'color ' ), new Rule ( 'display ' ) ],
85
+ ['color ' , 'color ' , 'display ' ],
86
86
'color ' ,
87
87
['display ' ],
88
88
],
@@ -92,7 +92,7 @@ public static function provideRulesAndPropertyNameToRemoveAndExpectedRemainingPr
92
92
[],
93
93
],
94
94
'removing nonexistent rule from nonempty list ' => [
95
- [new Rule ( 'color ' ), new Rule ( 'display ' ) ],
95
+ ['color ' , 'display ' ],
96
96
'width ' ,
97
97
['color ' , 'display ' ],
98
98
],
@@ -102,60 +102,60 @@ public static function provideRulesAndPropertyNameToRemoveAndExpectedRemainingPr
102
102
/**
103
103
* @test
104
104
*
105
- * @param list<Rule > $rules
105
+ * @param list<string > $initialPropertyNames
106
106
* @param list<string> $expectedRemainingPropertyNames
107
107
*
108
- * @dataProvider provideRulesAndPropertyNameToRemoveAndExpectedRemainingPropertyNames
108
+ * @dataProvider providePropertyNamesAndPropertyNameToRemoveAndExpectedRemainingPropertyNames
109
109
*/
110
110
public function removeMatchingRulesRemovesRulesByPropertyNameAndKeepsOthers (
111
- array $ rules ,
112
- string $ propertyName ,
111
+ array $ initialPropertyNames ,
112
+ string $ propertyNameToRemove ,
113
113
array $ expectedRemainingPropertyNames
114
114
): void {
115
- $ this ->subject -> setRules ( $ rules );
115
+ $ this ->setRulesFromPropertyNames ( $ initialPropertyNames );
116
116
117
- $ this ->subject ->removeMatchingRules ($ propertyName );
117
+ $ this ->subject ->removeMatchingRules ($ propertyNameToRemove );
118
118
119
119
$ remainingRules = $ this ->subject ->getRulesAssoc ();
120
- self ::assertArrayNotHasKey ($ propertyName , $ remainingRules );
120
+ self ::assertArrayNotHasKey ($ propertyNameToRemove , $ remainingRules );
121
121
foreach ($ expectedRemainingPropertyNames as $ expectedPropertyName ) {
122
122
self ::assertArrayHasKey ($ expectedPropertyName , $ remainingRules );
123
123
}
124
124
}
125
125
126
126
/**
127
- * @return array<string, array{0: list<Rule >, 1: string, 2: list<string>}>
127
+ * @return array<string, array{0: list<string >, 1: string, 2: list<string>}>
128
128
*/
129
- public static function provideRulesAndPropertyNamePrefixToRemoveAndExpectedRemainingPropertyNames (): array
129
+ public static function providePropertyNamesAndPropertyNamePrefixToRemoveAndExpectedRemainingPropertyNames (): array
130
130
{
131
131
return [
132
132
'removing shorthand rule ' => [
133
- [new Rule ( 'font ' ) ],
133
+ ['font ' ],
134
134
'font ' ,
135
135
[],
136
136
],
137
137
'removing longhand rule ' => [
138
- [new Rule ( 'font-size ' ) ],
138
+ ['font-size ' ],
139
139
'font ' ,
140
140
[],
141
141
],
142
142
'removing shorthand and longhand rule ' => [
143
- [new Rule ( 'font ' ), new Rule ( 'font-size ' ) ],
143
+ ['font ' , 'font-size ' ],
144
144
'font ' ,
145
145
[],
146
146
],
147
147
'removing shorthand rule with another kept ' => [
148
- [new Rule ( 'font ' ), new Rule ( 'color ' ) ],
148
+ ['font ' , 'color ' ],
149
149
'font ' ,
150
150
['color ' ],
151
151
],
152
152
'removing longhand rule with another kept ' => [
153
- [new Rule ( 'font-size ' ), new Rule ( 'color ' ) ],
153
+ ['font-size ' , 'color ' ],
154
154
'font ' ,
155
155
['color ' ],
156
156
],
157
157
'keeping other rules whose property names begin with the same characters ' => [
158
- [new Rule ( 'contain ' ), new Rule ( 'container ' ), new Rule ( 'container-type ' ) ],
158
+ ['contain ' , 'container ' , 'container-type ' ],
159
159
'contain ' ,
160
160
['container ' , 'container-type ' ],
161
161
],
@@ -165,18 +165,18 @@ public static function provideRulesAndPropertyNamePrefixToRemoveAndExpectedRemai
165
165
/**
166
166
* @test
167
167
*
168
- * @param list<Rule > $rules
168
+ * @param list<string > $initialPropertyNames
169
169
* @param list<string> $expectedRemainingPropertyNames
170
170
*
171
- * @dataProvider provideRulesAndPropertyNamePrefixToRemoveAndExpectedRemainingPropertyNames
171
+ * @dataProvider providePropertyNamesAndPropertyNamePrefixToRemoveAndExpectedRemainingPropertyNames
172
172
*/
173
173
public function removeMatchingRulesRemovesRulesByPropertyNamePrefixAndKeepsOthers (
174
- array $ rules ,
174
+ array $ initialPropertyNames ,
175
175
string $ propertyNamePrefix ,
176
176
array $ expectedRemainingPropertyNames
177
177
): void {
178
178
$ propertyNamePrefixWithHyphen = $ propertyNamePrefix . '- ' ;
179
- $ this ->subject -> setRules ( $ rules );
179
+ $ this ->setRulesFromPropertyNames ( $ initialPropertyNames );
180
180
181
181
$ this ->subject ->removeMatchingRules ($ propertyNamePrefixWithHyphen );
182
182
@@ -191,31 +191,44 @@ public function removeMatchingRulesRemovesRulesByPropertyNamePrefixAndKeepsOther
191
191
}
192
192
193
193
/**
194
- * @return array<string, array{0: list<Rule >}>
194
+ * @return array<string, array{0: list<string >}>
195
195
*/
196
- public static function provideRulesToRemove (): array
196
+ public static function providePropertyNamesToRemove (): array
197
197
{
198
198
return [
199
- 'no rules ' => [[]],
200
- 'one rule ' => [[new Rule ( 'color ' ) ]],
201
- 'two rules for different properties ' => [[new Rule ( 'color ' ), new Rule ( 'display ' ) ]],
202
- 'two rules for the same property ' => [[new Rule ( 'color ' ), new Rule ( 'color ' ) ]],
199
+ 'no properties ' => [[]],
200
+ 'one property ' => [['color ' ]],
201
+ 'two different properties ' => [['color ' , 'display ' ]],
202
+ 'two of the same property ' => [['color ' , 'color ' ]],
203
203
];
204
204
}
205
205
206
206
/**
207
207
* @test
208
208
*
209
- * @param list<Rule > $rules
209
+ * @param list<string > $propertyNamesToRemove
210
210
*
211
- * @dataProvider provideRulesToRemove
211
+ * @dataProvider providePropertyNamesToRemove
212
212
*/
213
- public function removeAllRulesRemovesAllRules (array $ rules ): void
213
+ public function removeAllRulesRemovesAllRules (array $ propertyNamesToRemove ): void
214
214
{
215
- $ this ->subject -> setRules ( $ rules );
215
+ $ this ->setRulesFromPropertyNames ( $ propertyNamesToRemove );
216
216
217
217
$ this ->subject ->removeAllRules ();
218
218
219
219
self ::assertSame ([], $ this ->subject ->getRules ());
220
220
}
221
+
222
+ /**
223
+ * @param list<string> $propertyNames
224
+ */
225
+ private function setRulesFromPropertyNames (array $ propertyNames ): void
226
+ {
227
+ $ this ->subject ->setRules (\array_map (
228
+ static function (string $ propertyName ): Rule {
229
+ return new Rule ($ propertyName );
230
+ },
231
+ $ propertyNames
232
+ ));
233
+ }
221
234
}
0 commit comments