@@ -67,7 +67,7 @@ public static function providePropertyNamesToBeSetInitially(): array
6767 /**
6868 * @return array<string, array{0: non-empty-string}>
6969 */
70- public static function providePropertyNameToAdd (): array
70+ public static function provideAnotherPropertyName (): array
7171 {
7272 return [
7373 'property name `color` maybe matching that of existing declaration ' => ['color ' ],
@@ -79,17 +79,17 @@ public static function providePropertyNameToAdd(): array
7979 /**
8080 * @return DataProvider<string, array{0: list<string>, 1: string}>
8181 */
82- public static function provideInitialPropertyNamesAndPropertyNameToAdd (): DataProvider
82+ public static function provideInitialPropertyNamesAndAnotherPropertyName (): DataProvider
8383 {
84- return DataProvider::cross (self ::providePropertyNamesToBeSetInitially (), self ::providePropertyNameToAdd ());
84+ return DataProvider::cross (self ::providePropertyNamesToBeSetInitially (), self ::provideAnotherPropertyName ());
8585 }
8686
8787 /**
8888 * @test
8989 *
9090 * @param list<string> $initialPropertyNames
9191 *
92- * @dataProvider provideInitialPropertyNamesAndPropertyNameToAdd
92+ * @dataProvider provideInitialPropertyNamesAndAnotherPropertyName
9393 */
9494 public function addRuleWithoutSiblingAddsRuleAfterInitialRulesAndSetsValidLineAndColumnNumbers (
9595 array $ initialPropertyNames ,
@@ -111,7 +111,7 @@ public function addRuleWithoutSiblingAddsRuleAfterInitialRulesAndSetsValidLineAn
111111 /**
112112 * @test
113113 *
114- * @dataProvider provideInitialPropertyNamesAndPropertyNameToAdd
114+ * @dataProvider provideInitialPropertyNamesAndAnotherPropertyName
115115 *
116116 * @param list<string> $initialPropertyNames
117117 */
@@ -134,7 +134,7 @@ public function addRuleWithOnlyLineNumberAddsRuleAndSetsColumnNumberPreservingLi
134134 /**
135135 * @test
136136 *
137- * @dataProvider provideInitialPropertyNamesAndPropertyNameToAdd
137+ * @dataProvider provideInitialPropertyNamesAndAnotherPropertyName
138138 *
139139 * @param list<string> $initialPropertyNames
140140 */
@@ -158,7 +158,7 @@ public function addRuleWithOnlyColumnNumberAddsRuleAfterInitialRulesAndSetsLineN
158158 /**
159159 * @test
160160 *
161- * @dataProvider provideInitialPropertyNamesAndPropertyNameToAdd
161+ * @dataProvider provideInitialPropertyNamesAndAnotherPropertyName
162162 *
163163 * @param list<string> $initialPropertyNames
164164 */
@@ -180,21 +180,21 @@ public function addRuleWithCompletePositionAddsRuleAndPreservesPosition(
180180 /**
181181 * @return array<string, array{0: non-empty-list<non-empty-string>, 1: int<0, max>}>
182182 */
183- public static function provideInitialPropertyNamesAndSiblingIndex (): array
183+ public static function provideInitialPropertyNamesAndIndexOfOne (): array
184184 {
185185 $ initialPropertyNamesSets = self ::providePropertyNamesToBeSetInitially ();
186186
187- // Provide sets with each possible sibling index for the initially set `Rule`s.
188- $ initialPropertyNamesAndSiblingIndexSets = [];
187+ // Provide sets with each possible index for the initially set `Rule`s.
188+ $ initialPropertyNamesAndIndexSets = [];
189189 foreach ($ initialPropertyNamesSets as $ setName => $ data ) {
190190 $ initialPropertyNames = $ data [0 ];
191- for ($ siblingIndex = 0 ; $ siblingIndex < \count ($ initialPropertyNames ); ++$ siblingIndex ) {
192- $ initialPropertyNamesAndSiblingIndexSets [$ setName . ', sibling index ' . $ siblingIndex ] =
193- [$ initialPropertyNames , $ siblingIndex ];
191+ for ($ index = 0 ; $ index < \count ($ initialPropertyNames ); ++$ index ) {
192+ $ initialPropertyNamesAndIndexSets [$ setName . ', index ' . $ index ] =
193+ [$ initialPropertyNames , $ index ];
194194 }
195195 }
196196
197- return $ initialPropertyNamesAndSiblingIndexSets ;
197+ return $ initialPropertyNamesAndIndexSets ;
198198 }
199199
200200 /**
@@ -203,15 +203,15 @@ public static function provideInitialPropertyNamesAndSiblingIndex(): array
203203 public static function provideInitialPropertyNamesAndSiblingIndexAndPropertyNameToAdd (): DataProvider
204204 {
205205 return DataProvider::cross (
206- self ::provideInitialPropertyNamesAndSiblingIndex (),
207- self ::providePropertyNameToAdd ()
206+ self ::provideInitialPropertyNamesAndIndexOfOne (),
207+ self ::provideAnotherPropertyName ()
208208 );
209209 }
210210
211211 /**
212212 * @test
213213 *
214- * @param list<string> $initialPropertyNames
214+ * @param non-empty- list<string> $initialPropertyNames
215215 * @param int<0, max> $siblingIndex
216216 *
217217 * @dataProvider provideInitialPropertyNamesAndSiblingIndexAndPropertyNameToAdd
@@ -236,7 +236,7 @@ public function addRuleWithSiblingInsertsRuleBeforeSibling(
236236 /**
237237 * @test
238238 *
239- * @param list<string> $initialPropertyNames
239+ * @param non-empty- list<string> $initialPropertyNames
240240 * @param int<0, max> $siblingIndex
241241 *
242242 * @dataProvider provideInitialPropertyNamesAndSiblingIndexAndPropertyNameToAdd
@@ -259,7 +259,7 @@ public function addRuleWithSiblingSetsValidLineNumber(
259259 /**
260260 * @test
261261 *
262- * @param list<string> $initialPropertyNames
262+ * @param non-empty- list<string> $initialPropertyNames
263263 * @param int<0, max> $siblingIndex
264264 *
265265 * @dataProvider provideInitialPropertyNamesAndSiblingIndexAndPropertyNameToAdd
@@ -284,7 +284,7 @@ public function addRuleWithSiblingSetsValidColumnNumber(
284284 *
285285 * @param list<string> $initialPropertyNames
286286 *
287- * @dataProvider provideInitialPropertyNamesAndPropertyNameToAdd
287+ * @dataProvider provideInitialPropertyNamesAndAnotherPropertyName
288288 */
289289 public function addRuleWithSiblingNotInRuleSetAddsRuleAfterInitialRulesAndSetsValidLineAndColumnNumbers (
290290 array $ initialPropertyNames ,
@@ -305,6 +305,62 @@ public function addRuleWithSiblingNotInRuleSetAddsRuleAfterInitialRulesAndSetsVa
305305 self ::assertGreaterThanOrEqual (0 , $ ruleToAdd ->getColumnNumber (), 'column number not valid ' );
306306 }
307307
308+ /**
309+ * @test
310+ *
311+ * @param non-empty-list<string> $initialPropertyNames
312+ * @param int<0, max> $indexToRemove
313+ *
314+ * @dataProvider provideInitialPropertyNamesAndIndexOfOne
315+ */
316+ public function removeRuleRemovesRuleInSet (array $ initialPropertyNames , int $ indexToRemove ): void
317+ {
318+ $ this ->setRulesFromPropertyNames ($ initialPropertyNames );
319+ $ ruleToRemove = $ this ->subject ->getRules ()[$ indexToRemove ];
320+
321+ $ this ->subject ->removeRule ($ ruleToRemove );
322+
323+ self ::assertNotContains ($ ruleToRemove , $ this ->subject ->getRules ());
324+ }
325+
326+ /**
327+ * @test
328+ *
329+ * @param non-empty-list<string> $initialPropertyNames
330+ * @param int<0, max> $indexToRemove
331+ *
332+ * @dataProvider provideInitialPropertyNamesAndIndexOfOne
333+ */
334+ public function removeRuleRemovesExactlyOneRule (array $ initialPropertyNames , int $ indexToRemove ): void
335+ {
336+ $ this ->setRulesFromPropertyNames ($ initialPropertyNames );
337+ $ ruleToRemove = $ this ->subject ->getRules ()[$ indexToRemove ];
338+
339+ $ this ->subject ->removeRule ($ ruleToRemove );
340+
341+ self ::assertCount (\count ($ initialPropertyNames ) - 1 , $ this ->subject ->getRules ());
342+ }
343+
344+ /**
345+ * @test
346+ *
347+ * @param list<string> $initialPropertyNames
348+ *
349+ * @dataProvider provideInitialPropertyNamesAndAnotherPropertyName
350+ */
351+ public function removeRuleWithRuleNotInSetKeepsSetUnchanged (
352+ array $ initialPropertyNames ,
353+ string $ propertyNameToRemove
354+ ): void {
355+ $ this ->setRulesFromPropertyNames ($ initialPropertyNames );
356+ $ initialRules = $ this ->subject ->getRules ();
357+ $ ruleToRemove = new Rule ($ propertyNameToRemove );
358+
359+ $ this ->subject ->removeRule ($ ruleToRemove );
360+
361+ self ::assertSame ($ initialRules , $ this ->subject ->getRules ());
362+ }
363+
308364 /**
309365 * @return array<string, array{0: list<string>, 1: string, 2: list<string>}>
310366 */
0 commit comments