From ec0543be1024da7fe8f28af9d9976bcfc0c2131b Mon Sep 17 00:00:00 2001 From: Mark Cahill Date: Mon, 8 Sep 2014 15:07:49 -0400 Subject: [PATCH] Tests for associative arrays --- tests/Valitron/ValidateTest.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/Valitron/ValidateTest.php b/tests/Valitron/ValidateTest.php index b954a88..16bed82 100644 --- a/tests/Valitron/ValidateTest.php +++ b/tests/Valitron/ValidateTest.php @@ -315,6 +315,28 @@ class ValidateTest extends BaseTestCase $this->assertTrue($v->validate()); } + public function testForeachAssocValues() + { + $v = new Validator(array('values' => array( + 'foo' => 5, + 'bar' => 10, + 'baz' => 15 + ))); + $v->rule('integer', 'values.*'); + $this->assertTrue($v->validate()); + } + + public function testForeachAssocValuesFails() + { + $v = new Validator(array('values' => array( + 'foo' => 5, + 'bar' => 10, + 'baz' => 'faz' + ))); + $v->rule('integer', 'values.*'); + $this->assertFalse($v->validate()); + } + public function testForeachArrayAccess() { $v = new Validator(array('settings' => array(