1515use Symfony \Component \Console \Tester \CommandTester ;
1616use Symfony \Component \Validator \Command \DebugCommand ;
1717use Symfony \Component \Validator \Constraints \Email ;
18+ use Symfony \Component \Validator \Constraints \Expression ;
1819use Symfony \Component \Validator \Constraints \NotBlank ;
1920use Symfony \Component \Validator \Mapping \ClassMetadataInterface ;
2021use Symfony \Component \Validator \Mapping \Factory \MetadataFactoryInterface ;
@@ -38,6 +39,11 @@ public function testOutputWithClassArgument()
3839 ->with (DummyClassOne::class)
3940 ->willReturn ($ classMetadata );
4041
42+ $ classMetadata
43+ ->expects ($ this ->once ())
44+ ->method ('getConstraints ' )
45+ ->willReturn ([new Expression ('1 + 1 = 2 ' )]);
46+
4147 $ classMetadata
4248 ->expects ($ this ->once ())
4349 ->method ('getConstrainedProperties ' )
@@ -68,22 +74,28 @@ public function testOutputWithClassArgument()
6874Symfony\Component\Validator\Tests\Dummy\DummyClassOne
6975-----------------------------------------------------
7076
71- +---------------+--------------------------------------------------+---------+------------------------------------------------------------+
72- | Property | Name | Groups | Options |
73- +---------------+--------------------------------------------------+---------+------------------------------------------------------------+
74- | firstArgument | Symfony\Component\Validator\Constraints\NotBlank | Default | [ |
75- | | | | "allowNull" => false, |
76- | | | | "message" => "This value should not be blank.", |
77- | | | | "normalizer" => null, |
78- | | | | "payload" => null |
79- | | | | ] |
80- | firstArgument | Symfony\Component\Validator\Constraints\Email | Default | [ |
81- | | | | "message" => "This value is not a valid email address.", |
82- | | | | "mode" => null, |
83- | | | | "normalizer" => null, |
84- | | | | "payload" => null |
85- | | | | ] |
86- +---------------+--------------------------------------------------+---------+------------------------------------------------------------+
77+ +---------------+----------------------------------------------------+---------+------------------------------------------------------------+
78+ | Property | Name | Groups | Options |
79+ +---------------+----------------------------------------------------+---------+------------------------------------------------------------+
80+ | - | Symfony\Component\Validator\Constraints\Expression | Default | [ |
81+ | | | | "expression" => "1 + 1 = 2", |
82+ | | | | "message" => "This value is not valid.", |
83+ | | | | "payload" => null, |
84+ | | | | "values" => [] |
85+ | | | | ] |
86+ | firstArgument | Symfony\Component\Validator\Constraints\NotBlank | Default | [ |
87+ | | | | "allowNull" => false, |
88+ | | | | "message" => "This value should not be blank.", |
89+ | | | | "normalizer" => null, |
90+ | | | | "payload" => null |
91+ | | | | ] |
92+ | firstArgument | Symfony\Component\Validator\Constraints\Email | Default | [ |
93+ | | | | "message" => "This value is not a valid email address.", |
94+ | | | | "mode" => null, |
95+ | | | | "normalizer" => null, |
96+ | | | | "payload" => null |
97+ | | | | ] |
98+ +---------------+----------------------------------------------------+---------+------------------------------------------------------------+
8799
88100TXT
89101 , $ tester ->getDisplay (true )
@@ -108,6 +120,11 @@ public function testOutputWithPathArgument()
108120 'firstArgument ' ,
109121 ]);
110122
123+ $ classMetadata
124+ ->expects ($ this ->exactly (2 ))
125+ ->method ('getConstraints ' )
126+ ->willReturn ([new Expression ('1 + 1 = 2 ' )]);
127+
111128 $ classMetadata
112129 ->method ('getPropertyMetadata ' )
113130 ->with ('firstArgument ' )
@@ -129,42 +146,54 @@ public function testOutputWithPathArgument()
129146Symfony\Component\Validator\Tests\Dummy\DummyClassOne
130147-----------------------------------------------------
131148
132- +---------------+--------------------------------------------------+---------+------------------------------------------------------------+
133- | Property | Name | Groups | Options |
134- +---------------+--------------------------------------------------+---------+------------------------------------------------------------+
135- | firstArgument | Symfony\Component\Validator\Constraints\NotBlank | Default | [ |
136- | | | | "allowNull" => false, |
137- | | | | "message" => "This value should not be blank.", |
138- | | | | "normalizer" => null, |
139- | | | | "payload" => null |
140- | | | | ] |
141- | firstArgument | Symfony\Component\Validator\Constraints\Email | Default | [ |
142- | | | | "message" => "This value is not a valid email address.", |
143- | | | | "mode" => null, |
144- | | | | "normalizer" => null, |
145- | | | | "payload" => null |
146- | | | | ] |
147- +---------------+--------------------------------------------------+---------+------------------------------------------------------------+
149+ +---------------+----------------------------------------------------+---------+------------------------------------------------------------+
150+ | Property | Name | Groups | Options |
151+ +---------------+----------------------------------------------------+---------+------------------------------------------------------------+
152+ | - | Symfony\Component\Validator\Constraints\Expression | Default | [ |
153+ | | | | "expression" => "1 + 1 = 2", |
154+ | | | | "message" => "This value is not valid.", |
155+ | | | | "payload" => null, |
156+ | | | | "values" => [] |
157+ | | | | ] |
158+ | firstArgument | Symfony\Component\Validator\Constraints\NotBlank | Default | [ |
159+ | | | | "allowNull" => false, |
160+ | | | | "message" => "This value should not be blank.", |
161+ | | | | "normalizer" => null, |
162+ | | | | "payload" => null |
163+ | | | | ] |
164+ | firstArgument | Symfony\Component\Validator\Constraints\Email | Default | [ |
165+ | | | | "message" => "This value is not a valid email address.", |
166+ | | | | "mode" => null, |
167+ | | | | "normalizer" => null, |
168+ | | | | "payload" => null |
169+ | | | | ] |
170+ +---------------+----------------------------------------------------+---------+------------------------------------------------------------+
148171
149172Symfony\Component\Validator\Tests\Dummy\DummyClassTwo
150173-----------------------------------------------------
151174
152- +---------------+--------------------------------------------------+---------+------------------------------------------------------------+
153- | Property | Name | Groups | Options |
154- +---------------+--------------------------------------------------+---------+------------------------------------------------------------+
155- | firstArgument | Symfony\Component\Validator\Constraints\NotBlank | Default | [ |
156- | | | | "allowNull" => false, |
157- | | | | "message" => "This value should not be blank.", |
158- | | | | "normalizer" => null, |
159- | | | | "payload" => null |
160- | | | | ] |
161- | firstArgument | Symfony\Component\Validator\Constraints\Email | Default | [ |
162- | | | | "message" => "This value is not a valid email address.", |
163- | | | | "mode" => null, |
164- | | | | "normalizer" => null, |
165- | | | | "payload" => null |
166- | | | | ] |
167- +---------------+--------------------------------------------------+---------+------------------------------------------------------------+
175+ +---------------+----------------------------------------------------+---------+------------------------------------------------------------+
176+ | Property | Name | Groups | Options |
177+ +---------------+----------------------------------------------------+---------+------------------------------------------------------------+
178+ | - | Symfony\Component\Validator\Constraints\Expression | Default | [ |
179+ | | | | "expression" => "1 + 1 = 2", |
180+ | | | | "message" => "This value is not valid.", |
181+ | | | | "payload" => null, |
182+ | | | | "values" => [] |
183+ | | | | ] |
184+ | firstArgument | Symfony\Component\Validator\Constraints\NotBlank | Default | [ |
185+ | | | | "allowNull" => false, |
186+ | | | | "message" => "This value should not be blank.", |
187+ | | | | "normalizer" => null, |
188+ | | | | "payload" => null |
189+ | | | | ] |
190+ | firstArgument | Symfony\Component\Validator\Constraints\Email | Default | [ |
191+ | | | | "message" => "This value is not a valid email address.", |
192+ | | | | "mode" => null, |
193+ | | | | "normalizer" => null, |
194+ | | | | "payload" => null |
195+ | | | | ] |
196+ +---------------+----------------------------------------------------+---------+------------------------------------------------------------+
168197
169198TXT
170199 , $ tester ->getDisplay (true )
0 commit comments