diff --git a/tests/Valitron/ErrorMessagesTest.php b/tests/Valitron/ErrorMessagesTest.php index da0cef3..94f3333 100644 --- a/tests/Valitron/ErrorMessagesTest.php +++ b/tests/Valitron/ErrorMessagesTest.php @@ -57,5 +57,20 @@ class ErrorMessagesTest extends BaseTestCase $errors = $v->errors(); $this->assertEquals($messages, $errors); } + + public function testMessageWithFieldSet() + { + $v = new Validator(array('name'=>''), array(), 'en', __DIR__ . '/../lang'); + $v->rule('required', 'name'); + $v->validate(); + $this->assertEquals( $v->errors('name'), array('A value is required for Name')); + } + + public function testMessageWithFieldAndLabelSet(){ + $v = new Validator(array('name'=>''), array(), 'en', __DIR__ . '/../lang'); + $v->rule('required', 'name')->label('my name'); + $v->validate(); + $this->assertEquals( $v->errors('name'), array('A value is required for my name')); + } } diff --git a/tests/lang/en.php b/tests/lang/en.php new file mode 100644 index 0000000..60480a0 --- /dev/null +++ b/tests/lang/en.php @@ -0,0 +1,5 @@ +