22
33namespace ProgrammatorDev \YetAnotherPhpValidator \Test ;
44
5- use ProgrammatorDev \YetAnotherPhpValidator \Exception \AllException ;
6- use ProgrammatorDev \YetAnotherPhpValidator \Rule \All ;
5+ use ProgrammatorDev \YetAnotherPhpValidator \Exception \EachValueException ;
6+ use ProgrammatorDev \YetAnotherPhpValidator \Rule \EachValue ;
77use ProgrammatorDev \YetAnotherPhpValidator \Rule \GreaterThan ;
88use ProgrammatorDev \YetAnotherPhpValidator \Rule \NotBlank ;
99use ProgrammatorDev \YetAnotherPhpValidator \Test \Util \TestRuleFailureConditionTrait ;
1212use ProgrammatorDev \YetAnotherPhpValidator \Test \Util \TestRuleUnexpectedValueTrait ;
1313use ProgrammatorDev \YetAnotherPhpValidator \Validator ;
1414
15- class AllTest extends AbstractTest
15+ class EachValueTest extends AbstractTest
1616{
1717 use TestRuleUnexpectedValueTrait;
1818 use TestRuleFailureConditionTrait;
@@ -21,36 +21,25 @@ class AllTest extends AbstractTest
2121
2222 public static function provideRuleUnexpectedValueData (): \Generator
2323 {
24- yield 'invalid constraint ' => [
25- new All ([new NotBlank (), 'invalid ' ]),
26- [1 , 2 , 3 ],
27- '/All constraints must be of type "RuleInterface"./ '
28- ];
2924 yield 'invalid value type ' => [
30- new All ([ new NotBlank ()] ),
25+ new EachValue ( new Validator ( new NotBlank ()) ),
3126 'invalid ' ,
3227 '/Expected value of type "array", "(.*)" given./ '
3328 ];
3429 yield 'unexpected value propagation ' => [
35- new All ([ new GreaterThan (10 )] ),
30+ new EachValue ( new Validator ( new GreaterThan (10 )) ),
3631 ['a ' ],
3732 '/Cannot compare a type "(.*)" with a type "(.*)"./ '
3833 ];
3934 }
4035
4136 public static function provideRuleFailureConditionData (): \Generator
4237 {
43- $ exception = AllException ::class;
44- $ message = '/At "(.*)": The "(.*)" value should not be blank, "(.*)" given./ ' ;
38+ $ exception = EachValueException ::class;
39+ $ message = '/At key "(.*)": The "(.*)" value should not be blank, "(.*)" given./ ' ;
4540
4641 yield 'constraint ' => [
47- new All ([new NotBlank ()]),
48- [1 , 2 , '' ],
49- $ exception ,
50- $ message
51- ];
52- yield 'validator ' => [
53- new All ([(new Validator (new NotBlank ()))]),
42+ new EachValue (new Validator (new NotBlank ())),
5443 [1 , 2 , '' ],
5544 $ exception ,
5645 $ message
@@ -59,31 +48,17 @@ public static function provideRuleFailureConditionData(): \Generator
5948
6049 public static function provideRuleSuccessConditionData (): \Generator
6150 {
62- yield 'constraints ' => [
63- new All ([new NotBlank (), new GreaterThan (1 )]),
64- [2 , 3 , 4 ]
65- ];
66- yield 'validators ' => [
67- new All ([
68- (new Validator (new NotBlank ())),
69- (new Validator (new GreaterThan (1 )))
70- ]),
71- [2 , 3 , 4 ]
72- ];
73- yield 'constraints and validators ' => [
74- new All ([
75- new NotBlank (),
76- (new Validator (new GreaterThan (1 )))
77- ]),
51+ yield 'constraint ' => [
52+ new EachValue (new Validator (new NotBlank (), new GreaterThan (1 ))),
7853 [2 , 3 , 4 ]
7954 ];
8055 }
8156
8257 public static function provideRuleMessageOptionData (): \Generator
8358 {
8459 yield 'constraint ' => [
85- new All (
86- constraints: [ new NotBlank ()] ,
60+ new EachValue (
61+ validator: new Validator ( new NotBlank ()) ,
8762 message: 'The "{{ name }}" value "{{ value }}" failed at key "{{ key }}". '
8863 ),
8964 [1 , 2 , '' ],
0 commit comments