From 6350cf8cb016ce2f016a335db100db33463639bb Mon Sep 17 00:00:00 2001 From: Willem Wollebrants Date: Sun, 27 Aug 2017 13:34:43 +0200 Subject: [PATCH] Test for pr #212 --- tests/Valitron/ErrorMessagesTest.php | 15 +++++++++++++++ tests/lang/en.php | 5 +++++ 2 files changed, 20 insertions(+) create mode 100644 tests/lang/en.php 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 @@ +