@@ -86,7 +86,12 @@ public function testSetRulesStoresRules(): void
8686 'bar ' => 'baz|belch ' ,
8787 ];
8888 $ this ->validation ->setRules ($ rules );
89- $ this ->assertSame ($ rules , $ this ->validation ->getRules ());
89+
90+ $ expected = [
91+ 'foo ' => ['rules ' => ['bar ' , 'baz ' ]],
92+ 'bar ' => ['rules ' => ['baz ' , 'belch ' ]],
93+ ];
94+ $ this ->assertSame ($ expected , $ this ->validation ->getRules ());
9095 }
9196
9297 public function testSetRuleStoresRule ()
@@ -97,7 +102,7 @@ public function testSetRuleStoresRule()
97102 $ this ->assertSame ([
98103 'foo ' => [
99104 'label ' => null ,
100- 'rules ' => 'bar| baz ' ,
105+ 'rules ' => [ 'bar ' , ' baz '] ,
101106 ],
102107 ], $ this ->validation ->getRules ());
103108 }
@@ -110,7 +115,7 @@ public function testSetRuleMultipleWithIndividual()
110115 $ this ->assertSame ([
111116 'username ' => [
112117 'label ' => 'Username ' ,
113- 'rules ' => 'required| min_length[3] ' ,
118+ 'rules ' => [ 'required ' , ' min_length[3] '] ,
114119 ],
115120 'password ' => [
116121 'label ' => 'Password ' ,
@@ -136,11 +141,11 @@ public function testSetRuleAddsRule()
136141 $ this ->assertSame ([
137142 'bar ' => [
138143 'label ' => null ,
139- 'rules ' => 'bar| baz ' ,
144+ 'rules ' => [ 'bar ' , ' baz '] ,
140145 ],
141146 'foo ' => [
142147 'label ' => null ,
143- 'rules ' => 'foo| foz ' ,
148+ 'rules ' => [ 'foo ' , ' foz '] ,
144149 ],
145150 ], $ this ->validation ->getRules ());
146151 }
@@ -158,7 +163,7 @@ public function testSetRuleOverwritesRule()
158163 $ this ->assertSame ([
159164 'foo ' => [
160165 'label ' => null ,
161- 'rules ' => 'foo| foz ' ,
166+ 'rules ' => [ 'foo ' , ' foz '] ,
162167 ],
163168 ], $ this ->validation ->getRules ());
164169 }
@@ -176,7 +181,7 @@ public function testSetRuleOverwritesRuleReverse()
176181 $ this ->assertSame ([
177182 'foo ' => [
178183 'label ' => null ,
179- 'rules ' => 'bar| baz ' ,
184+ 'rules ' => [ 'bar ' , ' baz '] ,
180185 ],
181186 ], $ this ->validation ->getRules ());
182187 }
@@ -549,7 +554,7 @@ public function testSetRuleGroup(): void
549554 {
550555 $ this ->validation ->setRuleGroup ('groupA ' );
551556 $ this ->assertSame ([
552- 'foo ' => ' required| min_length[5] ' ,
557+ 'foo ' => [ ' rules ' => [ ' required ' , ' min_length[5] ']] ,
553558 ], $ this ->validation ->getRules ());
554559 }
555560
@@ -1386,7 +1391,7 @@ public function provideStringRulesCases(): iterable
13861391 protected function placeholderReplacementResultDetermination (string $ placeholder = 'id ' , ?array $ data = null )
13871392 {
13881393 if ($ data === null ) {
1389- $ data = [$ placeholder => 'placeholder-value ' ];
1394+ $ data = [$ placeholder => '12 ' ];
13901395 }
13911396
13921397 $ validationRules = $ this ->getPrivateMethodInvoker ($ this ->validation , 'fillPlaceholders ' )($ this ->validation ->getRules (), $ data );
@@ -1421,13 +1426,15 @@ public function testPlaceholderReplacementTestFails()
14211426
14221427 public function testPlaceholderReplacementSetSingleRuleString ()
14231428 {
1429+ $ this ->validation ->setRule ('id ' , null , 'required|is_natural_no_zero ' );
14241430 $ this ->validation ->setRule ('foo ' , null , 'required|filter[{id}] ' );
14251431
14261432 $ this ->placeholderReplacementResultDetermination ();
14271433 }
14281434
14291435 public function testPlaceholderReplacementSetSingleRuleArray ()
14301436 {
1437+ $ this ->validation ->setRule ('id ' , null , ['required ' , 'is_natural_no_zero ' ]);
14311438 $ this ->validation ->setRule ('foo ' , null , ['required ' , 'filter[{id}] ' ]);
14321439
14331440 $ this ->placeholderReplacementResultDetermination ();
@@ -1436,6 +1443,7 @@ public function testPlaceholderReplacementSetSingleRuleArray()
14361443 public function testPlaceholderReplacementSetMultipleRulesSimpleString ()
14371444 {
14381445 $ this ->validation ->setRules ([
1446+ 'id ' => 'required|is_natural_no_zero ' ,
14391447 'foo ' => 'required|filter[{id}] ' ,
14401448 ]);
14411449
@@ -1445,6 +1453,7 @@ public function testPlaceholderReplacementSetMultipleRulesSimpleString()
14451453 public function testPlaceholderReplacementSetMultipleRulesSimpleArray ()
14461454 {
14471455 $ this ->validation ->setRules ([
1456+ 'id ' => ['required ' , 'is_natural_no_zero ' ],
14481457 'foo ' => ['required ' , 'filter[{id}] ' ],
14491458 ]);
14501459
@@ -1454,6 +1463,9 @@ public function testPlaceholderReplacementSetMultipleRulesSimpleArray()
14541463 public function testPlaceholderReplacementSetMultipleRulesComplexString ()
14551464 {
14561465 $ this ->validation ->setRules ([
1466+ 'id ' => [
1467+ 'rules ' => 'required|is_natural_no_zero ' ,
1468+ ],
14571469 'foo ' => [
14581470 'rules ' => 'required|filter[{id}] ' ,
14591471 ],
@@ -1465,6 +1477,9 @@ public function testPlaceholderReplacementSetMultipleRulesComplexString()
14651477 public function testPlaceholderReplacementSetMultipleRulesComplexArray ()
14661478 {
14671479 $ this ->validation ->setRules ([
1480+ 'id ' => [
1481+ 'rules ' => ['required ' , 'is_natural_no_zero ' ],
1482+ ],
14681483 'foo ' => [
14691484 'rules ' => ['required ' , 'filter[{id}] ' ],
14701485 ],
0 commit comments