@@ -102,6 +102,27 @@ public function testSetRuleStoresRule()
102102 ], $ this ->validation ->getRules ());
103103 }
104104
105+ public function testSetRuleMultipleWithIndividual ()
106+ {
107+ $ this ->validation ->setRule ('username ' , 'Username ' , 'required|min_length[3] ' );
108+ $ this ->validation ->setRule ('password ' , 'Password ' , ['required ' , 'min_length[8] ' , 'alpha_numeric_punct ' ]);
109+
110+ $ this ->assertSame ([
111+ 'username ' => [
112+ 'label ' => 'Username ' ,
113+ 'rules ' => 'required|min_length[3] ' ,
114+ ],
115+ 'password ' => [
116+ 'label ' => 'Password ' ,
117+ 'rules ' => [
118+ 'required ' ,
119+ 'min_length[8] ' ,
120+ 'alpha_numeric_punct ' ,
121+ ],
122+ ],
123+ ], $ this ->validation ->getRules ());
124+ }
125+
105126 public function testSetRuleAddsRule ()
106127 {
107128 $ this ->validation ->setRules ([
@@ -113,14 +134,14 @@ public function testSetRuleAddsRule()
113134 $ this ->validation ->setRule ('foo ' , null , 'foo|foz ' );
114135
115136 $ this ->assertSame ([
116- 'foo ' => [
117- 'label ' => null ,
118- 'rules ' => 'foo|foz ' ,
119- ],
120137 'bar ' => [
121138 'label ' => null ,
122139 'rules ' => 'bar|baz ' ,
123140 ],
141+ 'foo ' => [
142+ 'label ' => null ,
143+ 'rules ' => 'foo|foz ' ,
144+ ],
124145 ], $ this ->validation ->getRules ());
125146 }
126147
@@ -142,6 +163,24 @@ public function testSetRuleOverwritesRule()
142163 ], $ this ->validation ->getRules ());
143164 }
144165
166+ public function testSetRuleOverwritesRuleReverse ()
167+ {
168+ $ this ->validation ->setRule ('foo ' , null , 'foo|foz ' );
169+ $ this ->validation ->setRules ([
170+ 'foo ' => [
171+ 'label ' => null ,
172+ 'rules ' => 'bar|baz ' ,
173+ ],
174+ ]);
175+
176+ $ this ->assertSame ([
177+ 'foo ' => [
178+ 'label ' => null ,
179+ 'rules ' => 'bar|baz ' ,
180+ ],
181+ ], $ this ->validation ->getRules ());
182+ }
183+
145184 /**
146185 * @dataProvider setRuleRulesFormatCaseProvider
147186 *
0 commit comments