@@ -4149,6 +4149,56 @@ public function testError()
4149
4149
$ this ->assertHtml ($ expected , $ result );
4150
4150
}
4151
4151
4152
+ /**
4153
+ * test error translation can use rule names for translating.
4154
+ *
4155
+ * @return void
4156
+ */
4157
+ public function testErrorRuleName ()
4158
+ {
4159
+ $ this ->article ['errors ' ] = [
4160
+ 'Article ' => [
4161
+ 'field ' => ['email ' => 'Your email was not good ' ]
4162
+ ]
4163
+ ];
4164
+ $ this ->Form ->create ($ this ->article );
4165
+
4166
+ $ result = $ this ->Form ->error ('Article.field ' );
4167
+ $ expected = [
4168
+ ['div ' => ['class ' => 'error-message ' ]],
4169
+ 'Your email was not good ' ,
4170
+ '/div ' ,
4171
+ ];
4172
+ $ this ->assertHtml ($ expected , $ result );
4173
+
4174
+ $ result = $ this ->Form ->error ('Article.field ' , ['email ' => 'Email in use ' ]);
4175
+ $ expected = [
4176
+ ['div ' => ['class ' => 'error-message ' ]],
4177
+ 'Email in use ' ,
4178
+ '/div ' ,
4179
+ ];
4180
+ $ this ->assertHtml ($ expected , $ result );
4181
+
4182
+ $ result = $ this ->Form ->error ('Article.field ' , ['Your email was not good ' => 'Email in use ' ]);
4183
+ $ expected = [
4184
+ ['div ' => ['class ' => 'error-message ' ]],
4185
+ 'Email in use ' ,
4186
+ '/div ' ,
4187
+ ];
4188
+ $ this ->assertHtml ($ expected , $ result );
4189
+
4190
+ $ result = $ this ->Form ->error ('Article.field ' , [
4191
+ 'email ' => 'Key is preferred ' ,
4192
+ 'Your email was not good ' => 'Email in use '
4193
+ ]);
4194
+ $ expected = [
4195
+ ['div ' => ['class ' => 'error-message ' ]],
4196
+ 'Key is preferred ' ,
4197
+ '/div ' ,
4198
+ ];
4199
+ $ this ->assertHtml ($ expected , $ result );
4200
+ }
4201
+
4152
4202
/**
4153
4203
* Test error with nested lists.
4154
4204
*
0 commit comments